Patchwork [6,of,8] template: compute user in obsfate

login
register
mail settings
Submitter Boris Feld
Date Aug. 7, 2017, 2:56 p.m.
Message ID <d20670d9a7ed76321fbe.1502117785@FB>
Download mbox | patch
Permalink /patch/22730/
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 1499088840 -7200
#      Mon Jul 03 15:34:00 2017 +0200
# Node ID d20670d9a7ed76321fbeed7605ceaea1200f9625
# Parent  5b38b7216fe07a3a2ff5f1f6b3dfbe4dc986fac9
# EXP-Topic obsfatetemplate
template: compute user in obsfate

Extract, deduplicate users informations from obs markers in order to display
them.

Print all users for the moment, we might want to only display users in verbose
mode.

Patch

diff -r 5b38b7216fe0 -r d20670d9a7ed mercurial/obsutil.py
--- a/mercurial/obsutil.py	Mon Jul 03 15:33:27 2017 +0200
+++ b/mercurial/obsutil.py	Mon Jul 03 15:34:00 2017 +0200
@@ -564,8 +564,21 @@ 
         verb = 'split'
     return {'verb': verb}
 
+def _successorsetusers(successorset, markers):
+    """ Returns a sorted list of markers users without duplicates
+    """
+    if not markers:
+        return {}
+
+    # Check that user is present in meta
+    markersmeta = [dict(m[3]) for m in markers]
+    users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
+
+    return {'users': sorted(users)}
+
 FORMATSSETSFUNCTIONS = [
     _successorsetverb,
+    _successorsetusers,
 ]
 
 def computeobsfate(successorset, rawmarkers):
diff -r 5b38b7216fe0 -r d20670d9a7ed tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t	Mon Jul 03 15:33:27 2017 +0200
+++ b/tests/test-obsmarker-template.t	Mon Jul 03 15:34:00 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, ", ")}; "}"} \n" )}'
+  > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: {succsandmarkers % "{obsfate(succsandmarkers) % "{verb} as {join(successors, ", ")}{if(users, " by {join(users, ", ")}")}; "}"} \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;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg fatelog
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:d004c8f274b9;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg fatelog -v
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:d004c8f274b9;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test1, test2;
   o  ea207398892e
   
   $ hg up 'desc(A1)' --hidden
@@ -126,7 +126,7 @@ 
   o  d004c8f274b9
   |
   | @  a468dc9b3633
-  |/     Obsfate: rewritten as 4:d004c8f274b9;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
   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;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:a468dc9b3633;
+  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1;
   o  ea207398892e
   
 
@@ -206,14 +206,13 @@ 
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/     Obsfate: rewritten as 4:d004c8f274b9;
+  |/     Obsfate: rewritten as 4:d004c8f274b9 by test2;
   | x  f137d23bb3e1
   | |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:a468dc9b3633;
+  |/     Obsfate: rewritten as 3:a468dc9b3633 by test1;
   o  ea207398892e
   
-
   $ hg fatelogjson --hidden
   @  d004c8f274b9
   |
@@ -315,7 +314,7 @@ 
   o  337fec4d2edc
   |
   | @  471597cad322
-  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a;
+  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test;
   o  ea207398892e
   
   $ hg up f257fde29c7a
@@ -356,7 +355,7 @@ 
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a;
+  |/     Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test;
   o  ea207398892e
   
   $ hg fatelogjson --hidden
@@ -457,7 +456,7 @@ 
   o  eb5a0daa2192
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
@@ -486,9 +485,9 @@ 
   o  eb5a0daa2192
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 3:eb5a0daa2192;
+  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
   o  ea207398892e
   
   $ hg up 'desc(C0)'
@@ -524,9 +523,9 @@ 
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |    Obsfate: rewritten as 3:eb5a0daa2192;
+  | |    Obsfate: rewritten as 3:eb5a0daa2192 by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 3:eb5a0daa2192;
+  |/     Obsfate: rewritten as 3:eb5a0daa2192 by test;
   o  ea207398892e
   
 
@@ -663,7 +662,7 @@ 
   | o  fdf9bde5129a
   |/
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 2:fdf9bde5129a; rewritten as 4:019fadeab383;
+  |/     Obsfate: rewritten as 2:fdf9bde5129a by test; rewritten as 4:019fadeab383 by test;
   o  ea207398892e
   
   $ hg up 'desc(A1)'
