##// END OF EJS Templates
graphlog: evaluate FILE/-I/-X filesets on the working dir...
Patrick Mezard -
r16181:1fd352aa default
parent child Browse files
Show More
@@ -303,8 +303,10 b' def revset(repo, pats, opts):'
303 # pats/include/exclude cannot be represented as separate
303 # pats/include/exclude cannot be represented as separate
304 # revset expressions as their filtering logic applies at file
304 # revset expressions as their filtering logic applies at file
305 # level. For instance "-I a -X a" matches a revision touching
305 # level. For instance "-I a -X a" matches a revision touching
306 # "a" and "b" while "file(a) and not file(b)" does not.
306 # "a" and "b" while "file(a) and not file(b)" does
307 matchargs = []
307 # not. Besides, filesets are evaluated against the working
308 # directory.
309 matchargs = ['r:']
308 for p in pats:
310 for p in pats:
309 matchargs.append('p:' + p)
311 matchargs.append('p:' + p)
310 for p in opts.get('include', []):
312 for p in opts.get('include', []):
@@ -534,12 +534,16 b' def _matchfiles(repo, subset, x):'
534 #
534 #
535 # builds a match object from them and filters subset. Allowed
535 # builds a match object from them and filters subset. Allowed
536 # prefixes are 'p:' for regular patterns, 'i:' for include
536 # prefixes are 'p:' for regular patterns, 'i:' for include
537 # patterns and 'x:' for exclude patterns.
537 # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass
538 # a revision identifier, or the empty string to reference the
539 # working directory, from which the match object is
540 # initialized. At most one 'r:' argument can be passed.
538
541
539 # i18n: "_matchfiles" is a keyword
542 # i18n: "_matchfiles" is a keyword
540 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
543 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
541 pats, inc, exc = [], [], []
544 pats, inc, exc = [], [], []
542 hasset = False
545 hasset = False
546 rev = None
543 for arg in l:
547 for arg in l:
544 s = getstring(arg, _("_matchfiles requires string arguments"))
548 s = getstring(arg, _("_matchfiles requires string arguments"))
545 prefix, value = s[:2], s[2:]
549 prefix, value = s[:2], s[2:]
@@ -549,6 +553,11 b' def _matchfiles(repo, subset, x):'
549 inc.append(value)
553 inc.append(value)
550 elif prefix == 'x:':
554 elif prefix == 'x:':
551 exc.append(value)
555 exc.append(value)
556 elif prefix == 'r:':
557 if rev is not None:
558 raise error.ParseError(_('_matchfiles expected at most one '
559 'revision'))
560 rev = value
552 else:
561 else:
553 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
562 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
554 if not hasset and matchmod.patkind(value) == 'set':
563 if not hasset and matchmod.patkind(value) == 'set':
@@ -557,9 +566,12 b' def _matchfiles(repo, subset, x):'
557 s = []
566 s = []
558 for r in subset:
567 for r in subset:
559 c = repo[r]
568 c = repo[r]
560 if not m or hasset:
569 if not m or (hasset and rev is None):
570 ctx = c
571 if rev is not None:
572 ctx = repo[rev or None]
561 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
573 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
562 exclude=exc, ctx=c)
574 exclude=exc, ctx=ctx)
563 for f in c.files():
575 for f in c.files():
564 if m(f):
576 if m(f):
565 s.append(r)
577 s.append(r)
@@ -1539,12 +1539,12 b' have 2 filelog topological heads in a li'
1539 Test falling back to slow path for non-existing files
1539 Test falling back to slow path for non-existing files
1540
1540
1541 $ testlog a c
1541 $ testlog a c
1542 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'p:a'), ('string', 'p:c')))))
1542 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:c')))))
1543
1543
1544 Test multiple --include/--exclude/paths
1544 Test multiple --include/--exclude/paths
1545
1545
1546 $ testlog --include a --include e --exclude b --exclude e a e
1546 $ testlog --include a --include e --exclude b --exclude e a e
1547 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('list', ('list', ('list', ('string', 'p:a'), ('string', 'p:e')), ('string', 'i:a')), ('string', 'i:e')), ('string', 'x:b')), ('string', 'x:e')))))
1547 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('list', ('list', ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:e')), ('string', 'i:a')), ('string', 'i:e')), ('string', 'x:b')), ('string', 'x:e')))))
1548
1548
1549 Test glob expansion of pats
1549 Test glob expansion of pats
1550
1550
@@ -1660,3 +1660,10 b' Test --copies'
1660 |
1660 |
1661 o 0 add a copies:
1661 o 0 add a copies:
1662
1662
1663 Test "set:..." and parent revision
1664
1665 $ hg up -q 4
1666 $ testlog --include "set:copied()"
1667 ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'i:set:copied()')))))
1668 $ testlog -r "sort(file('set:copied()'), -rev)"
1669 ('group', ('group', ('func', ('symbol', 'sort'), ('list', ('func', ('symbol', 'file'), ('string', 'set:copied()')), ('negate', ('symbol', 'rev'))))))
General Comments 0
You need to be logged in to leave comments. Login now