1037 An alias for limit(). |
1037 An alias for limit(). |
1038 """ |
1038 """ |
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): |
1073 """``all()`` |
1076 """``all()`` |
1074 All changesets, the same as ``0:tip``. |
1077 All changesets, the same as ``0:tip``. |