Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.py @ 45484:5f0eeda2005d
log: make -frREV PATH detect missing files before falling back to slow path
If -rREV isn't specified, "log --follow" would abort on nonexistent paths.
Let's implement this behavior for "-frREV" case as we have ctx.hasdir() now.
Otherwise "log -frREV PATH" would silently fall back to slow path and files
wouldn't be followed across renames.
The loop is quadratic (as before), but the size of the startctxs and
match.files() should be small in general.
Some tests are marked as BROKEN since file renames aren't tracked in the
slow path. This is a known limitation of the current history traversal
function.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 12 Sep 2020 07:23:47 +0900 |
parents | 07324227f6b7 |
children | 142f0dcf90d0 |
comparison
equal
deleted
inserted
replaced
45483:07324227f6b7 | 45484:5f0eeda2005d |
---|---|
690 match, pats = scmutil.matchandpats(wctx, pats, opts) | 690 match, pats = scmutil.matchandpats(wctx, pats, opts) |
691 slowpath = match.anypats() or (not match.always() and opts.get(b'removed')) | 691 slowpath = match.anypats() or (not match.always() and opts.get(b'removed')) |
692 if not slowpath: | 692 if not slowpath: |
693 follow = opts.get(b'follow') or opts.get(b'follow_first') | 693 follow = opts.get(b'follow') or opts.get(b'follow_first') |
694 if follow and opts.get(b'rev'): | 694 if follow and opts.get(b'rev'): |
695 # There may be the case that a path doesn't exist in some (but | |
696 # not all) of the specified start revisions, but let's consider | |
697 # the path is valid. Missing files will be warned by the matcher. | |
695 startctxs = [repo[r] for r in revs] | 698 startctxs = [repo[r] for r in revs] |
696 for f in match.files(): | 699 for f in match.files(): |
697 # No idea if the path was a directory at that revision, so | 700 found = False |
698 # take the slow path. | 701 for c in startctxs: |
699 if any(f not in c for c in startctxs): | 702 if f in c: |
700 slowpath = True | 703 found = True |
701 break | 704 elif c.hasdir(f): |
705 # If a directory exists in any of the start revisions, | |
706 # take the slow path. | |
707 found = slowpath = True | |
708 if not found: | |
709 raise error.Abort( | |
710 _( | |
711 b'cannot follow file not in any of the specified ' | |
712 b'revisions: "%s"' | |
713 ) | |
714 % f | |
715 ) | |
702 elif follow: | 716 elif follow: |
703 for f in match.files(): | 717 for f in match.files(): |
704 if f not in wctx: | 718 if f not in wctx: |
705 # If the file exists, it may be a directory, so let it | 719 # If the file exists, it may be a directory, so let it |
706 # take the slow path. | 720 # take the slow path. |