Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

stable colormap: fix color of negative age

If the current changeset is younger than the annotated line,
AnnotateColorSaturation may calculate invalid color string, e.g. '#2a8ff451',
which results black background.

This fixes the issue by mapping negative age to 0.

Changeset 7d017d34af8c

Parent 0042c2064ad1

by Yuya Nishihara

Changes to 2 files · Browse files at 7d017d34af8c Showing diff from parent 0042c2064ad1 Diff from another changeset...

 
66
67
68
 
 
 
 
 
 
 
 
69
70
71
 
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@@ -66,6 +66,14 @@
  for d in (0, SECS_PER_DAY, 365 * SECS_PER_DAY):   assert_equals('#ffd4d4', cm.get_color(fakectx(0, d), d + age))   +def test_negative_age_calc(): + cm = colormap.AnnotateColorSaturation() + assert_equals('#ffaaaa', cm.get_color(fakectx(0, 0), 0), '0 days old') + assert_equals('#ffaaaa', cm.get_color(fakectx(0, 50 * SECS_PER_DAY), 0), + '-50 days old (should not raise ZeroDivisionError)') + assert_equals('#ffaaaa', cm.get_color(fakectx(0, 100 * SECS_PER_DAY), 0), + '-100 days old') +  def test_makeannotatepalette_latest_wins():   userstep = sys.maxint / 16   filectxs = [fakectx(0 * userstep, 0), fakectx(1 * userstep, 1),
 
102
103
104
105
 
106
107
108
 
102
103
104
 
105
106
107
108
@@ -102,7 +102,7 @@
  return _rescale(angle, 360.0 / self._maxhues)     def get_color(self, ctx, now): - days = _days(ctx, now) + days = max(_days(ctx, now), 0.0)   saturation = 255/((days/50) + 1)   if self._maxsaturations:   saturation = _rescaleceil(saturation, 255. / self._maxsaturations)