[PATCH 5 of 8] template: compute verb in obsfate
Boris Feld
boris.feld at octobus.net
Mon Aug 7 10:56:24 EDT 2017
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1499088807 -7200
# Mon Jul 03 15:33:27 2017 +0200
# Node ID 5b38b7216fe07a3a2ff5f1f6b3dfbe4dc986fac9
# Parent a96edc5bcdc8790719e003eefff91a4f656cc559
# EXP-Topic obsfatetemplate
template: compute verb in obsfate
Use the markers information to compute a better obsfate verb.
The current logic behind the obsfate verb is simple for the moment:
- If the successorsets is empty, the changeset has been pruned, for example:
Obsfate: pruned
- If the successorsets length is 1, the changeset has been rewritten without
divergence, for example:
Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a
- If the successorsets length is more than 1, the changeset has diverged, for
example:
Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a
As the divergence might occurs on a subset of successors, we might see some
successors twice:
Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; split
as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc
Add the logic behind computing the right verb in a separate function and
register it into FORMATSSETSFUNCTIONS list.
FORMATSSETSFUNCTIONS will contains a list of functions that can compute some
information based on obsmarkers and send back a dict that will be merged into
the obsfate data. Using a list and separate functions would help extensions to
replace some logic or add new data quite easily.
diff -r a96edc5bcdc8 -r 5b38b7216fe0 mercurial/obsutil.py
--- a/mercurial/obsutil.py Fri Aug 04 14:47:36 2017 +0200
+++ b/mercurial/obsutil.py Mon Jul 03 15:33:27 2017 +0200
@@ -553,6 +553,21 @@
cache[current] = final
return cache[initialnode]
+def _successorsetverb(successorset, markers):
+ """ Return the verb summarizing the successorset
+ """
+ if not successorset:
+ verb = 'pruned'
+ elif len(successorset) == 1:
+ verb = 'rewritten'
+ else:
+ verb = 'split'
+ return {'verb': verb}
+
+FORMATSSETSFUNCTIONS = [
+ _successorsetverb,
+]
+
def computeobsfate(successorset, rawmarkers):
""" For a successor set, get all related markers and convert every nodeid
into its hexadecimal form.
@@ -578,6 +593,10 @@
"markers": sorted(markers)
}
+ # Call an extensible list of functions to override or add new data
+ for function in FORMATSSETSFUNCTIONS:
+ data.update(function(successorset, markers))
+
return data
def successorsandmarkers(repo, ctx):
diff -r a96edc5bcdc8 -r 5b38b7216fe0 tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t Fri Aug 04 14:47:36 2017 +0200
+++ b/tests/test-obsmarker-template.t Mon Jul 03 15:33:27 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) % "rewritten as {join(successors, ", ")}; "}"} \n" )}'
+ > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, " Obsfate: {succsandmarkers % "{obsfate(succsandmarkers) % "{verb} as {join(successors, ", ")}; "}"} \n" )}'
> fatelogjson = log -G -T '{node|short}\n{if(succsandmarkers, " Obsfate: {succsandmarkers|json}\n")}'
> EOF
@@ -315,7 +315,7 @@
o 337fec4d2edc
|
| @ 471597cad322
- |/ Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a;
+ |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a;
o ea207398892e
$ hg up f257fde29c7a
@@ -356,7 +356,7 @@
o 337fec4d2edc
|
| x 471597cad322
- |/ Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a;
+ |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a;
o ea207398892e
$ hg fatelogjson --hidden
@@ -1525,7 +1525,7 @@
o dd800401bd8c
|
| x 9bd10a0775e4
- |/ Obsfate: rewritten as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c;
+ |/ Obsfate: split as 6:4a004186e638, 7:ba2ed02b0c9a, 5:dd800401bd8c;
o f897c6137566
|
| x 0dec01379d3b
@@ -1600,7 +1600,7 @@
o dd800401bd8c
|
| @ 9bd10a0775e4
- |/ Obsfate: rewritten as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; rewritten as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc;
+ |/ Obsfate: split as 9:0b997eb7ceee, 5:dd800401bd8c, 10:eceed8f98ffc; split as 8:b18bc8331526, 5:dd800401bd8c, 10:eceed8f98ffc;
o f897c6137566
|
o ea207398892e
More information about the Mercurial-devel
mailing list