rewriteutil: add utility to check whether empty successors should be skipped
authorManuel Jacob <me@manueljacob.de>
Sun, 12 Jul 2020 06:06:06 +0200
changeset 45122 a391d0710f22
parent 45121 b6269741ed42
child 45123 1efbfa9b36a7
rewriteutil: add utility to check whether empty successors should be skipped
mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py	Sat Jul 11 23:53:27 2020 +0200
+++ b/mercurial/rewriteutil.py	Sun Jul 12 06:06:06 2020 +0200
@@ -53,3 +53,20 @@
     if allowunstable:
         return revset.baseset()
     return repo.revs(b"(%ld::) - %ld", revs, revs)
+
+
+def skip_empty_successor(ui, command):
+    empty_successor = ui.config(b'rewrite', b'empty-successor')
+    if empty_successor == b'skip':
+        return True
+    elif empty_successor == b'keep':
+        return False
+    else:
+        raise error.ConfigError(
+            _(
+                b"%s doesn't know how to handle config "
+                b"rewrite.empty-successor=%s (only 'skip' and 'keep' are "
+                b"supported)"
+            )
+            % (command, empty_successor)
+        )