##// END OF EJS Templates
log: reorganize if-else and for loop in logcmdutil._makematcher()...
Yuya Nishihara -
r46043:a03fde10 default
parent child Browse files
Show More
@@ -691,39 +691,47 b' def _makematcher(repo, revs, 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 startctxs = []
695 if follow and opts.get(b'rev'):
694 if follow and opts.get(b'rev'):
696 startctxs = [repo[r] for r in revs]
695 startctxs = [repo[r] for r in revs]
697 for f in match.files():
696 for f in match.files():
698 if follow and startctxs:
699 # No idea if the path was a directory at that revision, so
697 # No idea if the path was a directory at that revision, so
700 # take the slow path.
698 # take the slow path.
701 if any(f not in c for c in startctxs):
699 if any(f not in c for c in startctxs):
702 slowpath = True
700 slowpath = True
703 continue
701 continue
704 elif follow and f not in wctx:
702 filelog = repo.file(f)
705 # If the file exists, it may be a directory, so let it
703 if not filelog:
706 # take the slow path.
707 if os.path.exists(repo.wjoin(f)):
708 slowpath = True
709 continue
710 else:
711 raise error.Abort(
712 _(
713 b'cannot follow file not in parent '
714 b'revision: "%s"'
715 )
716 % f
717 )
718 filelog = repo.file(f)
719 if not filelog:
720 # A zero count may be a directory or deleted file, so
721 # try to find matching entries on the slow path.
722 if follow:
723 raise error.Abort(
704 raise error.Abort(
724 _(b'cannot follow nonexistent file: "%s"') % f
705 _(b'cannot follow nonexistent file: "%s"') % f
725 )
706 )
726 slowpath = True
707 elif follow:
708 for f in match.files():
709 if f not in wctx:
710 # If the file exists, it may be a directory, so let it
711 # take the slow path.
712 if os.path.exists(repo.wjoin(f)):
713 slowpath = True
714 continue
715 else:
716 raise error.Abort(
717 _(
718 b'cannot follow file not in parent '
719 b'revision: "%s"'
720 )
721 % f
722 )
723 filelog = repo.file(f)
724 if not filelog:
725 raise error.Abort(
726 _(b'cannot follow nonexistent file: "%s"') % f
727 )
728 else:
729 for f in match.files():
730 filelog = repo.file(f)
731 if not filelog:
732 # A zero count may be a directory or deleted file, so
733 # try to find matching entries on the slow path.
734 slowpath = True
727
735
728 # We decided to fall back to the slowpath because at least one
736 # We decided to fall back to the slowpath because at least one
729 # of the paths was not a file. Check to see if at least one of them
737 # of the paths was not a file. Check to see if at least one of them
@@ -2308,6 +2308,20 b' follow files from wdir'
2308 $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
2308 $ hg log -T '== {rev} ==\n' -fr'wdir()' --git --stat notfound
2309 notfound: $ENOENT$
2309 notfound: $ENOENT$
2310
2310
2311 follow added/removed files from wdir parent
2312
2313 $ hg log -T '{rev}\n' -f d1/f2
2314 abort: cannot follow nonexistent file: "d1/f2"
2315 [255]
2316
2317 $ hg log -T '{rev}\n' -f f1-copy
2318 abort: cannot follow nonexistent file: "f1-copy"
2319 [255]
2320
2321 $ hg log -T '{rev}\n' -f .d6/f1
2322 abort: cannot follow file not in parent revision: ".d6/f1"
2323 [255]
2324
2311 $ hg revert -aqC
2325 $ hg revert -aqC
2312
2326
2313 Check that adding an arbitrary name shows up in log automatically
2327 Check that adding an arbitrary name shows up in log automatically
General Comments 0
You need to be logged in to leave comments. Login now