[PATCH 7 of 8] graphlog: correctly handle calls in subdirectories

Patrick Mezard patrick at mezard.eu
Wed Apr 11 05:08:44 CDT 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1334136720 -7200
# Node ID 3f680f7af3b8bc6ff37cd84953afd152e2c93c6b
# Parent  5059d414905a40538c441c862fd2f2d41a3f8b2f
graphlog: correctly handle calls in subdirectories

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -340,7 +340,7 @@
         # "a" and "b" while "file(a) and not file(b)" does
         # not. Besides, filesets are evaluated against the working
         # directory.
-        matchargs = ['r:']
+        matchargs = ['r:', 'd:relpath']
         for p in pats:
             matchargs.append('p:' + p)
         for p in opts.get('include', []):
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -558,13 +558,14 @@
     # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass
     # a revision identifier, or the empty string to reference the
     # working directory, from which the match object is
-    # initialized. At most one 'r:' argument can be passed.
+    # initialized. Use 'd:' to set the default matching mode, default
+    # to 'glob'. At most one 'r:' and 'd:' argument can be passed.
 
     # i18n: "_matchfiles" is a keyword
     l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
     pats, inc, exc = [], [], []
     hasset = False
-    rev = None
+    rev, default = None, None
     for arg in l:
         s = getstring(arg, _("_matchfiles requires string arguments"))
         prefix, value = s[:2], s[2:]
@@ -579,10 +580,17 @@
                 raise error.ParseError(_('_matchfiles expected at most one '
                                          'revision'))
             rev = value
+        elif prefix == 'd:':
+            if default is not None:
+                raise error.ParseError(_('_matchfiles expected at most one '
+                                         'default mode'))
+            default = value
         else:
             raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
         if not hasset and matchmod.patkind(value) == 'set':
             hasset = True
+    if not default:
+        default = 'glob'
     m = None
     s = []
     for r in subset:
@@ -592,7 +600,7 @@
             if rev is not None:
                 ctx = repo[rev or None]
             m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
-                               exclude=exc, ctx=ctx)
+                               exclude=exc, ctx=ctx, default=default)
         for f in c.files():
             if m(f):
                 s.append(r)
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1600,7 +1600,9 @@
       ('symbol', '_matchfiles')
       (list
         (list
-          ('string', 'r:')
+          (list
+            ('string', 'r:')
+            ('string', 'd:relpath'))
           ('string', 'p:a'))
         ('string', 'p:c'))))
 
@@ -1617,7 +1619,9 @@
             (list
               (list
                 (list
-                  ('string', 'r:')
+                  (list
+                    ('string', 'r:')
+                    ('string', 'd:relpath'))
                   ('string', 'p:a'))
                 ('string', 'p:e'))
               ('string', 'i:a'))
@@ -1791,7 +1795,9 @@
     (func
       ('symbol', '_matchfiles')
       (list
-        ('string', 'r:')
+        (list
+          ('string', 'r:')
+          ('string', 'd:relpath'))
         ('string', 'p:set:copied()'))))
   $ testlog --include "set:copied()"
   []
@@ -1799,7 +1805,9 @@
     (func
       ('symbol', '_matchfiles')
       (list
-        ('string', 'r:')
+        (list
+          ('string', 'r:')
+          ('string', 'd:relpath'))
         ('string', 'i:set:copied()'))))
   $ testlog -r "sort(file('set:copied()'), -rev)"
   ["sort(file('set:copied()'), -rev)"]
@@ -1816,7 +1824,9 @@
     (func
       ('symbol', '_matchfiles')
       (list
-        ('string', 'r:')
+        (list
+          ('string', 'r:')
+          ('string', 'd:relpath'))
         ('string', 'p:a'))))
   $ testlog --removed --follow a
   abort: can only follow copies/renames for explicit filenames
@@ -2001,3 +2011,18 @@
     (func
       ('symbol', '_firstancestors')
       ('symbol', '6')))
+
+Test subdir
+
+  $ hg up -q 3
+  $ cd dir
+  $ testlog .
+  []
+  (group
+    (func
+      ('symbol', '_matchfiles')
+      (list
+        (list
+          ('string', 'r:')
+          ('string', 'd:relpath'))
+        ('string', 'p:.'))))
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -246,7 +246,7 @@
   7
   8
   9
-  $ log 'file(b)'
+  $ log 'file("b*")'
   1
   4
   $ log 'follow()'


More information about the Mercurial-devel mailing list