Patchwork [7,of,8] template: compute dates in obsfate

login
register
mail settings
Submitter Boris Feld
Date Aug. 7, 2017, 2:56 p.m.
Message ID <274933e813ada051cba2.1502117786@FB>
Download mbox | patch
Permalink /patch/22731/
State Changes Requested
Headers show

Comments

Boris Feld - Aug. 7, 2017, 2:56 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499088850 -7200
#      Mon Jul 03 15:34:10 2017 +0200
# Node ID 274933e813ada051cba2e0d193ad098d0d0b28b6
# Parent  d20670d9a7ed76321fbeed7605ceaea1200f9625
# EXP-Topic obsfatetemplate
template: compute dates in obsfate

Extract the dates from obsmarkers. Compute the min and max date from the
obsmarker range list.

Patch

diff -r d20670d9a7ed -r 274933e813ad mercurial/obsutil.py
--- a/mercurial/obsutil.py	Mon Jul 03 15:34:00 2017 +0200
+++ b/mercurial/obsutil.py	Mon Jul 03 15:34:10 2017 +0200
@@ -576,9 +576,24 @@ 
 
     return {'users': sorted(users)}
 
+def _successorsetdates(successorset, markers):
+    """returns the max date and the min date of the markers list
+    """
+
+    if not markers:
+        return {}
+
+    dates = [m[4] for m in markers]
+
+    return {
+        'min_date': min(dates),
+        'max_date': max(dates)
+    }
+
 FORMATSSETSFUNCTIONS = [
     _successorsetverb,
     _successorsetusers,
+    _successorsetdates,
 ]
 
 def computeobsfate(successorset, rawmarkers):
diff -r d20670d9a7ed -r 274933e813ad tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t	Mon Jul 03 15:34:00 2017 +0200
+++ b/tests/test-obsmarker-template.t	Mon Jul 03 15:34:10 2017 +0200
@@ -20,7 +20,7 @@ 
   >     {if(successorssets, "\n  Successors: {successorssets}")}\
   >     {if(successorssets, "\n  multi-line: {join(successorssets, "\n  multi-line: ")}")}\
   >     {if(successorssets, "\n  json: {successorssets|json}")}\n'
-  > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: {succsandmarkers % "{obsfate(succsandmarkers) % "{verb} as {join(successors, ", ")}{if(users, " by {join(users, ", ")}")}; "}"} \n" )}'
+  > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: {succsandmarkers % "{obsfate(succsandmarkers) % "{verb} as {join(successors, ", ")}{if(users, " by {join(users, ", ")}")}{if(max_date, "{ifeq(min_date, max_date, " (at {min_date|isodate})", " (between {min_date|isodate} and {max_date|isodate})")}")}; "}"} \n" )}'
   > fatelogjson = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: {succsandmarkers|json}\n")}'
   > EOF
 
@@ -89,21 +89,21 @@ 
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 2001-04-19 04:25 +0000 and 2009-02-13 23:31 +0000);
   o  ea207398892e
   
   $ hg fatelog
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 2001-04-19 04:25 +0000 and 2009-02-13 23:31 +0000);
   o  ea207398892e
   
   $ hg fatelog -v
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2 (between 2001-04-19 04:25 +0000 and 2009-02-13 23:31 +0000);
   o  ea207398892e
   
   $ hg up 'desc(A1)' --hidden
@@ -126,7 +126,7 @@ 
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2 (at 2001-04-19 04:25 +0000);
   o  ea207398892e
   
 Predecessors template should show all the predecessors as we force their display
@@ -157,11 +157,11 @@ 
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2 (at 2001-04-19 04:25 +0000);
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1;
+  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1 (at 2009-02-13 23:31 +0000);
   o  ea207398892e
   
 
@@ -206,11 +206,11 @@ 
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2 (at 2001-04-19 04:25 +0000);
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1;
+  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1 (at 2009-02-13 23:31 +0000);
   o  ea207398892e
   
   $ hg fatelogjson --hidden
@@ -314,7 +314,7 @@ 
   o  337fec4d2edc
   |
   | @  471597cad322
-  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test;
+  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up f257fde29c7a
@@ -355,7 +355,7 @@ 
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test;
+  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg fatelogjson --hidden
@@ -456,7 +456,7 @@ 
   o  eb5a0daa2192
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
@@ -485,9 +485,9 @@ 
   o  eb5a0daa2192
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test;
+  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(C0)'
@@ -523,9 +523,9 @@ 
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test;
+  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
 
