[PATCH] rebase: add flag to commit to insert commit in stack
cdelahousse at fb.com
cdelahousse at fb.com
Wed Nov 25 20:04:10 UTC 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1448481218 28800
# Wed Nov 25 11:53:38 2015 -0800
# Node ID e08ef9c3e1409b9864e14f5b66ddd3821b4d6115
# Parent 397baacd694d0f8343888b64c200bfa926cdd893
rebase: add flag to commit to insert commit in stack
This patch adds a flag to insert a commit within an existing stack without
forcing the user to do a separate rebase step. From the call to commit --insert,
the tool flag is passed into our call to rebase in case the user specifies it.
A new test file is created because as there was no existing suitable place to
test the functionality.
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1229,6 +1229,30 @@
return obsoletenotrebased
+def commitinsert(orig, ui, repo, *args, **opts):
+ '''Insert a commit and rebase the current descendants on top of it
+ '''
+ ret = None
+ if opts.get('insert'):
+ wlock = lock = None
+ try:
+ wlock = repo.wlock()
+ lock = repo.lock()
+ descendants = list(repo.revs('(.::) - .'))
+ ret = orig(ui, repo, *args, **opts)
+ rebaseopts = {
+ 'dest' : '.',
+ 'rev' : descendants,
+ 'tool': opts.get('tool')
+ }
+
+ rebase(ui, repo, **rebaseopts)
+ finally:
+ release(lock, wlock)
+ else:
+ ret = orig(ui, repo, *args, **opts)
+ return ret
+
def summaryhook(ui, repo):
if not os.path.exists(repo.join('rebasestate')):
return
@@ -1248,6 +1272,9 @@
def uisetup(ui):
#Replace pull with a decorator to provide --rebase option
+ entry = extensions.wrapcommand(commands.table, 'commit', commitinsert)
+ entry[1].append(('', 'insert', None,
+ _("insert a commit and rebase descendants on top of it")))
entry = extensions.wrapcommand(commands.table, 'pull', pullrebase)
entry[1].append(('', 'rebase', None,
_("rebase working directory to branch head")))
More information about the Mercurial-devel
mailing list