Commit graph

1755 commits

Author SHA1 Message Date
Thomas Lauf
7858bf4be8 Inline cli.getIds ()
- It is only used to hint for the modify command if any ids are given

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 14:10:57 +02:00
Thomas Lauf
11877d3fff Restrict application of exclusions to range before now for open intervals
- Closes #370

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-18 18:58:05 +02:00
Shaun Ruffell
26fdebf754 CmdReport: Throw error if report fails to produce output
Ideally this would be fixed in libshared.

See GothenburgBitFactory/libshared#27

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-17 13:05:33 +02:00
Shaun Ruffell
670fc289e9 CmdDiagnostics: Show per-file error messages.
I had a broken symbolic link in my extensions directory. When I ran
`timew diag` it would simply print on the screen:

```
stat error 2: No such file or directory
```

After this change, there is more context information about the source of
the error:

```
  timew 1.3.0
         Platform: Linux

  Compiler:
          Version: 7.5.0
             Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
       Compliance: C++11

  Build Features
            Built: Aug 14 2020 05:57:06
           Commit: 6fe15d26
            CMake: 3.10.2
       Build type: Debug

  Configuration
    TIMEWARRIORDB: -
              Cfg: /home/sruffell/.timewarrior/timewarrior.cfg (-rw- 0 bytes)
         Database: /home/sruffell/.timewarrior (drwx 4096 bytes)
          $EDITOR: vim
      Color theme: Built-in default
                   00 01 02 03 04 05 06 07 08 09 10 11 12

  Extensions
         Location: /home/sruffell/.timewarrior/extensions (drwx 4096 bytes)
                   /home/sruffell/.timewarrior/extensions/tsheet (stat error 2: No such file or directory)
```

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-17 13:05:33 +02:00
Thomas Lauf
0137703512 Update libshared
- Version containing #26 which fixes a compilation error on FreeBSD
- Related to #258

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-16 16:04:49 +02:00
Thomas Lauf
02491f8153 Restore behaviour for adding a new interval with same tag set
- Closes #351

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-14 22:33:16 +02:00
Thomas Lauf
ea33b29986 Coding style: add spaces
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
e57fadc7a7 Fix comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
0db5598aa6 Add brackets to if-/for-statement
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
f00c4b9464 Use Range::is_started ()/Range::is_ended () instead of accessing range.start/range.end
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
bffce7ef28 Use empty() instead of size () == 0
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Thomas Lauf
a4a16ec2c5 Use const bool uniformly for variable 'verbose'
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-13 10:12:16 +02:00
Shaun Ruffell
e99eee55d8 CmdHelp: Include wait.h for exit() support.
Fixes the following errors when compiling on FreeBSD 12.1:

  [ 75%] Building CXX object src/commands/CMakeFiles/commands.dir/CmdHelp.cpp.o
  /home/user/timew-1.3.0/src/commands/CmdHelp.cpp:123:13: error: use of undeclared identifier 'WIFEXITED'
  return (WIFEXITED (ret)) ? WEXITSTATUS (ret) : -1;
  ^
  /home/user/timew-1.3.0/src/commands/CmdHelp.cpp:123:32: error: use of undeclared identifier 'WEXITSTATUS'
  return (WIFEXITED (ret)) ? WEXITSTATUS (ret) : -1;
  ^
  2 errors generated.
  *** Error code 1

Thanks @kbcb
Related to issue #258

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-13 09:51:31 +02:00
Shaun Ruffell
7481dab8d0 Datafile: Throw exception if Datafile::deleteInterval fails
This is particularly bad when called from the Database::modifyInterval
call, since the delete may fail, but then the addInterval will proceed.

