Patchwork [2,of,5,V2] rewriteutil: add utility to check whether empty successors should be skipped

login
register
mail settings
Submitter Manuel Jacob
Date July 12, 2020, 5:13 a.m.
Message ID <216360d175b1dbbda849.1594530832@tmp>
Download mbox | patch
Permalink /patch/46700/
State Accepted
Headers show

Comments

Manuel Jacob - July 12, 2020, 5:13 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1594526766 -7200
#      Sun Jul 12 06:06:06 2020 +0200
# Node ID 216360d175b1dbbda8498bd8d4341b315e977ad1
# Parent  8263ac153567482d8794d76a897eb47a0f116e2d
# EXP-Topic keep_empty_successor
rewriteutil: add utility to check whether empty successors should be skipped

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)
+        )