Patchwork [4,of,5,VFS] subrepo: inline reporelpath into abstractsubrepo._relpath to centralize logic

login
register
mail settings
Submitter Katsunori FUJIWARA
Date April 9, 2015, 3:51 p.m.
Message ID <01b48b1b6786c8fb5c2a.1428594677@juju>
Download mbox | patch
Permalink /patch/8578/
State Accepted
Commit 93b0e0db7929e17df19af592f4233c65de8c075a
Headers show

Comments

Katsunori FUJIWARA - April 9, 2015, 3:51 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1428593802 -32400
#      Fri Apr 10 00:36:42 2015 +0900
# Node ID 01b48b1b6786c8fb5c2a6b785a85aa413f552ba6
# Parent  f058247059f549cbeeaddc0f1891b41575c75d0c
subrepo: inline reporelpath into abstractsubrepo._relpath to centralize logic

"reporelpath()" is referred only from "abstractsubrepo._relpath()".

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -271,13 +271,6 @@  def _updateprompt(ui, sub, dirty, local,
                % (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
@@ -558,7 +551,13 @@  class abstractsubrepo(object):
     def _relpath(self):
         """return path to this subrepository as seen from outermost repository
         """
-        return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path)
+        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)
 
 class hgsubrepo(abstractsubrepo):
     def __init__(self, ctx, path, state):