Patchwork [1,of,2] subrepo: backout 93b0e0db7929 to restore reporelpath()

login
register
mail settings
Submitter Matt Harbison
Date April 15, 2015, 6:26 p.m.
Message ID <7f70e8f8239f813f5041.1429122379@waste.org>
Download mbox | patch
Permalink /patch/8682/
State Accepted
Headers show

Comments

Matt Harbison - April 15, 2015, 6:26 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1429111406 14400
#      Wed Apr 15 11:23:26 2015 -0400
# Node ID 7f70e8f8239f813f5041210ff6395fae53e01971
# Parent  c560d8c687916cb70a6d54c2c9ddcb5c9e457be2
subrepo: backout 93b0e0db7929 to restore reporelpath()

The path for hgsubrepo needs to be calculated slightly differently from other
subrepo types, but can reuse this.  See the next patch for details.
Matt Harbison - April 16, 2015, 12:27 a.m.
On Wed, 15 Apr 2015 14:26:19 -0400, Matt Harbison  
<matt_harbison@yahoo.com> wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1429111406 14400
> #      Wed Apr 15 11:23:26 2015 -0400
> # Node ID 7f70e8f8239f813f5041210ff6395fae53e01971
> # Parent  c560d8c687916cb70a6d54c2c9ddcb5c9e457be2
> subrepo: backout 93b0e0db7929 to restore reporelpath()

Not sure if mpm was testing anything in particular, but I got some evolve  
related errors when pushing this series 2 hours later.  (The series was  
accepted by pushgate though.)


$ ../hg push -r 24988::
pushing to http://selenic.com/repo/hg-push
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 1 files
remote:
remote: Welcome to Pushgate!
remote: http://mercurial.selenic.com/wiki/ContributingChanges
remote: ---
remote: 04/15 7f70 matt_harbison  subrepo: backout 93b0e0db7929 to restore
reporelpath()
remote: *** failed to import extension evolve
 from /home/oxymoron/mutable-history/hgext/evolve.py: 'module' object has no
attribute 'command'
remote: 04/15 5b69 matt_harbison  subrepo: calculate _relpath for hgsubrepo
based on self instead of parent
remote: *** failed to import extension evolve
 from /home/oxymoron/mutable-history/hgext/evolve.py: 'module' object has no
attribute 'command'
remote: this patch series consists of 2 patches.
remote:
remote: (optional) Subject: [PATCH 0 of 2]
remote: Cc:
remote:
remote: sending [PATCH 1 of 2] subrepo: backout 93b0e0db7929 to restore
reporelpath() ...
remote: sending [PATCH 2 of 2] subrepo: calculate _relpath for hgsubrepo
based on self instead of parent ...
remote: ---
remote:
remote: transaction abort!
remote: rollback completed
Matt Mackall - April 17, 2015, 5:01 p.m.
On Wed, 2015-04-15 at 20:27 -0400, Matt Harbison wrote:
> On Wed, 15 Apr 2015 14:26:19 -0400, Matt Harbison  
> <matt_harbison@yahoo.com> wrote:
> 
> > # HG changeset patch
> > # User Matt Harbison <matt_harbison@yahoo.com>
> > # Date 1429111406 14400
> > #      Wed Apr 15 11:23:26 2015 -0400
> > # Node ID 7f70e8f8239f813f5041210ff6395fae53e01971
> > # Parent  c560d8c687916cb70a6d54c2c9ddcb5c9e457be2
> > subrepo: backout 93b0e0db7929 to restore reporelpath()
> 
> Not sure if mpm was testing anything in particular, but I got some evolve  
> related errors when pushing this series 2 hours later.  (The series was  
> accepted by pushgate though.)

Thanks, I think I've tracked this down.

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -271,6 +271,13 @@ 
                % (subrelpath(sub), local, remote))
     return ui.promptchoice(msg, 0)
 
+def reporelpath(repo):
+    """return path to this (sub)repo as seen from outermost repo"""
+    parent = repo
+    while util.safehasattr(parent, '_subparent'):
+        parent = parent._subparent
+    return repo.root[len(pathutil.normasprefix(parent.root)):]
+
 def subrelpath(sub):
     """return path to this subrepo as seen from outermost repo"""
     return sub._relpath
@@ -551,13 +558,7 @@ 
     def _relpath(self):
         """return path to this subrepository as seen from outermost repository
         """
-        repo = self._ctx.repo()
-        parent = repo
-        while util.safehasattr(parent, '_subparent'):
-            parent = parent._subparent
-        reporelpath = repo.root[len(pathutil.normasprefix(parent.root)):]
-
-        return self.wvfs.reljoin(reporelpath, self._path)
+        return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path)
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):