Skip to content

Commit

Permalink
[BREAKING] Remove journal.info support
Browse files Browse the repository at this point in the history
This support will require access to all of the operations ever performed
on a task, which is not currently exposed by TaskChampion (but see #2928)
  • Loading branch information
djmitche committed Jan 17, 2023
1 parent 02543a0 commit 191b0f0
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 152 deletions.
1 change: 0 additions & 1 deletion src/TDB2.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class TDB2

friend class CmdSync; // CmdSync accesses the backlog directly
TF2 backlog;
friend class CmdInfo; // CmdInfo uses undo data to give history
TF2 undo;

private:
Expand Down
57 changes: 0 additions & 57 deletions src/commands/CmdInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ int CmdInfo::execute (std::string& output)
rc = 1;
}

// Get the undo data.
std::vector <std::string> undo;
if (Context::getContext ().config.getBoolean ("journal.info"))
undo = Context::getContext ().tdb2.undo.get_lines ();

// Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat.info
// rc.dateformat
Expand Down Expand Up @@ -530,65 +525,13 @@ int CmdInfo::execute (std::string& output)
urgencyDetails.set (row, 5, rightJustify (format (task.urgency (), 4, 4), 6));
}

// Create a third table, containing undo log change details.
Table journal;
setHeaderUnderline (journal);

if (Context::getContext ().config.getBoolean ("obfuscate"))
journal.obfuscate ();
if (Context::getContext ().config.getBoolean ("color"))
journal.forceColor ();

journal.width (Context::getContext ().getWidth ());
journal.add ("Date");
journal.add ("Modification");

if (Context::getContext ().config.getBoolean ("journal.info") &&
undo.size () > 3)
{
// Scan the undo data for entries matching this task, without making
// copies.
unsigned int i = 0;
long last_timestamp = 0;
while (i < undo.size ())
{
int when = i++;
int previous = -1;

if (! undo[i].compare (0, 3, "old", 3))
previous = i++;

int current = i++;
i++; // Separator

if (undo[current].find ("uuid:\"" + uuid) != std::string::npos)
{
if (previous != -1)
{
int row = journal.addRow ();

Datetime timestamp (strtol (undo[when].substr (5).c_str (), nullptr, 10));
journal.set (row, 0, timestamp.toString (dateformat));

Task before (undo[previous].substr (4));
Task after (undo[current].substr (4));
journal.set (row, 1, before.diffForInfo (after, dateformat, last_timestamp, Datetime(after.get("modified")).toEpoch()));
}
}
}
}

out << optionalBlankLine ()
<< view.render ()
<< '\n';

if (urgencyDetails.rows () > 0)
out << urgencyDetails.render ()
<< '\n';

if (journal.rows () > 0)
out << journal.render ()
<< '\n';
}

output = out.str ();
Expand Down
1 change: 0 additions & 1 deletion test/info.t
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class TestInfoCommand(TestCase):
self.assertRegex(out, "Urgency\s+\d+(\.\d+)?")
self.assertRegex(out, "Priority\s+H")

self.assertRegex(out, "Annotation of 'bar' added.")
self.assertIn("project", out)
self.assertIn("active", out)
self.assertIn("annotations", out)
Expand Down
2 changes: 1 addition & 1 deletion test/quotes.t
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TestBug880(TestCase):
self.assertEqual("one\\\n", out)

self.t(r"1 annotate 'two\\'")
code, out, err = self.t("long rc.verbose:nothing")
code, out, err = self.t("info rc.verbose:nothing")
self.assertIn("one\\\n", out)
self.assertIn("two\\\n", out)

Expand Down
92 changes: 0 additions & 92 deletions test/tw-1999.t

This file was deleted.

3 changes: 3 additions & 0 deletions test/tw-2514.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ task add Something I did yesterday
task 1 mod start:yesterday+18h
task 1 done end:yesterday+20h

# this does not work without journal.info
export EXPFAIL=true

# Check that 2 hour interval is reported by task info
task info | grep -F "Start deleted"
[[ ! -z `task info | grep -F "Start deleted (duration: 2:00:00)."` ]]

0 comments on commit 191b0f0

Please sign in to comment.