##// END OF EJS Templates
revset: make follow() accept keyword arguments...
Yuya Nishihara -
r35300:89b5c2ae default
parent child Browse files
Show More
@@ -909,14 +909,13 b' def first(repo, subset, x, order):'
909 return limit(repo, subset, x, order)
909 return limit(repo, subset, x, order)
910
910
911 def _follow(repo, subset, x, name, followfirst=False):
911 def _follow(repo, subset, x, name, followfirst=False):
912 l = getargs(x, 0, 2, _("%s takes no arguments or a pattern "
912 args = getargsdict(x, name, 'file startrev')
913 "and an optional revset") % name)
914 c = repo['.']
913 c = repo['.']
915 if l:
914 if 'file' in args:
916 x = getstring(l[0], _("%s expected a pattern") % name)
915 x = getstring(args['file'], _("%s expected a pattern") % name)
917 revs = [None]
916 revs = [None]
918 if len(l) >= 2:
917 if 'startrev' in args:
919 revs = getset(repo, fullreposet(repo), l[1])
918 revs = getset(repo, fullreposet(repo), args['startrev'])
920 if not revs:
919 if not revs:
921 raise error.RepoLookupError(
920 raise error.RepoLookupError(
922 _("%s expected at least one starting revision") % name)
921 _("%s expected at least one starting revision") % name)
@@ -930,23 +929,26 b' def _follow(repo, subset, x, name, follo'
930 fctxs.extend(ctx[f].introfilectx() for f in ctx.manifest().walk(m))
929 fctxs.extend(ctx[f].introfilectx() for f in ctx.manifest().walk(m))
931 s = dagop.filerevancestors(fctxs, followfirst)
930 s = dagop.filerevancestors(fctxs, followfirst)
932 else:
931 else:
932 if 'startrev' in args:
933 raise error.ParseError(_("%s takes no arguments or a pattern "
934 "and an optional revset") % name)
933 s = dagop.revancestors(repo, baseset([c.rev()]), followfirst)
935 s = dagop.revancestors(repo, baseset([c.rev()]), followfirst)
934
936
935 return subset & s
937 return subset & s
936
938
937 @predicate('follow([pattern[, startrev]])', safe=True)
939 @predicate('follow([file[, startrev]])', safe=True)
938 def follow(repo, subset, x):
940 def follow(repo, subset, x):
939 """
941 """
940 An alias for ``::.`` (ancestors of the working directory's first parent).
942 An alias for ``::.`` (ancestors of the working directory's first parent).
941 If pattern is specified, the histories of files matching given
943 If file pattern is specified, the histories of files matching given
942 pattern in the revision given by startrev are followed, including copies.
944 pattern in the revision given by startrev are followed, including copies.
943 """
945 """
944 return _follow(repo, subset, x, 'follow')
946 return _follow(repo, subset, x, 'follow')
945
947
946 @predicate('_followfirst', safe=True)
948 @predicate('_followfirst', safe=True)
947 def _followfirst(repo, subset, x):
949 def _followfirst(repo, subset, x):
948 # ``followfirst([pattern[, startrev]])``
950 # ``followfirst([file[, startrev]])``
949 # Like ``follow([pattern[, startrev]])`` but follows only the first parent
951 # Like ``follow([file[, startrev]])`` but follows only the first parent
950 # of every revisions or files revisions.
952 # of every revisions or files revisions.
951 return _follow(repo, subset, x, '_followfirst', followfirst=True)
953 return _follow(repo, subset, x, '_followfirst', followfirst=True)
952
954
@@ -735,16 +735,22 b' log -r "follow(\'set:grep(b2)\', 4)"'
735
735
736 follow files starting from multiple revisions:
736 follow files starting from multiple revisions:
737
737
738 $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', 2+3+4)"
738 $ hg log -T '{rev}: {files}\n' -r "follow('glob:b?', startrev=2+3+4)"
739 3: b1
739 3: b1
740 4: b2
740 4: b2
741
741
742 follow files starting from empty revision:
742 follow files starting from empty revision:
743
743
744 $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', .-.)"
744 $ hg log -T '{rev}: {files}\n' -r "follow('glob:*', startrev=.-.)"
745 abort: follow expected at least one starting revision!
745 abort: follow expected at least one starting revision!
746 [255]
746 [255]
747
747
748 follow starting from revisions:
749
750 $ hg log -Gq -r "follow(startrev=2+4)"
751 hg: parse error: follow takes no arguments or a pattern and an optional revset
752 [255]
753
748 $ hg up -qC 4
754 $ hg up -qC 4
749
755
750 log -f -r null
756 log -f -r null
General Comments 0
You need to be logged in to leave comments. Login now