# HG changeset patch # User Manuel Jacob # Date 1594526766 -7200 # Node ID a391d0710f227a47dcacf21eb1348fd0306fa699 # Parent b6269741ed42760accf00e2eedabda754578450c rewriteutil: add utility to check whether empty successors should be skipped diff -r b6269741ed42 -r a391d0710f22 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) + )