If calling undo on an operation the removes many entries from the
datafiles, there would be many 0 length size files remaining in the data
directory. Now they will be removed if they are empty so they will not
longer need to be checked when parsing the database.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Allows the user to specify a maximum number of entries to store in the
undo file. By default the behavior is unchanged, and the file will grow
unbounded without user intervention.
journal.size = 0 will disable storing any entries, journal.size < 0
indicates that the size of the journal should be unlimited (the
default), otherwise it indicates the number of entries to store.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
- This also handles the case when it is called with the `:all` hint
- When called with a range, the `track` command is recommended
- There is no forwarding to `track`
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
Move the adjustment of a new open interval that is enclosed by the
current open interval into the validation processing, where the other
overlap resolution takes place.
This will allow the start command to honor the :adjust flag when
starting a new interval that predates the current open interval.
Closes#326
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
It was possible previously to start an interval with a filter earlier
than the current filter, and if the tags matched, the command would
report success without actually moving the start time.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
Since the Intervals are all in order, we can use getTracked directly to
get overlapping intervals without the need to copy the Intervals into
another vector.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
- Add tests for JSON output
- Separate different test scenarios
- Optimize JSON output in `TagInfoDatabase::toJson ()`
- Closes#325
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- This adds the last bits to the PR started by Christian Roesch:
- Some code formatting
- Specifying both id(s) and tag(s) is an error
- Clear range for tag filter: The range is meant to set the new interval's range, not the filter's
- Added tests
- Overhauled test using relative times and testing exported intervals instead of command line output
- Closes#241
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- Only an open interval can truncate another open interval.
Otherwise the `:adjust` hint has to be applied
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- Filter shall be taken as is, not changed
- If there is a problem, the functions consuming the filter have to be adapted, not the filter
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- Add DatetimeParser::parse_range: If a date contains no time, it is assumed to be a fixed range, else an open range starting at given datetime
- Add tests for summary with named dates 'yesterday' and 'today'
- Remove closing of filter in CmdSummary.cpp
- Closes#333
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
In order to keep the database consistent, we really want all the
AtomicFiles to be finalized as a group. This will prevent an inopportune
signal from interrupting this process.
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
- This file was development only, now any other test file can serve as template for new tests
- Closes#303
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
The json::object pointer was allocated in the parse function but never
freed.
The way timwarrior is used currently, this leak does not cause any
problems, but...
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
When the Lexer breaks a line into tokens, it also wants to return the
type of the token. This information isn't used by the IntervalFactory
and it slows down the operation since dates end up being parsed at least
twice, once by the Lexer to determine that the string is a date, then
again in the IntervalFactory to actually construct the Date.
Before are the before and after results when exporting a database with
100 lines. The number of instructions executed went from roughly 31,552,467 to
12,952,372 on debug builds. Release builds saw a change from around 14K
to 7K instructions.
Before:
$ rm -fr ~/.timewarrior; src/timew :yes >/dev/null; for x in {100..1}; do src/timew start ${x}sec ago proj_${x} >/dev/null; done;
$ sudo chrt -f 99 valgrind --tool=callgrind --callgrind-out-file=callgrind.out src/timew export >/dev/null
==20888== Callgrind, a call-graph generating cache profiler
==20888== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==20888== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==20888== Command: src/timew export
==20888==
==20888== For interactive control, run 'callgrind_control -h'.
==20888==
==20888== Events : Ir
==20888== Collected : 31552467
==20888==
==20888== I refs: 31,552,467
After:
$ sudo chrt -f 99 valgrind --tool=callgrind --callgrind-out-file=callgrind.out src/timew export >/dev/null
==24088== Callgrind, a call-graph generating cache profiler
==24088== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==24088== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==24088== Command: src/timew export
==24088==
==24088== For interactive control, run 'callgrind_control -h'.
==24088==
==24088== Events : Ir
==24088== Collected : 12952372
==24088==
==24088== I refs: 12,952,372
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>