Commit graph

2941 commits

Author SHA1 Message Date
Shaun Ruffell
d62fc02649 test/problems: Change to allow match to be saved after each condition
This isn't a functional change, but will allow the capture groups to be
inspected for each of the regular expressions in a future commit.
2020-01-26 22:38:52 +01:00
Shaun Ruffell
1abf6e9320 Database: firstLine -> getLatestEntry
firstLine is ambiguous (the first line that was added in time? The first line
that will be returned when iterating the database?)

See https://github.com/GothenburgBitFactory/timewarrior/pull/269#discussion_r367922757
2020-01-26 19:49:23 +01:00
Shaun Ruffell
c7c1ea632a CmdUntag: Fix copy-paste errors from recent changes 2020-01-26 19:49:23 +01:00
Shaun Ruffell
2fcca6f949 trivial:coding-style: Add curly braces around blocks modified recently
timwarrior coding standard is for there to be curly braces around all code
blocks.

See https://github.com/GothenburgBitFactory/timewarrior/pull/269#discussion_r367937920
2020-01-26 19:49:23 +01:00
Shaun Ruffell
f45734efe0 test:modify.t: Split tests to for synthetic / non-synthetic intervals
Split the single test for synthetic interval into two separate tests.
2020-01-26 19:49:23 +01:00
Shaun Ruffell
845ab2f805 test: Check move / annotate commands with both synthetic and non-synthetic intervals in database
These tests are designed to check that `getIntervalsById()` will not
count the open interval at the end of the database twice.

See https://github.com/GothenburgBitFactory/timewarrior/pull/269/files#r368238522
2020-01-26 19:49:23 +01:00
Shaun Ruffell
7b438830e2 test: Revert recent annotate.t and move.t changes
In commits 18559df275 and eaed297964 I had updated existing
tests when I should have created new tests to check mixed synethic /
non-synethic intervals.

This change reverts those changes and a follow-on commit will add the
new tests.

See https://github.com/GothenburgBitFactory/timewarrior/pull/269/files#r368238522
2020-01-26 19:49:23 +01:00
Shaun Ruffell
d9480b591a CmdModify: Allow modification of synthetic intervals
This fixes an issue in the modify command since it was first added. This will
allow modify to work in the presence of synthetic intervals.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
9aac57c518 CmdSplit: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
a5493787ad CmdShorten: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
52115accb6 CmdResize: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
1b8c674771 CmdMove: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
18559df275 test/move.t: Make sure move handles mix of synthetic and non-synthetic intervals
This test updates one of the existing tests to make sure that an non-synthetic
interval in addition with the synthetic intervals can be moved properly.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
62bde62961 CmdLenghten: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
c65c899926 CmdJoin: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
6a62d2297e CmdDelete: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
8c8f6b7c7c CmdAnnotate: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
eaed297964 test/annotate.t: Annotate a mix of synthetic / non-synthetic intervals 2020-01-17 17:48:57 +01:00
Shaun Ruffell
a5785dd41a CmdUntag: Do not load entire database when untagging intervals
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
aa44df24c0 CmdModify: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
16d2c13f55 CmdTag: Do not load entire database
Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
2c1a4a146d CmdContinue: Do not load entire database
This change eliminates the call to getTracked with an empty filter,
which causes the entire database to be parsed.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
59ee7e47d4 Database: add assert in addInterval if start is greater than end 2020-01-17 17:48:57 +01:00
Shaun Ruffell
894f8ba5d8 Database: Add method empty 2020-01-17 17:48:57 +01:00
Shaun Ruffell
2df76a2ef0 Add helpers flattenDatabase and getIntervalsByIds
getIntervalsByIds will be used by commands that are loading complete database
currently when they really want a few intervals that the user specified by ID.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
610e78fede Remove getAllInclusions helper function
All locations in the code that was creating Intervals for all entries in
the database have been removed. This function can now be removed as
well.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
91e4da7a4c getUntracked helper function should not call getAllInclusions
The getUntracked, called as part of the `timew gaps` command, is
normally looking at a relatively recent interval. We do not want to take
the performance hit of loading the entire database into memory when
processing this command.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
b06b8cf8ae Database: add tags method for getting set of tag names
The database class now separatly tracks tag information. So for the one
place where all the inclusions were iterated over in order to build up a
tag set, we now instead ask the database for this set directly.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
5dcf226d20 Database: Switch the natural order from newest inclusion to oldest
The inclusion database for the user always starts with the most recent
entry. It is now the same way in the code as well.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
623db0c8e4 Database: Remove Database::allLines()
The Database class itself can now be used in range-based for loops for iterating
over all the lines.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
bd1f7aef99 Remove unused outerRange
outerRange is no longer used, since the filter was simply started based on the
first line in the database now.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
3ec09f9be1 getOverlaps should use non-empty range filter
We can eliminate the need to parse the entire database if we only look for
overlaps based on the latest interval.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
9c0c27b55b getLatestInterval does not need to walk all the inclusions
This does not appear to be necessary anymore given that the database lines are
generated from intervals and are all well formed. Any open interval *should* be
at the end of the database.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
86bb1465e8 getTracked does not need to read in entire database
Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
e9f860d8ce Remove call to getAllInclusions when initializing tag database 2020-01-17 17:48:57 +01:00
Shaun Ruffell
cf8c35ad55 intervalSummarize should not load the entire database
intervalSummarize is called at the end of most commands. The cost of parsing
all the lines in the database can be significant as the size of the database
grows.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
6af1101ea2 Database: Use reverse iterator in lastLine
Now that we have the iterators, we can standardize on their use.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
557fd4cb34 Database: Add forward/reverse iterator
This allows the database to be treated as a single collection of strings, but
can be used to avoid loading the entire database when only interested in recent
entries.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
ea3bbd0e85 Datafile: allLines() can return const reference instead of copy.
Not only does this eliminate the need to copy the stings to the caller, it will
also eliminate the need for any iterators over the entries in the Database from
having to hold a copy of the lines from the Datafile.

Related to #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
ff56bc4759 test/simpletap: Look for functions that start with "test_" on exceptions
Since the switch to python3, there is another method that starts with "test"
higher up in the stack which produces unhelpful file / line information on a
failed test like:

  ERROR: CommandError on file /usr/lib/python3.6/unittest/case.py line 59 in testPartExecutor: 'yield':

This change restores the previous behavior from before the switch to python 3.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
0e354da1c7 test: Use faketime instead of date -v for relative dates
Ubuntu 18.04.3 does not have the -v option to the date utility.
2020-01-17 17:48:57 +01:00
Thomas Lauf
5e385b84a1 Switch to python 3
- #259

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 19:01:26 +01:00
Thomas Lauf
3f3c4c3108 Switch to python 3
- #259

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 18:52:19 +01:00
Thomas Lauf
dc77a8c457 Use new style formatting
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 18:39:18 +01:00
Thomas Lauf
d746b422bf Accommodate PEP8
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 18:31:20 +01:00
Thomas Lauf
6c601cfeb8 Switch to python 3
- #259

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 18:30:28 +01:00
Thomas Lauf
4f657e57d9 Switch to python 3
- #259

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 15:30:17 +01:00
Thomas Lauf
7997c99106 Update README
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 15:12:33 +01:00
Thomas Lauf
42df2cb08b Update copyright years and holders
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 15:12:33 +01:00
Thomas Lauf
002a04db63 Merge same holidays from different regions
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-12-28 15:12:33 +01:00