Patchwork D8746: rewriteutil: add utility to check whether empty successors should be skipped

login
register
mail settings
Submitter phabricator
Date July 14, 2020, 3:32 p.m.
Message ID <differential-rev-PHID-DREV-6mwbqdbpb7gbcuaquneb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/46731/
State Superseded
Headers show

Comments

phabricator - July 14, 2020, 3:32 p.m.
mjacob created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8746

AFFECTED FILES
  mercurial/rewriteutil.py

CHANGE DETAILS




To: mjacob, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/rewriteutil.py b/mercurial/rewriteutil.py
--- a/mercurial/rewriteutil.py
+++ b/mercurial/rewriteutil.py
@@ -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)
+        )