[PATCH] identify: avoid a crash when given '-r wdir()'
Yuya Nishihara
yuya at tcha.org
Mon Jun 29 08:39:58 CDT 2015
On Sun, 28 Jun 2015 21:40:09 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1435531198 14400
> # Sun Jun 28 18:39:58 2015 -0400
> # Node ID 6f1a661262ebb3281f707642447887deaafafc38
> # Parent 601770f5da477240954670d51f5ea11caa40dc20
> identify: avoid a crash when given '-r wdir()'
>
> The crash was 'NoneType is not subscriptable' in hexfunc(ctx.node()), because
> the node for wdir() is None. This can be avoided simply by detecting 'wdir()'
> and taking the existing path for no given revision.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4064,6 +4064,12 @@
> if bm:
> output.append(bm)
> else:
> + if rev:
> + # If wdir() is given, translate back to None
> + ctx = scmutil.revsingle(repo, rev)
> + if ctx.rev() is None:
> + rev = None
> +
> if not rev:
> ctx = repo[None]
Perhaps we can simply do
ctx = scmutil.revsingle(repo, rev, None)
if ctx.rev() is None:
...
else:
...
More information about the Mercurial-devel
mailing list