##// END OF EJS Templates
revsets: makes follow() supports file patterns (issue4757) (BC)...
liscju -
r26102:5618858d default
parent child Browse files
Show More
@@ -1039,34 +1039,37 b' def first(repo, subset, x):'
1039 return limit(repo, subset, x)
1039 return limit(repo, subset, x)
1040
1040
1041 def _follow(repo, subset, x, name, followfirst=False):
1041 def _follow(repo, subset, x, name, followfirst=False):
1042 l = getargs(x, 0, 1, _("%s takes no arguments or a filename") % name)
1042 l = getargs(x, 0, 1, _("%s takes no arguments or a pattern") % name)
1043 c = repo['.']
1043 c = repo['.']
1044 if l:
1044 if l:
1045 x = getstring(l[0], _("%s expected a filename") % name)
1045 x = getstring(l[0], _("%s expected a pattern") % name)
1046 if x in c:
1046 matcher = matchmod.match(repo.root, repo.getcwd(), [x],
1047 cx = c[x]
1047 ctx=repo[None], default='path')
1048 s = set(ctx.rev() for ctx in cx.ancestors(followfirst=followfirst))
1048
1049 # include the revision responsible for the most recent version
1049 s = set()
1050 s.add(cx.introrev())
1050 for fname in c:
1051 else:
1051 if matcher(fname):
1052 return baseset()
1052 fctx = c[fname]
1053 s = s.union(set(c.rev() for c in fctx.ancestors(followfirst)))
1054 # include the revision responsible for the most recent version
1055 s.add(fctx.introrev())
1053 else:
1056 else:
1054 s = _revancestors(repo, baseset([c.rev()]), followfirst)
1057 s = _revancestors(repo, baseset([c.rev()]), followfirst)
1055
1058
1056 return subset & s
1059 return subset & s
1057
1060
1058 def follow(repo, subset, x):
1061 def follow(repo, subset, x):
1059 """``follow([file])``
1062 """``follow([pattern])``
1060 An alias for ``::.`` (ancestors of the working directory's first parent).
1063 An alias for ``::.`` (ancestors of the working directory's first parent).
1061 If a filename is specified, the history of the given file is followed,
1064 If pattern is specified, the histories of files matching given
1062 including copies.
1065 pattern is followed, including copies.
1063 """
1066 """
1064 return _follow(repo, subset, x, 'follow')
1067 return _follow(repo, subset, x, 'follow')
1065
1068
1066 def _followfirst(repo, subset, x):
1069 def _followfirst(repo, subset, x):
1067 # ``followfirst([file])``
1070 # ``followfirst([pattern])``
1068 # Like ``follow([file])`` but follows only the first parent of
1071 # Like ``follow([pattern])`` but follows only the first parent of
1069 # every revision or file revision.
1072 # every revisions or files revisions.
1070 return _follow(repo, subset, x, '_followfirst', followfirst=True)
1073 return _follow(repo, subset, x, '_followfirst', followfirst=True)
1071
1074
1072 def getall(repo, subset, x):
1075 def getall(repo, subset, x):
@@ -620,6 +620,21 b' log --follow tests'
620 $ hg up -C 1
620 $ hg up -C 1
621 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
621 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
622 $ echo b1 > b1
622 $ echo b1 > b1
623
624 log -r "follow('set:clean()')"
625
626 $ hg log -r "follow('set:clean()')"
627 changeset: 0:67e992f2c4f3
628 user: test
629 date: Thu Jan 01 00:00:01 1970 +0000
630 summary: base
631
632 changeset: 1:3d5bf5654eda
633 user: test
634 date: Thu Jan 01 00:00:01 1970 +0000
635 summary: r1
636
637
623 $ hg ci -Amb1 -d '1 0'
638 $ hg ci -Amb1 -d '1 0'
624 adding b1
639 adding b1
625 created new head
640 created new head
@@ -646,7 +661,26 b' log -f'
646 summary: base
661 summary: base
647
662
648
663
664 log -r follow('glob:b*')
649
665
666 $ hg log -r "follow('glob:b*')"
667 changeset: 0:67e992f2c4f3
668 user: test
669 date: Thu Jan 01 00:00:01 1970 +0000
670 summary: base
671
672 changeset: 1:3d5bf5654eda
673 user: test
674 date: Thu Jan 01 00:00:01 1970 +0000
675 summary: r1
676
677 changeset: 3:e62f78d544b4
678 tag: tip
679 parent: 1:3d5bf5654eda
680 user: test
681 date: Thu Jan 01 00:00:01 1970 +0000
682 summary: b1
683
650 log -f -r '1 + 4'
684 log -f -r '1 + 4'
651
685
652 $ hg up -C 0
686 $ hg up -C 0
@@ -673,6 +707,16 b" log -f -r '1 + 4'"
673 date: Thu Jan 01 00:00:01 1970 +0000
707 date: Thu Jan 01 00:00:01 1970 +0000
674 summary: base
708 summary: base
675
709
710 log -r "follow('set:grep(b2)')"
711
712 $ hg log -r "follow('set:grep(b2)')"
713 changeset: 4:ddb82e70d1a1
714 tag: tip
715 parent: 0:67e992f2c4f3
716 user: test
717 date: Thu Jan 01 00:00:01 1970 +0000
718 summary: b2
719
676 log -f -r null
720 log -f -r null
677
721
678 $ hg log -f -r null
722 $ hg log -f -r null
General Comments 0
You need to be logged in to leave comments. Login now