Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 15966:610c4434973b stable
revset: include the correct first ancestor change for follow(file)
Previously we always included '.', which may not touch a file.
Instead, find the file revision present in '.' and add its linkrev.
This matches the results of 'hg log --follow file'.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 20 Jan 2012 23:52:31 -0600 |
parents | 57738b9130ae |
children | 39e60576ac98 |
comparison
equal
deleted
inserted
replaced
15965:57738b9130ae | 15966:610c4434973b |
---|---|
447 If a filename is specified, the history of the given file is followed, | 447 If a filename is specified, the history of the given file is followed, |
448 including copies. | 448 including copies. |
449 """ | 449 """ |
450 # i18n: "follow" is a keyword | 450 # i18n: "follow" is a keyword |
451 l = getargs(x, 0, 1, _("follow takes no arguments or a filename")) | 451 l = getargs(x, 0, 1, _("follow takes no arguments or a filename")) |
452 p = repo['.'].rev() | 452 c = repo['.'] |
453 if l: | 453 if l: |
454 x = getstring(l[0], _("follow expected a filename")) | 454 x = getstring(l[0], _("follow expected a filename")) |
455 if x in repo['.']: | 455 if x in c: |
456 s = set(ctx.rev() for ctx in repo['.'][x].ancestors()) | 456 cx = c[x] |
457 s = set(ctx.rev() for ctx in cx.ancestors()) | |
458 # include the revision responsible for the most recent version | |
459 s.add(cx.linkrev()) | |
457 else: | 460 else: |
458 return [] | 461 return [] |
459 else: | 462 else: |
460 s = set(repo.changelog.ancestors(p)) | 463 s = set(repo.changelog.ancestors(c.rev())) |
461 | 464 s.add(c.rev()) |
462 s |= set([p]) | 465 |
463 return [r for r in subset if r in s] | 466 return [r for r in subset if r in s] |
464 | 467 |
465 def getall(repo, subset, x): | 468 def getall(repo, subset, x): |
466 """``all()`` | 469 """``all()`` |
467 All changesets, the same as ``0:tip``. | 470 All changesets, the same as ``0:tip``. |