mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
validate: Restructured autoAdjust code
- First approach indicates there is no general case. Instead identifiable and correctable use cases will be gathered. No solution yet.
This commit is contained in:
parent
14ca159df4
commit
36455b5115
2 changed files with 39 additions and 36 deletions
|
@ -98,47 +98,50 @@ static void autoAdjust (
|
||||||
Interval range_filter;
|
Interval range_filter;
|
||||||
auto tracked = getTracked (database, rules, range_filter);
|
auto tracked = getTracked (database, rules, range_filter);
|
||||||
|
|
||||||
|
// Find all overlapping intervals.
|
||||||
|
std::vector <Interval> overlapping;
|
||||||
for (auto& track : tracked)
|
for (auto& track : tracked)
|
||||||
{
|
|
||||||
if (interval.range.overlap (track.range))
|
if (interval.range.overlap (track.range))
|
||||||
{
|
overlapping.push_back (track);
|
||||||
debug ("Input " + interval.dump ());
|
|
||||||
debug ("Overlaps with " + track.dump ());
|
|
||||||
|
|
||||||
if (! adjust)
|
// Diagnostics.
|
||||||
throw std::string ("You cannot overlap intervals. Adjust the start/end "
|
debug ("Input " + interval.dump ());
|
||||||
"time, or specify the :adjust hint.");
|
debug ("Overlaps with");
|
||||||
|
for (auto& overlap : overlapping)
|
||||||
|
debug (" " + overlap.dump ());
|
||||||
|
|
||||||
if (interval.range.start <= track.range.start)
|
// Overlaps are forbidden.
|
||||||
{
|
if (! adjust && overlapping.size ())
|
||||||
// interval [--------)
|
throw std::string ("You cannot overlap intervals. Correct the start/end "
|
||||||
// C [----)
|
"time, or specify the :adjust hint.");
|
||||||
//
|
|
||||||
// adjusted (dominate) C deleted
|
|
||||||
// adjusted (defer) interval split, C unmodified
|
|
||||||
|
|
||||||
// interval [--------)
|
// TODO Accumulate identifiable and correctable cases here.
|
||||||
// D [--------)
|
|
||||||
//
|
|
||||||
// adjusted (dominate) D modified
|
|
||||||
// adjusted (defer) interval modified
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// interval [--------)
|
|
||||||
// B [--------)
|
|
||||||
//
|
|
||||||
// adjusted (dominate) B modified
|
|
||||||
// adjusted (defer) interval modified
|
|
||||||
|
|
||||||
// interval [--------)
|
// interval [--------)
|
||||||
// F [-------------)
|
// C [----)
|
||||||
//
|
//
|
||||||
// adjusted (dominate) F split
|
// adjusted (dominate) C deleted
|
||||||
// adjusted (defer) interval deleted
|
// adjusted (defer) interval split, C unmodified
|
||||||
}
|
|
||||||
}
|
// interval [--------)
|
||||||
}
|
// D [--------)
|
||||||
|
//
|
||||||
|
// adjusted (dominate) D modified
|
||||||
|
// adjusted (defer) interval modified
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// interval [--------)
|
||||||
|
// B [--------)
|
||||||
|
//
|
||||||
|
// adjusted (dominate) B modified
|
||||||
|
// adjusted (defer) interval modified
|
||||||
|
|
||||||
|
// interval [--------)
|
||||||
|
// F [-------------)
|
||||||
|
//
|
||||||
|
// adjusted (dominate) F split
|
||||||
|
// adjusted (defer) interval deleted
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -116,7 +116,7 @@ class TestTrack(TestCase):
|
||||||
"""Test adding an overlapping interval fails"""
|
"""Test adding an overlapping interval fails"""
|
||||||
self.t("track 20160709T1400 - 20160709T1500 foo")
|
self.t("track 20160709T1400 - 20160709T1500 foo")
|
||||||
code, out, err = self.t.runError("track 20160709T1430 - 20160709T1530 foo")
|
code, out, err = self.t.runError("track 20160709T1430 - 20160709T1530 foo")
|
||||||
self.assertIn('You cannot overlap intervals. Adjust the start/end time, or specify the :adjust hint.', err)
|
self.assertIn('You cannot overlap intervals. Correct the start/end time, or specify the :adjust hint.', err)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from simpletap import TAPTestRunner
|
from simpletap import TAPTestRunner
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue