Patchwork D3196: revsymbol: stop delegating to repo.__getitem__ for unhandled symbols (API)

login
register
mail settings
Submitter phabricator
Date April 8, 2018, 5:05 p.m.
Message ID <differential-rev-PHID-DREV-a4c2i3c4bfqcmkegzgio-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30578/
State Superseded
Headers show

Comments

phabricator - April 8, 2018, 5:05 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The only remaining cases where we were delegating unhandled symbols to
  repo.__getitem__ should now be when the symbol could not be found. In
  that case we just delegated to repo.__getitem__ for the error
  message. Let's just copy the error message instead.
  
  If there were any cases where we got e.g. a binary nodeid or an
  integer revnum into revsymbol() (e.g. via repo.lookup()), we'd now
  start raising an exception instead. That is why this is marked (API).
  
  This affects one test case, but the new behavior seems better to me. I
  can't tell if the old behavior was desired or if the test was just
  there to document how it happened to work.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py
  tests/test-pull.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-pull.t b/tests/test-pull.t
--- a/tests/test-pull.t
+++ b/tests/test-pull.t
@@ -72,7 +72,7 @@ 
   [255]
   $ hg pull -r 'xxxxxxxxxxxxxxxxxx y'
   pulling from http://foo@localhost:$HGPORT/
-  abort: unknown revision '7878787878787878787878787878787878782079'!
+  abort: unknown revision 'xxxxxxxxxxxxxxxxxx y'!
   [255]
 
 Issue622: hg init && hg pull -u URL doesn't checkout default branch
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -499,7 +499,7 @@ 
             rev = repo.changelog.rev(node)
             return repo[rev]
 
-        return repo[symbol]
+        raise error.RepoLookupError(_("unknown revision '%s'") % symbol)
 
     except error.WdirUnsupported:
         return repo[None]