Patchwork D3081: wireproto: use repo.lookup() for lookup command

login
register
mail settings
Submitter phabricator
Date April 4, 2018, 10:53 p.m.
Message ID <differential-rev-PHID-DREV-cqmrgar5wesh5mxxn4bh-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/30297/
State Superseded
Headers show

Comments

phabricator - April 4, 2018, 10:53 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I'm trying to reduce use of repo[<string>] and this seems like an
  obvious place to use repo.lookup().

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/wireproto.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - April 5, 2018, 12:46 a.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  The fact that this wasn't using `lookup()` is mind numbing. What the wire protocol command handlers should be doing in many cases is calling `repo.peer().<command>()`. Now you can see how bad the wire protocol code is :/

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -1014,8 +1014,8 @@ 
 def lookup(repo, proto, key):
     try:
         k = encoding.tolocal(key)
-        c = repo[k]
-        r = c.hex()
+        n = repo.lookup(k)
+        r = hex(n)
         success = 1
     except Exception as inst:
         r = stringutil.forcebytestr(inst)