martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a bit unfortunate, but it enables moving other pieces out of
  changectx's constructor without affecting the order in which we
  look up things (e.g. hex nodeid before bookmark).
  
  We convert nodeid to revnum before calling repo.__getitem__, even
  though that will result in converting back to nodeid later. This is so
  we can handle the LookupError and attempt to interpret the string as
  something else (e.g. a bookmark).
  
  We also need to start handling WdirUnsupported now, since the full hex
  nodeid "ffff..." represents the working directory. The exception is
  raised by the revlog layer.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3193

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -18,6 +18,7 @@
 
 from .i18n import _
 from .node import (
+    bin,
     hex,
     nullid,
     short,
@@ -475,8 +476,20 @@
         except (ValueError, OverflowError, IndexError):
             pass
 
+        if len(symbol) == 40:
+            try:
+                node = bin(symbol)
+                rev = repo.changelog.rev(node)
+                return repo[rev]
+            except error.FilteredLookupError:
+                raise
+            except (TypeError, LookupError):
+                pass
+
         return repo[symbol]
 
+    except error.WdirUnsupported:
+        return repo[None]
     except (error.FilteredIndexError, error.FilteredLookupError,
             error.FilteredRepoLookupError):
         raise _filterederror(repo, symbol)



To: martinvonz, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to