resolve: port to generic templater

Test output changes because color labels are applied separately.
This commit is contained in:
Yuya Nishihara 2015-02-11 13:59:13 +09:00
parent c9de8bb4f9
commit 34b5e5774a
4 changed files with 30 additions and 10 deletions

View File

@ -5225,7 +5225,7 @@ def rename(ui, repo, *pats, **opts):
('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 @@ def resolve(ui, repo, *pats, **opts):
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()

View File

@ -278,7 +278,7 @@ Show all commands + options
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:

View File

@ -43,6 +43,10 @@ resolve -l should contain unresolved entries
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 @@ resolve -l should show resolved file as resolved
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 @@ resolve -l should be empty after commit
$ hg resolve -l
$ hg resolve -l -Tjson
[
]
resolve --all should abort when no merge in progress
$ hg resolve --all

View File

@ -338,8 +338,8 @@ test 'resolve -l'
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