[PATCH 3 of 3] resolve: port to generic templater

Yuya Nishihara yuya at tcha.org
Wed Feb 11 09:39:43 CST 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1423630753 -32400
#      Wed Feb 11 13:59:13 2015 +0900
# Node ID 3de7bfd959efdfa8f32cb6a1eeb35b62564c64a7
# Parent  50350f482b2a875944f81b3dd107b60ef92cd1cf
resolve: port to generic templater

Test output changes because color labels are applied separately.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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()
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -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: 
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -43,6 +43,10 @@ resolve -l should contain unresolved ent
   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 
   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
diff --git a/tests/test-status-color.t b/tests/test-status-color.t
--- a/tests/test-status-color.t
+++ b/tests/test-status-color.t
@@ -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
 


More information about the Mercurial-devel mailing list