# HG changeset patch # User Boris Feld <boris.f...@octobus.net> # Date 1499088807 -7200 # Mon Jul 03 15:33:27 2017 +0200 # Node ID 955b9374e3bee67ac49bf2924f44be67a6528747 # Parent 7fba236b2b17fd83a6b6446aaa84b14c65820aee # EXP-Topic obsfatetemplate template: show verb in obsfateprinter
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 7fba236b2b17 -r 955b9374e3be mercurial/obsutil.py --- a/mercurial/obsutil.py Tue Jul 04 15:50:25 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 preparesuccessorset(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 obsfatedata(repo, ctx): diff -r 7fba236b2b17 -r 955b9374e3be mercurial/templatekw.py --- a/mercurial/templatekw.py Tue Jul 04 15:50:25 2017 +0200 +++ b/mercurial/templatekw.py Mon Jul 03 15:33:27 2017 +0200 @@ -645,7 +645,7 @@ line = [] # Verb - line.append("rewritten") + line.append(obsfateline['verb']) # Successors successors = obsfateline["successors"] diff -r 7fba236b2b17 -r 955b9374e3be tests/test-obsmarker-template.t --- a/tests/test-obsmarker-template.t Tue Jul 04 15:50:25 2017 +0200 +++ b/tests/test-obsmarker-template.t Mon Jul 03 15:33:27 2017 +0200 @@ -302,7 +302,7 @@ o 337fec4d2edc | | @ 471597cad322 - |/ Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a + |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a o ea207398892e $ hg up f257fde29c7a @@ -343,7 +343,7 @@ o 337fec4d2edc | | x 471597cad322 - |/ Obsfate: rewritten as 2:337fec4d2edc, 3:f257fde29c7a + |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a o ea207398892e Test templates with folded commit @@ -1459,7 +1459,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 @@ -1513,7 +1513,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 _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel