##// 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 303 # pats/include/exclude cannot be represented as separate
304 304 # revset expressions as their filtering logic applies at file
305 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.
307 matchargs = []
306 # "a" and "b" while "file(a) and not file(b)" does
307 # not. Besides, filesets are evaluated against the working
308 # directory.
309 matchargs = ['r:']
308 310 for p in pats:
309 311 matchargs.append('p:' + p)
310 312 for p in opts.get('include', []):
@@ -534,12 +534,16 b' def _matchfiles(repo, subset, x):'
534 534 #
535 535 # builds a match object from them and filters subset. Allowed
536 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 542 # i18n: "_matchfiles" is a keyword
540 543 l = getargs(x, 1, -1, _("_matchfiles requires at least one argument"))
541 544 pats, inc, exc = [], [], []
542 545 hasset = False
546 rev = None
543 547 for arg in l:
544 548 s = getstring(arg, _("_matchfiles requires string arguments"))
545 549 prefix, value = s[:2], s[2:]
@@ -549,6 +553,11 b' def _matchfiles(repo, subset, x):'
549 553 inc.append(value)
550 554 elif prefix == 'x:':
551 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 561 else:
553 562 raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix)
554 563 if not hasset and matchmod.patkind(value) == 'set':
@@ -557,9 +566,12 b' def _matchfiles(repo, subset, x):'
557 566 s = []
558 567 for r in subset:
559 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 573 m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc,
562 exclude=exc, ctx=c)
574 exclude=exc, ctx=ctx)
563 575 for f in c.files():
564 576 if m(f):
565 577 s.append(r)
@@ -1539,12 +1539,12 b' have 2 filelog topological heads in a li'
1539 1539 Test falling back to slow path for non-existing files
1540 1540
1541 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 1544 Test multiple --include/--exclude/paths
1545 1545
1546 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 1549 Test glob expansion of pats
1550 1550
@@ -1660,3 +1660,10 b' Test --copies'
1660 1660 |
1661 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