Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/logcmdutil.py @ 48581:3b6b43a7ace4
logcmdutil: raise `StateError` when file to follow doesn't exist
Differential Revision: https://phab.mercurial-scm.org/D11969
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 06 Jan 2022 22:09:40 -0800 |
parents | 91017508a785 |
children | 2f326ea19fbc 6000f5b25c9b |
comparison
equal
deleted
inserted
replaced
48580:91017508a785 | 48581:3b6b43a7ace4 |
---|---|
829 elif c.hasdir(f): | 829 elif c.hasdir(f): |
830 # If a directory exists in any of the start revisions, | 830 # If a directory exists in any of the start revisions, |
831 # take the slow path. | 831 # take the slow path. |
832 found = slowpath = True | 832 found = slowpath = True |
833 if not found: | 833 if not found: |
834 raise error.Abort( | 834 raise error.StateError( |
835 _( | 835 _( |
836 b'cannot follow file not in any of the specified ' | 836 b'cannot follow file not in any of the specified ' |
837 b'revisions: "%s"' | 837 b'revisions: "%s"' |
838 ) | 838 ) |
839 % f | 839 % f |
845 # take the slow path. | 845 # take the slow path. |
846 if os.path.exists(repo.wjoin(f)): | 846 if os.path.exists(repo.wjoin(f)): |
847 slowpath = True | 847 slowpath = True |
848 continue | 848 continue |
849 else: | 849 else: |
850 raise error.Abort( | 850 raise error.StateError( |
851 _( | 851 _( |
852 b'cannot follow file not in parent ' | 852 b'cannot follow file not in parent ' |
853 b'revision: "%s"' | 853 b'revision: "%s"' |
854 ) | 854 ) |
855 % f | 855 % f |
856 ) | 856 ) |
857 filelog = repo.file(f) | 857 filelog = repo.file(f) |
858 if not filelog: | 858 if not filelog: |
859 # A file exists in wdir but not in history, which means | 859 # A file exists in wdir but not in history, which means |
860 # the file isn't committed yet. | 860 # the file isn't committed yet. |
861 raise error.Abort( | 861 raise error.StateError( |
862 _(b'cannot follow nonexistent file: "%s"') % f | 862 _(b'cannot follow nonexistent file: "%s"') % f |
863 ) | 863 ) |
864 else: | 864 else: |
865 for f in match.files(): | 865 for f in match.files(): |
866 filelog = repo.file(f) | 866 filelog = repo.file(f) |
1136 | 1136 |
1137 # Two-levels map of "rev -> file ctx -> [line range]". | 1137 # Two-levels map of "rev -> file ctx -> [line range]". |
1138 linerangesbyrev = {} | 1138 linerangesbyrev = {} |
1139 for fname, (fromline, toline) in _parselinerangeopt(repo, opts): | 1139 for fname, (fromline, toline) in _parselinerangeopt(repo, opts): |
1140 if fname not in wctx: | 1140 if fname not in wctx: |
1141 raise error.Abort( | 1141 raise error.StateError( |
1142 _(b'cannot follow file not in parent revision: "%s"') % fname | 1142 _(b'cannot follow file not in parent revision: "%s"') % fname |
1143 ) | 1143 ) |
1144 fctx = wctx.filectx(fname) | 1144 fctx = wctx.filectx(fname) |
1145 for fctx, linerange in dagop.blockancestors(fctx, fromline, toline): | 1145 for fctx, linerange in dagop.blockancestors(fctx, fromline, toline): |
1146 rev = fctx.introrev() | 1146 rev = fctx.introrev() |