resolve: port to generic templater
Test output changes because color labels are applied separately.
--- a/mercurial/commands.py Wed Feb 11 13:55:15 2015 +0900
+++ b/mercurial/commands.py Wed Feb 11 13:59:13 2015 +0900
@@ -5225,7 +5225,7 @@
('m', 'mark', None, _('mark files as resolved')),
('u', 'unmark', None, _('mark files as unresolved')),
('n', 'no-status', None, _('hide status prefix'))]
- + mergetoolopts + walkopts,
+ + mergetoolopts + walkopts + formatteropts,
_('[OPTION]... [FILE]...'),
inferrepo=True)
def resolve(ui, repo, *pats, **opts):
@@ -5278,17 +5278,17 @@
hint=('use --all to remerge all files'))
if show:
+ fm = ui.formatter('resolve', opts)
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]])
+ l = 'resolve.' + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]
+ fm.startitem()
+ fm.condwrite(not nostatus, 'status', '%s ', ms[f].upper(), label=l)
+ fm.write('path', '%s\n', f, label=l)
+ fm.end()
return 0
wlock = repo.wlock()
--- a/tests/test-completion.t Wed Feb 11 13:55:15 2015 +0900
+++ b/tests/test-completion.t Wed Feb 11 13:59:13 2015 +0900
@@ -278,7 +278,7 @@
phase: public, draft, secret, force, rev
recover:
rename: after, force, include, exclude, dry-run
- resolve: all, list, mark, unmark, no-status, tool, include, exclude
+ resolve: all, list, mark, unmark, no-status, tool, include, exclude, template
revert: all, date, rev, no-backup, include, exclude, dry-run
rollback: dry-run, force
root:
--- a/tests/test-resolve.t Wed Feb 11 13:55:15 2015 +0900
+++ b/tests/test-resolve.t Wed Feb 11 13:59:13 2015 +0900
@@ -43,6 +43,10 @@
U file1
U file2
+ $ hg resolve -l --no-status
+ file1
+ file2
+
resolving an unknown path should emit a warning, but not for -l
$ hg resolve -m does-not-exist
@@ -60,6 +64,18 @@
R file1
U file2
+ $ hg resolve -l -Tjson
+ [
+ {
+ "path": "file1",
+ "status": "R"
+ },
+ {
+ "path": "file2",
+ "status": "U"
+ }
+ ]
+
resolve -m without paths should mark all resolved
$ hg resolve -m
@@ -70,6 +86,10 @@
$ hg resolve -l
+ $ hg resolve -l -Tjson
+ [
+ ]
+
resolve --all should abort when no merge in progress
$ hg resolve --all
--- a/tests/test-status-color.t Wed Feb 11 13:55:15 2015 +0900
+++ b/tests/test-status-color.t Wed Feb 11 13:59:13 2015 +0900
@@ -338,8 +338,8 @@
hg resolve with one unresolved, one resolved:
$ hg resolve --color=always -l
- \x1b[0;31;1mU a\x1b[0m (esc)
- \x1b[0;32;1mR b\x1b[0m (esc)
+ \x1b[0;31;1mU \x1b[0m\x1b[0;31;1ma\x1b[0m (esc)
+ \x1b[0;32;1mR \x1b[0m\x1b[0;32;1mb\x1b[0m (esc)
color coding of error message with current availability of curses