##// END OF EJS Templates
revset: add the 'subrepo' symbol...
Matt Harbison -
r24446:582cfcc8 default
parent child Browse files
Show More
@@ -1755,6 +1755,49 b' def sort(repo, subset, x):'
1755 1755 l.sort()
1756 1756 return baseset([e[-1] for e in l])
1757 1757
1758 def subrepo(repo, subset, x):
1759 """``subrepo([pattern])``
1760 Changesets that add, modify or remove the given subrepo. If no subrepo
1761 pattern is named, any subrepo changes are returned.
1762 """
1763 # i18n: "subrepo" is a keyword
1764 args = getargs(x, 0, 1, _('subrepo takes at most one argument'))
1765 if len(args) != 0:
1766 pat = getstring(args[0], _("subrepo requires a pattern"))
1767
1768 m = matchmod.exact(repo.root, repo.root, ['.hgsubstate'])
1769
1770 def submatches(names):
1771 k, p, m = _stringmatcher(pat)
1772 for name in names:
1773 if m(name):
1774 yield name
1775
1776 def matches(x):
1777 c = repo[x]
1778 s = repo.status(c.p1().node(), c.node(), match=m)
1779
1780 if len(args) == 0:
1781 return s.added or s.modified or s.removed
1782
1783 if s.added:
1784 return util.any(submatches(c.substate.keys()))
1785
1786 if s.modified:
1787 subs = set(c.p1().substate.keys())
1788 subs.update(c.substate.keys())
1789
1790 for path in submatches(subs):
1791 if c.p1().substate.get(path) != c.substate.get(path):
1792 return True
1793
1794 if s.removed:
1795 return util.any(submatches(c.p1().substate.keys()))
1796
1797 return False
1798
1799 return subset.filter(matches)
1800
1758 1801 def _stringmatcher(pattern):
1759 1802 """
1760 1803 accepts a string, possibly starting with 're:' or 'literal:' prefix.
@@ -1952,6 +1995,7 b' symbols = {'
1952 1995 "roots": roots,
1953 1996 "sort": sort,
1954 1997 "secret": secret,
1998 "subrepo": subrepo,
1955 1999 "matching": matching,
1956 2000 "tag": tag,
1957 2001 "tagged": tagged,
@@ -458,4 +458,85 b' Test a directory commit with a changed l'
458 458 R a.dat
459 459 R foo/bar/abc
460 460
461
462 $ echo foo > main
463 $ hg ci -m "mod parent only"
464 $ hg init sub3
465 $ echo "sub3 = sub3" >> .hgsub
466 $ echo xyz > sub3/a.txt
467 $ hg add sub3/a.txt
468 $ hg ci -Sm "add sub3"
469 committing subrepository sub3
470 $ cat .hgsub | grep -v sub3 > .hgsub1
471 $ mv .hgsub1 .hgsub
472 $ hg ci -m "remove sub3"
473
474 $ hg log -r "subrepo()" --style compact
475 0 7f491f53a367 1970-01-01 00:00 +0000 test
476 main import
477
478 1 ffe6649062fe 1970-01-01 00:00 +0000 test
479 deep nested modif should trigger a commit
480
481 2 9bb10eebee29 1970-01-01 00:00 +0000 test
482 add test.txt
483
484 3 7c64f035294f 1970-01-01 00:00 +0000 test
485 add large files
486
487 4 f734a59e2e35 1970-01-01 00:00 +0000 test
488 forget testing
489
490 11 9685a22af5db 1970-01-01 00:00 +0000 test
491 add sub3
492
493 12[tip] 2e0485b475b9 1970-01-01 00:00 +0000 test
494 remove sub3
495
496 $ hg log -r "subrepo('sub3')" --style compact
497 11 9685a22af5db 1970-01-01 00:00 +0000 test
498 add sub3
499
500 12[tip] 2e0485b475b9 1970-01-01 00:00 +0000 test
501 remove sub3
502
503 $ hg log -r "subrepo('bogus')" --style compact
504
505
506 Test .hgsubstate in the R state
507
508 $ hg rm .hgsub .hgsubstate
509 $ hg ci -m 'trash subrepo tracking'
510
511 $ hg log -r "subrepo('re:sub\d+')" --style compact
512 0 7f491f53a367 1970-01-01 00:00 +0000 test
513 main import
514
515 1 ffe6649062fe 1970-01-01 00:00 +0000 test
516 deep nested modif should trigger a commit
517
518 2 9bb10eebee29 1970-01-01 00:00 +0000 test
519 add test.txt
520
521 3 7c64f035294f 1970-01-01 00:00 +0000 test
522 add large files
523
524 4 f734a59e2e35 1970-01-01 00:00 +0000 test
525 forget testing
526
527 11 9685a22af5db 1970-01-01 00:00 +0000 test
528 add sub3
529
530 12 2e0485b475b9 1970-01-01 00:00 +0000 test
531 remove sub3
532
533 13[tip] a68b2c361653 1970-01-01 00:00 +0000 test
534 trash subrepo tracking
535
536
537 Restore the trashed subrepo tracking
538
539 $ hg rollback -q
540 $ hg update -Cq .
541
461 542 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now