[Request] [+- ] D10390: outgoing: pass subrepo path using function argument instead of abssource hack
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Apr 14 00:37:36 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This is clearer, remove the needs for the `repo._subtoppath` hack and will make
our live easier when making `outgoing` accept multiple destinations.
We needed a new function to compute the appropriate "relative" location.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10390
AFFECTED FILES
mercurial/commands.py
mercurial/hg.py
mercurial/subrepo.py
mercurial/subrepoutil.py
CHANGE DETAILS
diff --git a/mercurial/subrepoutil.py b/mercurial/subrepoutil.py
--- a/mercurial/subrepoutil.py
+++ b/mercurial/subrepoutil.py
@@ -383,6 +383,24 @@
return subs, commitsubs, newstate
+def repo_rel_or_abs_source(repo):
+ """return the source of this repo
+
+ Either absolute or relative the outermost repo"""
+ parent = repo
+ chunks = []
+ while util.safehasattr(parent, b'_subparent'):
+ source = urlutil.url(parent._subsource)
+ chunks.append(bytes(source))
+ if source.isabs():
+ break
+ parent = parent._subparent
+
+ chunks.reverse()
+ path = posixpath.join(*chunks)
+ return posixpath.normpath(path)
+
+
def reporelpath(repo):
# type: (localrepo.localrepository) -> bytes
"""return path to this (sub)repo as seen from outermost repo"""
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -873,7 +873,8 @@
opts = copy.copy(opts)
opts.pop(b'rev', None)
opts.pop(b'branch', None)
- return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts)
+ subpath = subrepoutil.repo_rel_or_abs_source(self._repo)
+ return hg.outgoing(ui, self._repo, dest, opts, subpath=subpath)
@annotatesubrepoerror
def incoming(self, ui, source, opts):
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -1320,7 +1320,7 @@
return _incoming(display, subreporecurse, ui, repo, source, opts)
-def _outgoing(ui, repo, dest, opts):
+def _outgoing(ui, repo, dest, opts, subpath=None):
path = ui.getpath(dest, default=(b'default-push', b'default'))
if not path:
raise error.Abort(
@@ -1328,6 +1328,15 @@
hint=_(b"see 'hg help config.paths'"),
)
dest = path.pushloc or path.loc
+ if subpath is not None:
+ subpath = urlutil.url(subpath)
+ if subpath.isabs():
+ dest = bytes(subpath)
+ else:
+ p = urlutil.url(dest)
+ p.path = os.path.normpath(b'%s/%s' % (p.path, subpath))
+ dest = bytes(p)
+
branches = path.branch, opts.get(b'branch') or []
ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(dest))
@@ -1382,10 +1391,10 @@
yield n
-def outgoing(ui, repo, dest, opts):
+def outgoing(ui, repo, dest, opts, subpath=None):
if opts.get(b'graph'):
logcmdutil.checkunsupportedgraphflags([], opts)
- o, other = _outgoing(ui, repo, dest, opts)
+ o, other = _outgoing(ui, repo, dest, opts, subpath=subpath)
ret = 1
try:
if o:
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4984,11 +4984,7 @@
finally:
other.close()
- repo._subtoppath = path.pushloc or path.loc
- try:
- return hg.outgoing(ui, repo, dest, opts)
- finally:
- del repo._subtoppath
+ return hg.outgoing(ui, repo, dest, opts)
@command(
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210414/d0a23839/attachment-0001.html>
More information about the Mercurial-patches
mailing list