[PATCH 2 of 3] resolve: extract -l/--list operation from big loop
Yuya Nishihara
yuya at tcha.org
Wed Feb 11 15:39:42 UTC 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1423630515 -32400
# Wed Feb 11 13:55:15 2015 +0900
# Node ID 50350f482b2a875944f81b3dd107b60ef92cd1cf
# Parent dc186553457068fd2865df427ee3023f5e3f1a06
resolve: extract -l/--list operation from big loop
This prepares for porting to generic templater. repo.wlock() and ms.commit()
should be unnecessary for "resolve -l".
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5277,11 +5277,25 @@ def resolve(ui, repo, *pats, **opts):
raise util.Abort(_('no files or directories specified'),
hint=('use --all to remerge all files'))
+ if show:
+ ms = mergemod.mergestate(repo)
+ m = scmutil.match(repo[None], pats, opts)
+ for f in ms:
+ if not m(f):
+ continue
+ if nostatus:
+ ui.write("%s\n" % f)
+ else:
+ ui.write("%s %s\n" % (ms[f].upper(), f),
+ label='resolve.' +
+ {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
+ return 0
+
wlock = repo.wlock()
try:
ms = mergemod.mergestate(repo)
- if not (ms.active() or repo.dirstate.p2() != nullid) and not show:
+ if not (ms.active() or repo.dirstate.p2() != nullid):
raise util.Abort(
_('resolve command not applicable when not merging'))
@@ -5295,14 +5309,7 @@ def resolve(ui, repo, *pats, **opts):
didwork = True
- if show:
- if nostatus:
- ui.write("%s\n" % f)
- else:
- ui.write("%s %s\n" % (ms[f].upper(), f),
- label='resolve.' +
- {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
- elif mark:
+ if mark:
ms.mark(f, "r")
elif unmark:
ms.mark(f, "u")
@@ -5328,16 +5335,14 @@ def resolve(ui, repo, *pats, **opts):
ms.commit()
- if not didwork and pats and not show:
+ if not didwork and pats:
ui.warn(_("arguments do not match paths that need resolving\n"))
finally:
wlock.release()
- # Nudge users into finishing an unfinished operation. We don't print
- # this with the list/show operation because we want list/show to remain
- # machine readable.
- if not list(ms.unresolved()) and not show:
+ # Nudge users into finishing an unfinished operation
+ if not list(ms.unresolved()):
ui.status(_('(no more unresolved files)\n'))
return ret
More information about the Mercurial-devel
mailing list