diff mercurial/commands.py @ 25683:3b1fc40626d8

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 28 Jun 2015 18:39:58 -0400
parents 328739ea70c3
children 0f894d2203c8
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Jun 26 14:33:34 2015 -0700
+++ b/mercurial/commands.py	Sun Jun 28 18:39:58 2015 -0400
@@ -4064,7 +4064,9 @@
             if bm:
                 output.append(bm)
     else:
-        if not rev:
+        ctx = scmutil.revsingle(repo, rev, None)
+
+        if ctx.rev() is None:
             ctx = repo[None]
             parents = ctx.parents()
             changed = ""
@@ -4079,7 +4081,6 @@
                 output.append("%s%s" %
                   ('+'.join([str(p.rev()) for p in parents]), changed))
         else:
-            ctx = scmutil.revsingle(repo, rev)
             if default or id:
                 output = [hexfunc(ctx.node())]
             if num: