Mercurial > hg
changeset 24673:105758d1b37b
subrepo: add _relpath field to centralize subrelpath logic
This patch adds propertycache-ed "_relpath" field to
"abstractsubrepo", to centralize "subrelpath" logic into it.
Now, "subrelpath()" can always return "_relpath" field of the
specified subrepo object, because it is ensured that subrepo object
has it. To reduce changes in this patch, "subrelpath()" itself is
still kept, even though it seems to be redundant.
This is also a part of eliminating "os.path.*" API invocations for
"Windows UTF-8 Plan".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 10 Apr 2015 00:36:42 +0900 |
parents | dd0b86f740ef |
children | 93b0e0db7929 |
files | mercurial/subrepo.py |
diffstat | 1 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/subrepo.py Fri Apr 10 00:36:42 2015 +0900 +++ b/mercurial/subrepo.py Fri Apr 10 00:36:42 2015 +0900 @@ -280,11 +280,7 @@ def subrelpath(sub): """return path to this subrepo as seen from outermost repo""" - if util.safehasattr(sub, '_relpath'): - return sub._relpath - if not util.safehasattr(sub, '_repo'): - return sub._path - return reporelpath(sub._repo) + return sub._relpath def _abssource(repo, push=False, abort=True): """return pull/push path of repo - either based on parent repo .hgsub info @@ -558,6 +554,12 @@ """ return scmutil.vfs(self._ctx.repo().wvfs.join(self._path)) + @propertycache + def _relpath(self): + """return path to this subrepository as seen from outermost repository + """ + return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path) + class hgsubrepo(abstractsubrepo): def __init__(self, ctx, path, state): super(hgsubrepo, self).__init__(ctx, path) @@ -1188,7 +1190,6 @@ def __init__(self, ctx, path, state): super(gitsubrepo, self).__init__(ctx, path) self._state = state - self._relpath = os.path.join(reporelpath(ctx.repo()), path) self._abspath = ctx.repo().wjoin(path) self._subparent = ctx.repo() self._ensuregit()