From patchwork Thu Apr 9 15:51:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 5, VFS] subrepo: inline reporelpath into abstractsubrepo._relpath to centralize logic From: Katsunori FUJIWARA X-Patchwork-Id: 8578 Message-Id: <01b48b1b6786c8fb5c2a.1428594677@juju> To: mercurial-devel@selenic.com Date: Fri, 10 Apr 2015 00:51:17 +0900 # HG changeset patch # User FUJIWARA Katsunori # 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()". 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):