Mercurial > hg
changeset 24126:b4d21bbc2589
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".
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 11 Feb 2015 13:55:15 +0900 |
parents | 18af6ebd4001 |
children | 4cb8002658d6 |
files | mercurial/commands.py |
diffstat | 1 files changed, 19 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Wed Feb 11 13:47:43 2015 +0900 +++ b/mercurial/commands.py Wed Feb 11 13:55:15 2015 +0900 @@ -5277,11 +5277,25 @@ 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 @@ 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 @@ 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