Patchwork D3047: push: avoid using repo.lookup() for converting to nodeid

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

Comments

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

REVISION SUMMARY
  repo.lookup(x) currently simply does repo[x].node(), which supports
  various types of inputs. As I explained in https://phab.mercurial-scm.org/rHG0194dac77c93912e3073466c440f4f175fc93bc0 (scmutil: add
  method for looking up a context given a revision symbol, 2018-04-02),
  I'd like to split that up so we use the new scmutil.revsymbol() for
  string inputs repo[x] for integer revnums and binary nodeids. Since
  repo.lookup() seems to exist in order to serve peer.lookup(), I think
  it should be calling revsymbol. However, we have several callers that
  use repo.lookup() with something that's not a string, so we need to
  remove those first. This patch starts doing that. Many more will
  follow.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - April 3, 2018, 11:11 p.m.
indygreg added a comment.


  I'll likely take this series. But part of me wonders if we should be performing conversion on the changelog instead. I guess it depends on whether the string inputs should resolve names and other things not known to the changelog itself. For converting integer revision numbers to nodes, I would argue we should go through the changelog.
  
  Anyway, we'll likely have a bikeshed about all of this once we establish a formal interface for the changelog. That's a bit of a ways off, however. These changes seem fine for today.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, indygreg
Cc: mercurial-devel
phabricator - April 3, 2018, 11:13 p.m.
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D3047#49274, @indygreg wrote:
  
  > I'll likely take this series. But part of me wonders if we should be performing conversion on the changelog instead. I guess it depends on whether the string inputs should resolve names and other things not known to the changelog itself. For converting integer revision numbers to nodes, I would argue we should go through the changelog.
  >
  > Anyway, we'll likely have a bikeshed about all of this once we establish a formal interface for the changelog. That's a bit of a ways off, however. These changes seem fine for today.
  
  
  Sure, we can talk about that later :) I think I'm at least moving us closer to that by moving out the handling of user-supplied strings.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4148,7 +4148,7 @@ 
     other = hg.peer(repo, opts, dest)
 
     if revs:
-        revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
+        revs = [repo[r].node() for r in scmutil.revrange(repo, revs)]
         if not revs:
             raise error.Abort(_("specified revisions evaluate to an empty set"),
                              hint=_("use different revision arguments"))