Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 24674:93b0e0db7929
subrepo: inline reporelpath into abstractsubrepo._relpath to centralize logic
"reporelpath()" is referred only from "abstractsubrepo._relpath()".
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 10 Apr 2015 00:36:42 +0900 |
parents | 105758d1b37b |
children | 47e7d5fbbf04 |
comparison
equal
deleted
inserted
replaced
24673:105758d1b37b | 24674:93b0e0db7929 |
---|---|
269 'use (l)ocal source (%s) or (r)emote source (%s)?' | 269 'use (l)ocal source (%s) or (r)emote source (%s)?' |
270 '$$ &Local $$ &Remote') | 270 '$$ &Local $$ &Remote') |
271 % (subrelpath(sub), local, remote)) | 271 % (subrelpath(sub), local, remote)) |
272 return ui.promptchoice(msg, 0) | 272 return ui.promptchoice(msg, 0) |
273 | 273 |
274 def reporelpath(repo): | |
275 """return path to this (sub)repo as seen from outermost repo""" | |
276 parent = repo | |
277 while util.safehasattr(parent, '_subparent'): | |
278 parent = parent._subparent | |
279 return repo.root[len(pathutil.normasprefix(parent.root)):] | |
280 | |
281 def subrelpath(sub): | 274 def subrelpath(sub): |
282 """return path to this subrepo as seen from outermost repo""" | 275 """return path to this subrepo as seen from outermost repo""" |
283 return sub._relpath | 276 return sub._relpath |
284 | 277 |
285 def _abssource(repo, push=False, abort=True): | 278 def _abssource(repo, push=False, abort=True): |
556 | 549 |
557 @propertycache | 550 @propertycache |
558 def _relpath(self): | 551 def _relpath(self): |
559 """return path to this subrepository as seen from outermost repository | 552 """return path to this subrepository as seen from outermost repository |
560 """ | 553 """ |
561 return self.wvfs.reljoin(reporelpath(self._ctx.repo()), self._path) | 554 repo = self._ctx.repo() |
555 parent = repo | |
556 while util.safehasattr(parent, '_subparent'): | |
557 parent = parent._subparent | |
558 reporelpath = repo.root[len(pathutil.normasprefix(parent.root)):] | |
559 | |
560 return self.wvfs.reljoin(reporelpath, self._path) | |
562 | 561 |
563 class hgsubrepo(abstractsubrepo): | 562 class hgsubrepo(abstractsubrepo): |
564 def __init__(self, ctx, path, state): | 563 def __init__(self, ctx, path, state): |
565 super(hgsubrepo, self).__init__(ctx, path) | 564 super(hgsubrepo, self).__init__(ctx, path) |
566 self._state = state | 565 self._state = state |