mercurial/subrepo.py
changeset 14963 c035f1c53e39
parent 14898 95ced9f5bf29
child 14999 f6a737357195
equal deleted inserted replaced
14962:1c917bc66ccc 14963:c035f1c53e39
   179     return ui.promptchoice(msg, (_('&Local'), _('&Remote')), 0)
   179     return ui.promptchoice(msg, (_('&Local'), _('&Remote')), 0)
   180 
   180 
   181 def reporelpath(repo):
   181 def reporelpath(repo):
   182     """return path to this (sub)repo as seen from outermost repo"""
   182     """return path to this (sub)repo as seen from outermost repo"""
   183     parent = repo
   183     parent = repo
   184     while hasattr(parent, '_subparent'):
   184     while util.safehasattr(parent, '_subparent'):
   185         parent = parent._subparent
   185         parent = parent._subparent
   186     return repo.root[len(parent.root)+1:]
   186     return repo.root[len(parent.root)+1:]
   187 
   187 
   188 def subrelpath(sub):
   188 def subrelpath(sub):
   189     """return path to this subrepo as seen from outermost repo"""
   189     """return path to this subrepo as seen from outermost repo"""
   190     if hasattr(sub, '_relpath'):
   190     if util.safehasattr(sub, '_relpath'):
   191         return sub._relpath
   191         return sub._relpath
   192     if not hasattr(sub, '_repo'):
   192     if not util.safehasattr(sub, '_repo'):
   193         return sub._path
   193         return sub._path
   194     return reporelpath(sub._repo)
   194     return reporelpath(sub._repo)
   195 
   195 
   196 def _abssource(repo, push=False, abort=True):
   196 def _abssource(repo, push=False, abort=True):
   197     """return pull/push path of repo - either based on parent repo .hgsub info
   197     """return pull/push path of repo - either based on parent repo .hgsub info
   198     or on the top repo config. Abort or return None if no source found."""
   198     or on the top repo config. Abort or return None if no source found."""
   199     if hasattr(repo, '_subparent'):
   199     if util.safehasattr(repo, '_subparent'):
   200         source = util.url(repo._subsource)
   200         source = util.url(repo._subsource)
   201         if source.isabs():
   201         if source.isabs():
   202             return str(source)
   202             return str(source)
   203         source.path = posixpath.normpath(source.path)
   203         source.path = posixpath.normpath(source.path)
   204         parent = _abssource(repo._subparent, push, abort=False)
   204         parent = _abssource(repo._subparent, push, abort=False)
   206             parent = util.url(parent)
   206             parent = util.url(parent)
   207             parent.path = posixpath.join(parent.path, source.path)
   207             parent.path = posixpath.join(parent.path, source.path)
   208             parent.path = posixpath.normpath(parent.path)
   208             parent.path = posixpath.normpath(parent.path)
   209             return str(parent)
   209             return str(parent)
   210     else: # recursion reached top repo
   210     else: # recursion reached top repo
   211         if hasattr(repo, '_subtoppath'):
   211         if util.safehasattr(repo, '_subtoppath'):
   212             return repo._subtoppath
   212             return repo._subtoppath
   213         if push and repo.ui.config('paths', 'default-push'):
   213         if push and repo.ui.config('paths', 'default-push'):
   214             return repo.ui.config('paths', 'default-push')
   214             return repo.ui.config('paths', 'default-push')
   215         if repo.ui.config('paths', 'default'):
   215         if repo.ui.config('paths', 'default'):
   216             return repo.ui.config('paths', 'default')
   216             return repo.ui.config('paths', 'default')