[PATCH 1 of 7 evolve-ext] _relocatecommit
Shusen LIU
liushusen at fb.com
Mon Dec 7 01:46:46 UTC 2015
# HG changeset patch
# User Shusen LIU <liushusen at fb.com>
# Date 1449450395 28800
# Sun Dec 06 17:06:35 2015 -0800
# Node ID 3021c118e9b77a0332cbda182fa27277b9011c04
# Parent ed63bf62ff02cf5a1c9c12841b3ed0dfa7eccf2c
_relocatecommit
diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -953,22 +953,7 @@
if r[-1]: #some conflict
raise error.Abort(
'unresolved merge conflicts (see hg help resolve)')
- if commitmsg is None:
- commitmsg = orig.description()
- extra = dict(orig.extra())
- if 'branch' in extra:
- del extra['branch']
- extra['rebase_source'] = orig.hex()
-
- backup = repo.ui.backupconfig('phases', 'new-commit')
- try:
- targetphase = max(orig.phase(), phases.draft)
- repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
- # Commit might fail if unresolved files exist
- nodenew = repo.commit(text=commitmsg, user=orig.user(),
- date=orig.date(), extra=extra)
- finally:
- repo.ui.restoreconfig(backup)
+ nodenew = _relocatecommit(repo, orig, commitmsg)
except error.Abort as exc:
repo.dirstate.beginparentchange()
repo.setparents(repo['.'].node(), nullid)
@@ -3654,3 +3639,32 @@
help.helptable.append((["evolution"], _("Safely Rewriting History"),
_helploader))
help.helptable.sort()
+
+def _relocatecommit(repo, orig, commitmsg, continued=False):
+ if commitmsg is None:
+ commitmsg = orig.description()
+ extra = dict(orig.extra())
+ if 'branch' in extra:
+ del extra['branch']
+
+ if continued:
+ source = orig.extra().get('source')
+ if source:
+ extra['source'] = source
+ extra['intermediate-source'] = orig.hex()
+ else:
+ extra['source'] = orig.hex()
+ extra.pop('rebase_source', None)
+ else:
+ extra['rebase_source'] = orig.hex()
+
+ backup = repo.ui.backupconfig('phases', 'new-commit')
+ try:
+ targetphase = max(orig.phase(), phases.draft)
+ repo.ui.setconfig('phases', 'new-commit', targetphase, 'rebase')
+ # Commit might fail if unresolved files exist
+ nodenew = repo.commit(text=commitmsg, user=orig.user(),
+ date=orig.date(), extra=extra)
+ finally:
+ repo.ui.restoreconfig(backup)
+ return nodenew
More information about the Mercurial-devel
mailing list