@@ -662,7 +662,7 @@ 
   | o  fdf9bde5129a
   |/
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 2:fdf9bde5129a by test; rewritten as 4:019fadeab383 by test;
+  |/     Obsfate: rewritten as 2:fdf9bde5129a by test (at 1970-01-01 00:00 +0000); rewritten as 4:019fadeab383 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(A1)'
@@ -718,11 +718,11 @@ 
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/     Obsfate: rewritten as 4:019fadeab383 by test;
+  |/     Obsfate: rewritten as 4:019fadeab383 by test (at 1970-01-01 00:00 +0000);
   | @  fdf9bde5129a
   |/
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:fdf9bde5129a by test; rewritten as 3:65b757b745b9 by test;
+  |/     Obsfate: rewritten as 2:fdf9bde5129a by test (at 1970-01-01 00:00 +0000); rewritten as 3:65b757b745b9 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
 
@@ -840,7 +840,7 @@ 
   o  eb5a0daa2192
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
@@ -868,9 +868,9 @@ 
   o  eb5a0daa2192
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(B1)' --hidden
@@ -898,9 +898,9 @@ 
   o  eb5a0daa2192
   |
   | @  b7ea6d14e664
-  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(C0)'
@@ -949,11 +949,11 @@ 
   @  eb5a0daa2192
   |
   | x  b7ea6d14e664
-  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   | | x  0dec01379d3b
-  | |/     Obsfate: rewritten as 3:b7ea6d14e664 by test;
+  | |/     Obsfate: rewritten as 3:b7ea6d14e664 by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
 
@@ -1077,7 +1077,7 @@ 
   o  7a230b46bf61
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 2:7a230b46bf61 by test;
+  |/     Obsfate: rewritten as 2:7a230b46bf61 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg up 'desc(A2)'
@@ -1114,7 +1114,7 @@ 
   @  7a230b46bf61
   |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:7a230b46bf61 by test;
+  |/     Obsfate: rewritten as 2:7a230b46bf61 by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
 
@@ -1189,9 +1189,9 @@ 
   o  f897c6137566
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 3:f897c6137566 by test; rewritten as 1:471f378eab4c by test;
+  | |    Obsfate: rewritten as 3:f897c6137566 by test (at 1970-01-01 00:00 +0000); rewritten as 1:471f378eab4c by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:0dec01379d3b by test;
+  |/     Obsfate: rewritten as 2:0dec01379d3b by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
 
@@ -1447,7 +1447,7 @@ 
   | o  ba2ed02b0c9a
   | |
   | x  4a004186e638
-  |/     Obsfate: rewritten as 8:b18bc8331526 by test; rewritten as 9:0b997eb7ceee by test;
+  |/     Obsfate: rewritten as 8:b18bc8331526 by test (at 1970-01-01 00:00 +0000); rewritten as 9:0b997eb7ceee by test (at 1970-01-01 00:00 +0000);
   o  dd800401bd8c
   |
   o  f897c6137566
@@ -1520,17 +1520,17 @@ 
   | o  ba2ed02b0c9a
   | |
   | x  4a004186e638
-  |/     Obsfate: rewritten as 8:b18bc8331526 by test; rewritten as 9:0b997eb7ceee by test;
+  |/     Obsfate: rewritten as 8:b18bc8331526 by test (at 1970-01-01 00:00 +0000); rewritten as 9:0b997eb7ceee by test (at 1970-01-01 00:00 +0000);
   o  dd800401bd8c
   |
   | x  9bd10a0775e4
-  |/     Obsfate: split as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c by test;
+  |/     Obsfate: split as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c by test (at 1970-01-01 00:00 +0000);
   o  f897c6137566
   |
   | x  0dec01379d3b
-  | |    Obsfate: rewritten as 3:f897c6137566 by test; rewritten as 1:471f378eab4c by test;
+  | |    Obsfate: rewritten as 3:f897c6137566 by test (at 1970-01-01 00:00 +0000); rewritten as 1:471f378eab4c by test (at 1970-01-01 00:00 +0000);
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:0dec01379d3b by test;
+  |/     Obsfate: rewritten as 2:0dec01379d3b by test (at 1970-01-01 00:00 +0000);
   o  ea207398892e
   
   $ hg fatelogjson --hidden
@@ -1599,7 +1599,7 @@ 
   o  dd800401bd8c
   |
   | @  9bd10a0775e4
-  |/     Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc by test; split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc by test;
+  |/     Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc by test (at 1970-01-01 00:00 +0000); split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc by test (at 1970-01-01 00:00 +0000);
   o  f897c6137566
   |
   o  ea207398892e