Patchwork D3191: clone: avoid using repo.lookup() with binary nodeid

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

Comments

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

REVISION SUMMARY
  The code in hg.clone() is a bit of a mess, but it seems like the
  "checkout" variable is always a binary nodeid (tests pass when run
  with "assert len(checkout) == 20" before the
  repo.lookup()). repo.lookup() will soon work only with string inputs,
  so we need remove this use.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hg.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -711,9 +711,9 @@ 
                 uprev = None
                 status = None
                 if checkout is not None:
-                    try:
-                        uprev = destrepo.lookup(checkout)
-                    except error.RepoLookupError:
+                    if checkout in destrepo:
+                        uprev = checkout
+                    else:
                         if update is not True:
                             try:
                                 uprev = destrepo.lookup(update)