[PATCH 5 of 6 v2] import: refactor exact handling and split between exact and usenode
timeless
timeless at mozdev.org
Thu Dec 31 00:47:19 CST 2015
# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1451509773 0
# Wed Dec 30 21:09:33 2015 +0000
# Node ID 37c3ba3d2f3678daa5439947f20d89496282d8b0
# Parent f157383b6e9967a6c4a43ee30679f4eba6a1d6c5
import: refactor exact handling and split between exact and usenode
The usenode flag identifies when parentnode is being used.
Distinct from when exact might error if the commit isn't perfect.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -887,6 +887,8 @@
return (None, None, False)
rejects = False
+ exact = opts.get('exact')
+ usenode = exact
try:
cmdline_message = logmessage(ui, opts)
@@ -903,7 +905,7 @@
if len(parents) == 1:
parents.append(repo[nullid])
- if opts.get('exact'):
+ if usenode:
if not nodeid or not p1:
raise error.Abort(_('not a Mercurial patch'))
p1 = repo[p1]
@@ -933,7 +935,7 @@
if p2 != parents[1]:
repo.setparents(p1.node(), p2.node())
- if opts.get('exact') or importbranch:
+ if usenode or importbranch:
repo.dirstate.setbranch(branch or 'default')
partial = opts.get('partial', False)
@@ -952,7 +954,7 @@
if message:
msgs.append(message)
else:
- if opts.get('exact') or p2:
+ if usenode or p2:
# If you got here, you either use --force and know what
# you are doing or used --exact or a merge patch while
# being updated to its first parent.
@@ -960,7 +962,7 @@
else:
m = scmutil.matchfiles(repo, files or [])
editform = mergeeditform(repo[None], 'import.normal')
- if opts.get('exact'):
+ if usenode:
editor = None
else:
editor = getcommiteditor(editform=editform, **opts)
@@ -979,7 +981,7 @@
finally:
repo.ui.restoreconfig(allowemptyback)
else:
- if opts.get('exact') or importbranch:
+ if usenode or importbranch:
branch = branch or 'default'
else:
branch = p1.branch()
@@ -991,7 +993,7 @@
files, eolmode=None)
except patch.PatchError as e:
raise error.Abort(str(e))
- if opts.get('exact'):
+ if usenode:
editor = None
else:
editor = getcommiteditor(editform='import.bypass')
@@ -1004,11 +1006,11 @@
n = memctx.commit()
finally:
store.close()
- if opts.get('exact') and nocommit:
+ if exact and nocommit:
# --exact with --no-commit is still useful in that it does merge
# and branch bits
ui.warn(_("warning: can't check exact import with --no-commit\n"))
- elif opts.get('exact') and hex(n) != nodeid:
+ elif exact and hex(n) != nodeid:
raise error.Abort(_('patch is damaged or loses information'))
msg = _('applied to working directory')
if n:
More information about the Mercurial-devel
mailing list