Closes #319

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-11 10:39:34 +02:00
Shaun Ruffell
a87117db09 Remove undo file if empty
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
b0efdbc9ee Datafile: Remove empty files
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>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
a1e2def1a8 Introduce 'journal.size' config setting.
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>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
0a4644bfc7 AtomicFile: Add size() and remove() methods
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-10 22:24:52 +02:00
Shaun Ruffell
cea2e5d13f Only show tag in chart if utf8 character width is within the width
- Closes #309

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 21:44:22 +02:00
Thomas Lauf
06a4235b10 Move start of transaction down to actual database methods
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 17:53:59 +02:00
Thomas Lauf
b5aec4db8b Remove flattening of database in CmdContinue
- Should now be done during overlap resolution in `validate.cpp`

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-17 17:53:04 +02:00
Thomas Lauf
c35a08719f Move handling of starting a interval with identical tag set as the current tracking to standard overlap resolution
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-14 13:58:54 +02:00
Thomas Lauf
6618231002 CmdStart shall not accept ranges as input
- 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>
2020-07-14 13:57:15 +02:00
Thomas Lauf
91c246c42f CmdStart should not redirect to CmdTrack but issue an error message when called with range
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-13 16:40:37 +02:00
Shaun Ruffell
cc82f468e1 CmdStart: Honor the :adjust flag when overwriting a currently open interval
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>
2020-07-12 12:27:31 +02:00
Thomas Lauf
1c1066ae6c Adapt standard overlap resolution
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-07-12 12:18:54 +02:00
Shaun Ruffell
4aacba47df CmdStart: Do not assume :all hint means now
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-07-08 21:28:41 +02:00
Shaun Ruffell
6a52a412ba CmdStart: Do not silently fail if tags match
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>
2020-07-08 21:28:41 +02:00
Shaun Ruffell
356f20c9de Remove getOverlaps function
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>
2020-07-08 21:28:41 +02:00
Thomas Lauf
7bc511bc73 Update tests for TagInfoDatabase
- 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>
2020-07-02 22:42:45 +02:00
Quazgar
ca10d52927 ENH: tags.data writes one entry per line.
This makes it easier to compare and merge the tags file from different machines.

Signed-off-by: Quazgar <quazgar@posteo.de>
2020-07-02 22:38:51 +02:00
Thomas Lauf
d99872eb90 Finish implementation of 'continue by tag'
- 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>
2020-07-02 19:59:47 +02:00
Christian Rösch
3def4b10c4 Refactor code as suggested and add tests. 2020-07-01 16:16:58 +02:00
Christian Rösch
f3280966e0 Allow continue by tag. 2020-07-01 16:16:58 +02:00
Thomas Lauf
6db29f1df5 Move overlap resolution from CmdContinue to function autoAdjust
- 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>
2020-07-01 08:12:04 +02:00
Thomas Lauf
c6598b9ac8 Convert to early return
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-30 21:17:51 +02:00
Thomas Lauf
07a6dfe313 Use functions is_started() and is_ended() instead of querying start/end directly
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-29 22:09:00 +02:00
Thomas Lauf
4637cd3d4e Do not manipulate filter in getTracked
- 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>
2020-06-29 22:07:35 +02:00
Thomas Lauf
63f230013a Detect whether a date is meant as range
- 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>
2020-06-28 20:52:43 +02:00
Shaun Ruffell
59d0f1263f Mask signals while updating database
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>
2020-06-03 21:31:01 +02:00
Thomas Lauf
83ec55cdc6 Remove unused filter
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 18:44:36 +02:00
Thomas Lauf
c9eec956e4 Add hint :all
- Closes #206

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 18:44:36 +02:00
Thomas Lauf
6117ce1a84 Introduce default range parameter when requesting filter from CLI
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-03 17:47:14 +02:00
Thomas Lauf
c71eeb6dfd Add DOM-query for ids
- Closes #126

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
2169e8e928 Add/update descriptive comments
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
a508dd21ea Get and use filter from CLI when processing DOM references
- Closes #188

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
13f1de2c49 Identify DOM references by their prefix ('dom.<...>') and mark them as such when analyzing the command line
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
9ae3ace109 Make getFilter(cli) a method of CLI 2020-05-10 21:44:30 +02:00
Thomas Lauf
547bda5ef8 Extract filter so it can be injected
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00
Thomas Lauf
6e5236d472 Add DOM query dom.tracked.tags
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-05-10 21:44:30 +02:00