Commit graph

1883 commits

Author SHA1 Message Date
Thomas Lauf
0edef6eda4 Use more efficient overload with character
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2021-05-16 12:45:38 +02:00
Shaun Ruffell
a98bd14d66 Simplify getIntervalsById and getTracked
The intent here is to make similar the implementations of
getIntervalsById and getTracked, since they are both gathering a
collection of intervals from the database, but they are just using a
different criteria for which ones to pull.

This also eliminates the use of std::deque.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
73970b3755 Do not delete and then re-add the latest interval when flattening Database
Eliminates extra noise in the debug output. I.e. from #422 the original
report contained:

  >> 2021-05.data: Deleted inc 20210511T161243Z # "TRACKER-6145"
  >> 2021-05.data: Added inc 20210511T161243Z # "TRACKER-6145"

Which isn't doing anything.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
bba56cc633 getIntervalsById: Only add truly synthetic intervals to synthetic vector
This fixes an error where the latest interval, a non-synthetic interval,
is added to the synthetic array (and marked synthetic) if flatten() is
otherwise not able to convert it to a group of synthetic intervals.

When modify was attempting to edit this interval, it would fail since
synthetic intervals should not be written to the database unless the
database is being flattened and timewarrior believed the interval to be
modified was synthetic.

Closes #422

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
3e5aa0d7ec Trivial: Fix indentation in getIntervalsById
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
939491d060 Dump intervals in serialization check
The Interval::dump() method will show if intervals are synthetic or not,
which can be useful when trying to determine why a comparison is
failing.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
0460656afe Allow tags to be enclosed in double quotes
Closes #159

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-04-10 22:52:04 +02:00
Shaun Ruffell
fd6d57dbc2 Use json::{encode|decode} for reading / writing JSON.
The JSON library in libshared has functions to esacpe JSON's special
characters, but they are not used by default.

Closes #416
Related to #261

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-04-10 22:52:04 +02:00
Thomas Lauf
b189ccb020 Replace roff man pages with asciidoctor
This replaces the generation of man pages on project setup
by a on-demand generation via asciidoctor.
An exception are the man pages for the commands `day`, `month`, and `week`
which are simply redirects to the man page `timew-chart.1`. Those are now
static files in the Timewarrior repository.

A CMake find module to detect asciidoctor was added.
If asciidoctor is found, the targets `doc`, `man1`, and `man7` are created.
Those targets are also added to the default build target.

If asciidoctor is not available, the target `doc` is available, but it only
emits a message to install asciidoctor first.

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2021-02-21 20:58:30 +01:00
Thomas Lauf
65ef38658b Increase minimal CMake version
Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
According to our test images all supported distributions have CMake > 3

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2021-02-12 10:50:39 +01:00
Thomas Lauf
2cfeef1aa2 Update libshared to c1760be8686ce0b2f778832aaa1e2f98eed2ffc1
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2021-01-25 14:31:00 +01:00
Tomas Babej
e5870380a4
doc: Update copyright to 2021 2021-01-02 02:52:39 -05:00
Tomas Babej
2babc52dc5
build: Update libshared to version supporting Unicode 11 2020-12-20 15:34:04 -05:00
Thomas Lauf
ace5cbe876 Update libshared to 9d4a44f877611484233bab42fd9e5af3ef47b26c
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-11-09 21:50:47 +01:00
Thomas Lauf
a8b4055ad5 Quote tags if needed when outputting them on one line
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-10-02 08:36:46 +02:00
Thomas Lauf
5b1deaab59 Do not overwrite interval index when parsing DOM reference
- Closes #390

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-10-02 08:36:46 +02:00
Shaun Ruffell
ae5e44c558 CmdSummary: Show recent intervals that start later in day than first interval with :all
It was possible for `summary` command, when used with the :all hint, to
skip over any intervals that start later than the first interval in the
database.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-09-03 21:56:22 +02:00
Thomas Lauf
86024b1a41 Set upper limit for summary table to now if both filter and latest interval are open
- Closes #378

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-29 19:26:30 +02:00
Thomas Lauf
87c91b1f79 Update copyright
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-29 11:27:50 +02:00
Thomas Lauf
1ba3ee8a32 Block future times for command continue
- This is meant as a temporary fix until Timewarrior can handle intervals regardless of start time
- Closes #364

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 23:03:53 +02:00
Shaun Ruffell
9d43727c09 Use only the current interval duration when summarizing
There are several instances where the "total" reported in the interval
summary is confusing because the summarize function would walk backward
and add all intervals with the same set of tags.

Closes #248 and #308

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-08-21 21:41:20 +02:00
Thomas Lauf
7405d2be96 Drop empty intervals during overlap resolution
- Closes #372

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-21 18:08:13 +02:00
Thomas Lauf
55ea1aafce Fix typo
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
abf4784aba Command start now hints for command continue if called with ids
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
e69bd4b03b Coding style: Add spaces
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
3feba61459 Rework stop command
- Compute the set difference between the latest interval's tag set and the given tag set
- If no tags given, the difference is set to `{}`
- In case of an empty difference, close the current open interval, apply exclusions and update the database
- In case of a non-empty difference, just add a new open interval and let the overlap resolution do the job...

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
96aaa71eb4 Move validation for tag set up
- The given set of tags must be a subset of the latest interval's tag set (this includes the empty case)
- If not a subset, throw an error and show the first non-matching tag
- This also prevents the stop command from doing any work on the database
- Closes #280

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
Thomas Lauf
5b1c77b8aa Move validation of filter range up
- Use default range starting at `now`
- Add check for no datetime given (rare case of e.g. `timew stop :all`)

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-19 15:41:52 +02:00
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