Mercurial > hg-stable
changeset 34907:0ccfc468423a
log: handle removed files with --line-range patterns
I.e. abort when the pattern corresponds to a removed file, as done with bare
file patterns.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Thu, 19 Oct 2017 14:55:10 +0200 |
parents | 2e45bbd3db7b |
children | 907ff34e1460 |
files | mercurial/cmdutil.py tests/test-log-linerange.t |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Oct 19 14:12:49 2017 +0200 +++ b/mercurial/cmdutil.py Thu Oct 19 14:55:10 2017 +0200 @@ -2627,6 +2627,9 @@ # Two-levels map of "rev -> file ctx -> [line range]". linerangesbyrev = {} for fname, (fromline, toline) in _parselinerangelogopt(repo, opts): + if fname not in wctx: + raise error.Abort(_('cannot follow file not in parent ' + 'revision: "%s"') % fname) fctx = wctx.filectx(fname) for fctx, linerange in dagop.blockancestors(fctx, fromline, toline): rev = fctx.introrev()
--- a/tests/test-log-linerange.t Thu Oct 19 14:12:49 2017 +0200 +++ b/tests/test-log-linerange.t Thu Oct 19 14:55:10 2017 +0200 @@ -842,6 +842,14 @@ hg: parse error: line range pattern 'glob:*a*' must match exactly one file [255] +We get an error for removed files. + + $ hg rm dir/baz + $ hg ci -m 'remove baz' --quiet + $ hg log -f -L dir/baz,5:7 -p + abort: cannot follow file not in parent revision: "dir/baz" + [255] + Graph log does work yet. $ hg log -f -L dir/baz,5:7 --graph