Commit graph

2766 commits

Author SHA1 Message Date
Thomas Lauf
fa4371d30c Return exit code of ./problems, not the last command, on macOS
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-01 20:33:40 +01:00
Thomas Lauf
5ab9b86e56 Set python version explicitly to python3
- Closes #259

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 21:32:39 +01:00
Thomas Lauf
6b75a5f92d Set bufsize to '-1' so we use io.DEFAULT_BUFFER_SIZE
- Removes RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:26:29 +01:00
Thomas Lauf
d960a5fede Drop the explicit 80-character limit from coding style
- As a general rule of thumb: "one sentence/statement per line"

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
ad9ca3e46e Remove Python 2.7 from contribution guidelines
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
2f64f38bc0 Add Developer Certificate of Origin (DCO)
- See https://developercertificate.org/

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
72f13b859f Remove obsolete code
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
cb7240fe1a Linebreak after <"""> in multiline doc-comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
457e73f772 Remove unnecessary input
- ":yes" hint already takes care of that

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
bb73c293ef Remove line breaks
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-23 19:03:54 +01:00
Thomas Lauf
28da1b55f2 Hoist verbose flag 2020-02-23 19:03:54 +01:00
Shaun Ruffell
213eb44954 Do not always create timewarrior.cfg file
I tried placing my timewarrior database in Dropbox and noticed that everytime
I ran a command, Dropbox would indicate that it was syncing. Running fswatch
on macOS I saw that there was an event for timewarrior.cfg on every run. This
change eliminates the file system events when not writing to the database.

Related to #284
2020-02-23 19:03:40 +01:00
Shaun Ruffell
dcfe0d1c3d test/docker: containers should return non-zero values on failures 2020-02-23 19:03:40 +01:00
Shaun Ruffell
926ecd7333 test: Add write-failure.t
This test uses libfiu to create random failures in fputs and the write system
calls to verify out-of-space errors on the filesystem do not corrupt the
database.

Related to #155
2020-02-23 19:03:40 +01:00
Shaun Ruffell
4798e6f26b Database: Recreate tags.data from interval data if parsing fails.
If the tags database has been corrupted for any reason we should recreate it.
This commit simplified some of the negative testing for AtomicFiles.
2020-02-23 19:03:40 +01:00
Shaun Ruffell
aa7a674ca6 Do not write tag database if it is not changed.
Database objects were unconditionally writing out the tags database
file. For commands that are not modifying any tags, this is unnecessary.
We will now track if there have been modifications so we can use it to
determine if we need to save the tags to a file.

Closes #284
2020-02-23 19:03:40 +01:00
Shaun Ruffell
4b3a907cbb Use AtomicFile for data, tags, undo, and config files
Now changes accross all of these files either happen all together or not
at all.

Related to issue #155
2020-02-23 19:03:40 +01:00
Shaun Ruffell
8e99c07d85 Introduce AtomicFiles
Introduce AtomicFile and a test of this module to the code.

AtomicFile is like File, except all writes go to temporary files until
the class method finalize_all () is called and the temporary files are
copied over the real files. If any writes fail, like when there is no
more space on the filesystem, none of the files in the database will be
modified.

Since we need version 1.00 of libfiu, I have only added it to the debian
testing container, which includes libfiu-1.00 in the default repository.

Related to #155
2020-02-23 19:03:40 +01:00
Shaun Ruffell
6db1d2b859 Do not construct File when a Path will suffice
There were places in Database, CmdReport, and CmdHelp that were using a File
object when only the Path interface was needed. This is some minor cleanup I
noticed while studying the File usage as part of preparating for converting to
AtomicFile.
2020-02-23 19:03:40 +01:00
Thomas Lauf
35a38d628c Optimize handling of implicit latest interval
- If no id is given but active time tracking (i.e. open interval) is present
  then apply the command to the open interval
2020-02-01 23:49:56 +01:00
Thomas Lauf
711848915b Test for no ids
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-01 23:49:56 +01:00
Thomas Lauf
6a08fd392b Update ChangeLog
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-02-01 23:49:56 +01:00
Shaun Ruffell
7261c23fa7 Database: Fix error when empty datafile is most recent / oldest
This fixes an error I introduced in the recent code to avoid loading the
entire database. It only now appeared because I happened to run the test
suite on the first of the month.

Below is the error I was seeing:

  $ test/delete.t
  1..5
  ok 1 - delete.t: Delete a single closed interval
  ok 2 - delete.t: Delete an interval which encloses a month border
  ok 3 - delete.t: Delete a mix of open/closed intervals
  not ok 4 - delete.t: Delete a single open interval
  # FAIL: AssertionError on file test/delete.t line 56 in test_delete_open:
  # 'self.assertEqual(len(j), 1)':
  #       0 != 1
  ok 5 - delete.t: Delete an open interval that spans over an exclusion

The problem is that when there was one entry in the 2020-01.data file
and one in the 2020-02.data file, when I deleted the single one in the
2020-02.data file, the interator constructor was not updating the lines
iterator when moving to a new file.
2020-02-01 23:36:18 +01:00
Shaun Ruffell
85c5655f79 Replace 'ѕ' with 's' in test docstrings
Since the recent switch to python3, I've been noticing that some of the tests
have been aborting with the following error when I use LANG=en_US instead of
LANG=en_US.UTF-8:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u0455' in position 57: ordinal not in range(256)

Arguably, I should run with a unicode locale while running the test, but it
*looks* to me like the original ѕ was not intended.
2020-01-26 22:38:52 +01:00
Shaun Ruffell
6852fd2924 test/problems: Report when tests do not run properly
When some of the individual tests fail to run, the `make test` target would
still pass since test/problems would not return an error which could hide the
fact that there are problems in the test.

With this change, if you do not have the python dateutil package, you will now
get output like:

  'test_totals.t' failed to run any tests.
  Passed:                           975
  Failed:                             1
  Unexpected successes:               0
  Skipped:                            0
  Expected failures:                  0
  Runtime:                         4.83 seconds

Or, if you do not have UTF-8 encoding set in your language you will get
something like:

  'track.t' failed to run all tests.
  'stop.t' failed to run all tests.
  'start.t' failed to run all tests.
  'test_totals.t' failed to run all tests.
  Passed:                           941
  Failed:                            50
  Unexpected successes:               0
  Skipped:                            0
  Expected failures:                  0
  Runtime:                         4.55 seconds
2020-01-26 22:38:52 +01:00
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