mq: print "'foo' 'bar'", not "['foo', 'bar']" when showing guards
authorMartin Geisler <mg@aragost.com>
Tue, 31 May 2011 08:47:16 +0200
changeset 14464 00256f689f9c
parent 14463 81f559d1b9b2
child 14465 9e3a89c9e46c
mq: print "'foo' 'bar'", not "['foo', 'bar']" when showing guards The internal list representation of guards was leaking into the output. The guards were always printed using repr(guard) and that style was kept. When "hg qguard -l" prints several guards for a patch, it does so by joining the names with " " and that style was used for the error messages too.
hgext/mq.py
tests/test-mq-guards.t
tests/test-mq-qpush-fail.t
tests/test-mq.t
--- a/hgext/mq.py	Fri May 27 12:42:36 2011 +0200
+++ b/hgext/mq.py	Tue May 31 08:47:16 2011 +0200
@@ -455,13 +455,13 @@
         guards = self.active()
         exactneg = [g for g in patchguards if g[0] == '-' and g[1:] in guards]
         if exactneg:
-            return False, exactneg[0]
+            return False, repr(exactneg[0])
         pos = [g for g in patchguards if g[0] == '+']
         exactpos = [g for g in pos if g[1:] in guards]
         if pos:
             if exactpos:
-                return True, exactpos[0]
-            return False, pos
+                return True, repr(exactpos[0])
+            return False, ' '.join(map(repr, pos))
         return True, ''
 
     def explain_pushable(self, idx, all_patches=False):
@@ -479,11 +479,11 @@
                         write(_('allowing %s - no matching negative guards\n') %
                               self.series[idx])
                     else:
-                        write(_('allowing %s - guarded by %r\n') %
+                        write(_('allowing %s - guarded by %s\n') %
                               (self.series[idx], why))
             if not pushable:
                 if why:
-                    write(_('skipping %s - guarded by %r\n') %
+                    write(_('skipping %s - guarded by %s\n') %
                           (self.series[idx], why))
                 else:
                     write(_('skipping %s - no matching guards\n') %
@@ -1114,7 +1114,7 @@
                             _("cannot push to a previous patch: %s") % patch)
                 else:
                     if reason:
-                        reason = _('guarded by %r') % reason
+                        reason = _('guarded by %s') % reason
                     else:
                         reason = _('no matching guards')
                     self.ui.warn(_("cannot push '%s' - %s\n") % (patch, reason))
--- a/tests/test-mq-guards.t	Fri May 27 12:42:36 2011 +0200
+++ b/tests/test-mq-guards.t	Tue May 31 08:47:16 2011 +0200
@@ -63,7 +63,7 @@
 should fail
 
   $ hg qpush a.patch
-  cannot push 'a.patch' - guarded by ['+a']
+  cannot push 'a.patch' - guarded by '+a'
   [1]
 
   $ hg qguard a.patch
@@ -366,9 +366,9 @@
   3 G d.patch
   $ hg qpush -a
   applying new.patch
-  skipping b.patch - guarded by ['+2']
+  skipping b.patch - guarded by '+2'
   applying c.patch
-  skipping d.patch - guarded by ['+2']
+  skipping d.patch - guarded by '+2'
   now at: c.patch
   $ qappunappv
   % hg qapplied
--- a/tests/test-mq-qpush-fail.t	Fri May 27 12:42:36 2011 +0200
+++ b/tests/test-mq-qpush-fail.t	Tue May 31 08:47:16 2011 +0200
@@ -122,7 +122,7 @@
 try to push and pop while a is guarded
 
   $ hg qpush a
-  cannot push 'a' - guarded by ['+block']
+  cannot push 'a' - guarded by '+block'
   [1]
   $ hg qpush -a
   applying b
--- a/tests/test-mq.t	Fri May 27 12:42:36 2011 +0200
+++ b/tests/test-mq.t	Tue May 31 08:47:16 2011 +0200
@@ -460,7 +460,7 @@
   $ hg qguard test1b.patch -- -negguard
   $ hg qguard test2.patch -- +posguard
   $ hg qpush --move test2.patch # can't move guarded patch
-  cannot push 'test2.patch' - guarded by ['+posguard']
+  cannot push 'test2.patch' - guarded by '+posguard'
   [1]
   $ hg qselect posguard
   number of unguarded, unapplied patches has changed from 2 to 3