[PATCH 1 of 2] subrepo: hgsuberpo use local filesytem subrepo on push/pull when no source provided
alexraynepe196 at gmail.com
alexraynepe196 at gmail.com
Thu Sep 12 21:46:18 UTC 2024
# HG changeset patch
# User alexrayne
# Date 1726176902 -10800
# Fri Sep 13 00:35:02 2024 +0300
# Node ID a000ac71e41a56e3b1c7697f44e34683d0fd47bd
# Parent 3785814bc2b75c7785b6bf1a26f96ef5848b09dd
subrepo: hgsuberpo use local filesytem subrepo on push/pull when no source provided.
* when hgsub not provides source (a kind of mistake), occasionaly was used parent repo on push/pull.
This leads on accasinaly trash full subrepo contents into root-repo on push.
now for such issue use local subrepo path, instead of parent repo.
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -482,6 +482,10 @@
# internal config: ui._usedassubrepo
self.ui.setconfig(b'ui', b'_usedassubrepo', b'True', b'subrepo')
self._initrepo(r, state[0], create)
+ # provide relpath for subrepos
+ # this case push/pull try into local repo when no repo-source provided.
+ self._repo._relpath = self._relpath;
+
@annotatesubrepoerror
def addwebdirpath(self, serverpath, webconf):
diff --git a/mercurial/subrepoutil.py b/mercurial/subrepoutil.py
--- a/mercurial/subrepoutil.py
+++ b/mercurial/subrepoutil.py
@@ -456,7 +456,12 @@
"""return pull/push path of repo - either based on parent repo .hgsub info
or on the top repo config. Abort or return None if no source found."""
if hasattr(repo, '_subparent'):
- source = urlutil.url(repo._subsource)
+ source = repo._subsource
+ if not source:
+ if hasattr(repo, '_relpath'):
+ if urlutil.url(repo.root).islocal:
+ source = repo._relpath
+ source = urlutil.url(source)
if source.isabs():
return bytes(source)
source.path = posixpath.normpath(source.path)
More information about the Mercurial-devel
mailing list