obshistory: add _predecessorsverb() similar to _successorsetverb()
authorAnton Shestakov <av6@dwimlabs.net>
Tue, 21 Apr 2020 23:40:44 +0800
changeset 5327 b1a564cb18d0
parent 5326 99c25397889e
child 5328 a81631766575
obshistory: add _predecessorsverb() similar to _successorsetverb()
hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py	Sat Apr 25 18:51:23 2020 +0800
+++ b/hgext3rd/evolve/obshistory.py	Tue Apr 21 23:40:44 2020 +0800
@@ -738,6 +738,26 @@
         verb = b'split'
     return {b'verb': verb}
 
+def _predecessorsverb(predecessors, markers):
+    """ Return the verb summarizing a set of predecessors and related markers.
+    """
+    verb = None
+    if not predecessors:
+        # we got successors instead of predecessors, and they are empty
+        # (this is a special case for showing prunes)
+        verb = b'pruned'
+    elif len(markers) == 1 and len(markers[0][1]) > 1:
+        # peeked at the successors to see if this is a split
+        verb = b'split'
+    elif len(predecessors) == 1:
+        verb = _markerspreciseverb(markers)
+
+        if verb is None:
+            verb = b'rewritten'
+    else:
+        verb = b'folded'
+    return verb
+
 # Use a more advanced version of obsfateverb that uses effect-flag
 @eh.wrapfunction(obsutil, 'obsfateverb')
 def obsfateverb(orig, *args, **kwargs):