equal
deleted
inserted
replaced
382 """return the source of this repo |
382 """return the source of this repo |
383 |
383 |
384 Either absolute or relative the outermost repo""" |
384 Either absolute or relative the outermost repo""" |
385 parent = repo |
385 parent = repo |
386 chunks = [] |
386 chunks = [] |
387 while util.safehasattr(parent, '_subparent'): |
387 while hasattr(parent, '_subparent'): |
388 source = urlutil.url(parent._subsource) |
388 source = urlutil.url(parent._subsource) |
389 chunks.append(bytes(source)) |
389 chunks.append(bytes(source)) |
390 if source.isabs(): |
390 if source.isabs(): |
391 break |
391 break |
392 parent = parent._subparent |
392 parent = parent._subparent |
398 |
398 |
399 def reporelpath(repo): |
399 def reporelpath(repo): |
400 # type: (localrepo.localrepository) -> bytes |
400 # type: (localrepo.localrepository) -> bytes |
401 """return path to this (sub)repo as seen from outermost repo""" |
401 """return path to this (sub)repo as seen from outermost repo""" |
402 parent = repo |
402 parent = repo |
403 while util.safehasattr(parent, '_subparent'): |
403 while hasattr(parent, '_subparent'): |
404 parent = parent._subparent |
404 parent = parent._subparent |
405 return repo.root[len(pathutil.normasprefix(parent.root)) :] |
405 return repo.root[len(pathutil.normasprefix(parent.root)) :] |
406 |
406 |
407 |
407 |
408 def subrelpath(sub): |
408 def subrelpath(sub): |
413 |
413 |
414 def _abssource(repo, push=False, abort=True): |
414 def _abssource(repo, push=False, abort=True): |
415 # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] |
415 # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] |
416 """return pull/push path of repo - either based on parent repo .hgsub info |
416 """return pull/push path of repo - either based on parent repo .hgsub info |
417 or on the top repo config. Abort or return None if no source found.""" |
417 or on the top repo config. Abort or return None if no source found.""" |
418 if util.safehasattr(repo, '_subparent'): |
418 if hasattr(repo, '_subparent'): |
419 source = urlutil.url(repo._subsource) |
419 source = urlutil.url(repo._subsource) |
420 if source.isabs(): |
420 if source.isabs(): |
421 return bytes(source) |
421 return bytes(source) |
422 source.path = posixpath.normpath(source.path) |
422 source.path = posixpath.normpath(source.path) |
423 parent = _abssource(repo._subparent, push, abort=False) |
423 parent = _abssource(repo._subparent, push, abort=False) |
426 parent.path = posixpath.join(parent.path or b'', source.path) |
426 parent.path = posixpath.join(parent.path or b'', source.path) |
427 parent.path = posixpath.normpath(parent.path) |
427 parent.path = posixpath.normpath(parent.path) |
428 return bytes(parent) |
428 return bytes(parent) |
429 else: # recursion reached top repo |
429 else: # recursion reached top repo |
430 path = None |
430 path = None |
431 if util.safehasattr(repo, '_subtoppath'): |
431 if hasattr(repo, '_subtoppath'): |
432 path = repo._subtoppath |
432 path = repo._subtoppath |
433 elif push and repo.ui.config(b'paths', b'default-push'): |
433 elif push and repo.ui.config(b'paths', b'default-push'): |
434 path = repo.ui.config(b'paths', b'default-push') |
434 path = repo.ui.config(b'paths', b'default-push') |
435 elif repo.ui.config(b'paths', b'default'): |
435 elif repo.ui.config(b'paths', b'default'): |
436 path = repo.ui.config(b'paths', b'default') |
436 path = repo.ui.config(b'paths', b'default') |