merge with crew-stable
authorThomas Arendsen Hein <thomas@intevation.de>
Sun, 18 Mar 2007 20:44:58 +0100
changeset 4248 815ad65cfca9
parent 4237 da6b14877195 (current diff)
parent 4242 e1cdf5f6386e (diff)
child 4249 7663780b55a7
merge with crew-stable
hgext/mq.py
--- a/hgext/mq.py	Fri Mar 16 22:58:49 2007 -0300
+++ b/hgext/mq.py	Sun Mar 18 20:44:58 2007 +0100
@@ -1146,7 +1146,7 @@
             self.explain_pushable(i)
         return unapplied
 
-    def qseries(self, repo, missing=None, start=0, length=0, status=None,
+    def qseries(self, repo, missing=None, start=0, length=None, status=None,
                 summary=False):
         def displayname(patchname):
             if summary:
@@ -1156,27 +1156,23 @@
                 msg = ''
             return '%s%s' % (patchname, msg)
 
-        def pname(i):
-            if status == 'A':
-                return self.applied[i].name
-            else:
-                return self.series[i]
-
         applied = dict.fromkeys([p.name for p in self.applied])
-        if not length:
+        if length is None:
             length = len(self.series) - start
         if not missing:
             for i in xrange(start, start+length):
+                patch = self.series[i]
+                if patch in applied:
+                    stat = 'A'
+                elif self.pushable(i)[0]:
+                    stat = 'U'
+                else:
+                    stat = 'G'
                 pfx = ''
-                patch = pname(i)
                 if self.ui.verbose:
-                    if patch in applied:
-                        stat = 'A'
-                    elif self.pushable(i)[0]:
-                        stat = 'U'
-                    else:
-                        stat = 'G'
                     pfx = '%d %s ' % (i, stat)
+                elif status and status != stat:
+                    continue
                 self.ui.write('%s%s\n' % (pfx, displayname(patch)))
         else:
             msng_list = []
@@ -1185,7 +1181,8 @@
                 for f in files:
                     fl = os.path.join(d, f)
                     if (fl not in self.series and
-                        fl not in (self.status_path, self.series_path)
+                        fl not in (self.status_path, self.series_path,
+                                   self.guards_path)
                         and not fl.startswith('.')):
                         msng_list.append(fl)
             msng_list.sort()
@@ -1460,10 +1457,7 @@
             raise util.Abort(_("patch %s is not in series file") % patch)
         end = q.series.index(patch) + 1
     else:
-        end = len(q.applied)
-    if not end:
-        return
-
+        end = q.series_end(True)
     return q.qseries(repo, length=end, status='A', summary=opts.get('summary'))
 
 def unapplied(ui, repo, patch=None, **opts):
@@ -1474,8 +1468,8 @@
             raise util.Abort(_("patch %s is not in series file") % patch)
         start = q.series.index(patch) + 1
     else:
-        start = q.series_end()
-    q.qseries(repo, start=start, summary=opts.get('summary'))
+        start = q.series_end(True)
+    q.qseries(repo, start=start, status='U', summary=opts.get('summary'))
 
 def qimport(ui, repo, *filename, **opts):
     """import a patch
@@ -2162,7 +2156,7 @@
          'hg qfold [-e] [-m <text>] [-l <file] PATCH...'),
     'qguard': (guard, [('l', 'list', None, _('list all patches and guards')),
                        ('n', 'none', None, _('drop all guards'))],
-               'hg qguard [PATCH] [+GUARD...] [-GUARD...]'),
+               'hg qguard [PATCH] [+GUARD]... [-GUARD]...'),
     'qheader': (header, [],
                 _('hg qheader [PATCH]')),
     "^qimport":
@@ -2207,7 +2201,7 @@
           ('I', 'include', [], _('include names matching the given patterns')),
           ('X', 'exclude', [], _('exclude names matching the given patterns'))
           ] + commands.commitopts,
-         'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] FILES...'),
+         'hg qrefresh [-I] [-X] [-e] [-m TEXT] [-l FILE] [-s] [FILE]...'),
     'qrename|qmv':
         (rename, [], 'hg qrename PATCH1 [PATCH2]'),
     "qrestore":
@@ -2228,7 +2222,7 @@
                  ('', 'pop', None,
                   _('pop to before first guarded applied patch')),
                  ('', 'reapply', None, _('pop, then reapply patches'))],
-                'hg qselect [OPTION...] [GUARD...]'),
+                'hg qselect [OPTION]... [GUARD]...'),
     "qseries":
         (series,
          [('m', 'missing', None, 'print patches not in series')] + seriesopts,
--- a/tests/test-mq-guards	Fri Mar 16 22:58:49 2007 -0300
+++ b/tests/test-mq-guards	Sun Mar 18 20:44:58 2007 +0100
@@ -118,3 +118,33 @@
 hg qguard d.patch +2
 echo % new.patch, b.patch: Guarded. c.patch: Applied. d.patch: Guarded.
 hg qseries -v
+
+qappunappv()
+(
+    for command in qapplied "qapplied -v" qunapplied "qunapplied -v"; do
+        echo % hg $command
+        hg $command
+    done
+)
+
+hg qpop -a
+hg qguard -l
+qappunappv
+hg qselect 1
+qappunappv
+hg qpush -a
+qappunappv
+hg qselect 2
+qappunappv
+
+for patch in `hg qseries`; do
+    echo % hg qapplied $patch
+    hg qapplied $patch
+    echo % hg qunapplied $patch
+    hg qunapplied $patch
+done
+
+echo % hg qseries -m: only b.patch should be shown
+echo the guards file was not ignored in the past
+hg qdelete -k b.patch
+hg qseries -m
--- a/tests/test-mq-guards.out	Fri Mar 16 22:58:49 2007 -0300
+++ b/tests/test-mq-guards.out	Sun Mar 18 20:44:58 2007 +0100
@@ -103,3 +103,77 @@
 1 G b.patch
 2 A c.patch
 3 G d.patch
+Patch queue now empty
+new.patch: +1 +2 -3
+b.patch: +2
+c.patch: unguarded
+d.patch: +2
+% hg qapplied
+% hg qapplied -v
+% hg qunapplied
+c.patch
+% hg qunapplied -v
+0 G new.patch
+1 G b.patch
+2 U c.patch
+3 G d.patch
+number of unguarded, unapplied patches has changed from 1 to 2
+% hg qapplied
+% hg qapplied -v
+% hg qunapplied
+new.patch
+c.patch
+% hg qunapplied -v
+0 U new.patch
+1 G b.patch
+2 U c.patch
+3 G d.patch
+applying new.patch
+skipping b.patch - guarded by ['+2']
+applying c.patch
+skipping d.patch - guarded by ['+2']
+Now at: c.patch
+% hg qapplied
+new.patch
+c.patch
+% hg qapplied -v
+0 A new.patch
+1 G b.patch
+2 A c.patch
+% hg qunapplied
+% hg qunapplied -v
+3 G d.patch
+number of unguarded, unapplied patches has changed from 0 to 1
+number of guarded, applied patches has changed from 1 to 0
+% hg qapplied
+new.patch
+c.patch
+% hg qapplied -v
+0 A new.patch
+1 U b.patch
+2 A c.patch
+% hg qunapplied
+d.patch
+% hg qunapplied -v
+3 U d.patch
+% hg qapplied new.patch
+new.patch
+% hg qunapplied new.patch
+b.patch
+d.patch
+% hg qapplied b.patch
+new.patch
+% hg qunapplied b.patch
+d.patch
+% hg qapplied c.patch
+new.patch
+c.patch
+% hg qunapplied c.patch
+d.patch
+% hg qapplied d.patch
+new.patch
+c.patch
+% hg qunapplied d.patch
+% hg qseries -m: only b.patch should be shown
+the guards file was not ignored in the past
+b.patch