@@ -719,11 +718,11 @@ 
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/     Obsfate: rewritten as 4:019fadeab383;
+  |/     Obsfate: rewritten as 4:019fadeab383 by test;
   | @  fdf9bde5129a
   |/
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:fdf9bde5129a; rewritten as 3:65b757b745b9;
+  |/     Obsfate: rewritten as 2:fdf9bde5129a by test; rewritten as 3:65b757b745b9 by test;
   o  ea207398892e
   
 
@@ -841,7 +840,7 @@ 
   o  eb5a0daa2192
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
   o  ea207398892e
   
   $ hg up 'desc(B0)' --hidden
@@ -869,9 +868,9 @@ 
   o  eb5a0daa2192
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 4:eb5a0daa2192;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
   o  ea207398892e
   
   $ hg up 'desc(B1)' --hidden
@@ -899,9 +898,9 @@ 
   o  eb5a0daa2192
   |
   | @  b7ea6d14e664
-  | |    Obsfate: rewritten as 4:eb5a0daa2192;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
   o  ea207398892e
   
   $ hg up 'desc(C0)'
@@ -950,11 +949,11 @@ 
   @  eb5a0daa2192
   |
   | x  b7ea6d14e664
-  | |    Obsfate: rewritten as 4:eb5a0daa2192;
+  | |    Obsfate: rewritten as 4:eb5a0daa2192 by test;
   | | x  0dec01379d3b
-  | |/     Obsfate: rewritten as 3:b7ea6d14e664;
+  | |/     Obsfate: rewritten as 3:b7ea6d14e664 by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 4:eb5a0daa2192;
+  |/     Obsfate: rewritten as 4:eb5a0daa2192 by test;
   o  ea207398892e
   
 
@@ -1078,7 +1077,7 @@ 
   o  7a230b46bf61
   |
   | @  471f378eab4c
-  |/     Obsfate: rewritten as 2:7a230b46bf61;
+  |/     Obsfate: rewritten as 2:7a230b46bf61 by test;
   o  ea207398892e
   
   $ hg up 'desc(A2)'
@@ -1115,7 +1114,7 @@ 
   @  7a230b46bf61
   |
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:7a230b46bf61;
+  |/     Obsfate: rewritten as 2:7a230b46bf61 by test;
   o  ea207398892e
   
 
@@ -1190,9 +1189,9 @@ 
   o  f897c6137566
   |
   | @  0dec01379d3b
-  | |    Obsfate: rewritten as 3:f897c6137566; rewritten as 1:471f378eab4c;
+  | |    Obsfate: rewritten as 3:f897c6137566 by test; rewritten as 1:471f378eab4c by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:0dec01379d3b;
+  |/     Obsfate: rewritten as 2:0dec01379d3b by test;
   o  ea207398892e
   
 
@@ -1448,7 +1447,7 @@ 
   | o  ba2ed02b0c9a
   | |
   | x  4a004186e638
-  |/     Obsfate: rewritten as 8:b18bc8331526; rewritten as 9:0b997eb7ceee;
+  |/     Obsfate: rewritten as 8:b18bc8331526 by test; rewritten as 9:0b997eb7ceee by test;
   o  dd800401bd8c
   |
   o  f897c6137566
@@ -1521,17 +1520,17 @@ 
   | o  ba2ed02b0c9a
   | |
   | x  4a004186e638
-  |/     Obsfate: rewritten as 8:b18bc8331526; rewritten as 9:0b997eb7ceee;
+  |/     Obsfate: rewritten as 8:b18bc8331526 by test; rewritten as 9:0b997eb7ceee by test;
   o  dd800401bd8c
   |
   | x  9bd10a0775e4
-  |/     Obsfate: split as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c;
+  |/     Obsfate: split as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c by test;
   o  f897c6137566
   |
   | x  0dec01379d3b
-  | |    Obsfate: rewritten as 3:f897c6137566; rewritten as 1:471f378eab4c;
+  | |    Obsfate: rewritten as 3:f897c6137566 by test; rewritten as 1:471f378eab4c by test;
   | x  471f378eab4c
-  |/     Obsfate: rewritten as 2:0dec01379d3b;
+  |/     Obsfate: rewritten as 2:0dec01379d3b by test;
   o  ea207398892e
   
   $ hg fatelogjson --hidden
@@ -1600,7 +1599,7 @@ 
   o  dd800401bd8c
   |
   | @  9bd10a0775e4
-  |/     Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc;
+  |/     Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc by test; split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc by test;
   o  f897c6137566
   |
   o  ea207398892e