[PATCH 2 of 3] Fix income/pull with bundle and -R. Adds an additional "mainrepo" parameter to
Peter Arrenbrecht
peter.arrenbrecht at gmail.com
Fri Nov 30 12:16:15 UTC 2007
# HG changeset patch
# User Peter Arrenbrecht <peter.arrenbrecht at gmail.com>
# Date 1194075690 -3600
# Node ID c5d7088145d04baf2235a004d729a7fa7ac0e6ad
# Parent e2b6327fd09c361b38d603614ed473dc7d9fff83
Fix income/pull with bundle and -R. Adds an additional "mainrepo" parameter to
hg.repository() and *repo.instance(), which is the repository hg is running in. This
is used to properly initialize the parent repository of a bundle repository
(particularly when -R is in effect).
Fixes http://www.selenic.com/mercurial/bts/issue820.
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -253,17 +253,30 @@ class bundlerepository(localrepo.localre
if tempfile is not None:
os.unlink(tempfile)
-def instance(ui, path, create):
+def instance(ui, path, create, mainrepo=None):
if create:
raise util.Abort(_('cannot create new bundle repository'))
+ if mainrepo:
+ parentpath = mainrepo.root
+ # Try to make the full path relative so we get a nice, short URL.
+ # In particular, we don't want temp dir names in test outputs.
+ cwd = os.getcwd()
+ if parentpath == cwd:
+ parentpath = ''
+ else:
+ cwd = os.path.join(cwd,'')
+ if parentpath.startswith(cwd):
+ parentpath = parentpath[len(cwd):]
+ else:
+ parentpath = ''
path = util.drop_scheme('file', path)
if path.startswith('bundle:'):
path = util.drop_scheme('bundle', path)
s = path.split("+", 1)
if len(s) == 1:
- repopath, bundlename = "", s[0]
+ repopath, bundlename = parentpath, s[0]
else:
repopath, bundlename = s
else:
- repopath, bundlename = '', path
+ repopath, bundlename = parentpath, path
return bundlerepository(ui, repopath, bundlename)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -898,7 +898,7 @@ def debuginstall(ui):
ui.write(_(" (Current patch tool may be incompatible with patch,"
" or misconfigured. Please check your .hgrc file)\n"))
else:
- ui.write(_(" Internal patcher failure, please report this error"
+ ui.write(_(" Internal patcher failure, please report this error"
" to http://www.selenic.com/mercurial/bts\n"))
problems += patchproblems
@@ -1484,7 +1484,7 @@ def identify(ui, repo, source=None,
if source:
source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
- srepo = hg.repository(ui, source)
+ srepo = hg.repository(ui, source, mainrepo=repo)
if not rev and revs:
rev = revs[0]
if not rev:
@@ -1651,7 +1651,7 @@ def incoming(ui, repo, source="default",
source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev'])
cmdutil.setremoteconfig(ui, opts)
- other = hg.repository(ui, source)
+ other = hg.repository(ui, source, mainrepo=repo)
ui.status(_('comparing with %s\n') % util.hidepassword(source))
if revs:
revs = [other.lookup(rev) for rev in revs]
@@ -1885,7 +1885,7 @@ def manifest(ui, repo, node=None, rev=No
The manifest is the list of files being version controlled. If no revision
is given then the first parent of the working directory is used.
- With -v flag, print file permissions, symlink and executable bits. With
+ With -v flag, print file permissions, symlink and executable bits. With
--debug flag, print file revision hashes.
"""
@@ -1961,7 +1961,7 @@ def outgoing(ui, repo, dest=None, **opts
if revs:
revs = [repo.lookup(rev) for rev in revs]
- other = hg.repository(ui, dest)
+ other = hg.repository(ui, dest, mainrepo=repo) # mainrepo is untested; cannot outgoing from bundle
ui.status(_('comparing with %s\n') % util.hidepassword(dest))
o = repo.findoutgoing(other, force=opts['force'])
if not o:
@@ -2094,7 +2094,7 @@ def pull(ui, repo, source="default", **o
source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev'])
cmdutil.setremoteconfig(ui, opts)
- other = hg.repository(ui, source)
+ other = hg.repository(ui, source, mainrepo=repo)
ui.status(_('pulling from %s\n') % util.hidepassword(source))
if revs:
try:
@@ -2141,7 +2141,7 @@ def push(ui, repo, dest=None, **opts):
ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
cmdutil.setremoteconfig(ui, opts)
- other = hg.repository(ui, dest)
+ other = hg.repository(ui, dest, mainrepo=repo) # mainrepo is untested; cannot push to bundle
ui.status('pushing to %s\n' % util.hidepassword(dest))
if revs:
revs = [repo.lookup(rev) for rev in revs]
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -57,9 +57,9 @@ def islocal(repo):
return False
return repo.local()
-def repository(ui, path='', create=False):
+def repository(ui, path='', create=False, mainrepo=None):
"""return a repository object for the specified path"""
- repo = _lookup(path).instance(ui, path, create)
+ repo = _lookup(path).instance(ui, path, create, mainrepo)
ui = getattr(repo, "ui", ui)
for name, module in extensions.extensions():
hook = getattr(module, 'reposetup', None)
diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -454,7 +454,7 @@ class httpsrepository(httprepository):
'is not installed'))
httprepository.__init__(self, ui, path)
-def instance(ui, path, create):
+def instance(ui, path, create, mainrepo=None):
if create:
raise util.Abort(_('cannot create new http repository'))
if path.startswith('https:'):
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1989,7 +1989,7 @@ def aftertrans(files):
util.rename(src, dest)
return a
-def instance(ui, path, create):
+def instance(ui, path, create, mainrepo=None):
return localrepository(ui, util.drop_scheme('file', path), create)
def islocal(path):
diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py
--- a/mercurial/sshrepo.py
+++ b/mercurial/sshrepo.py
@@ -225,4 +225,6 @@ class sshrepository(remoterepository):
def stream_out(self):
return self.do_cmd('stream_out')
-instance = sshrepository
+def instance(ui, path, create, mainrepo=None):
+ return sshrepository(ui, path, create)
+
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -72,7 +72,7 @@ class statichttprepository(localrepo.loc
def local(self):
return False
-def instance(ui, path, create):
+def instance(ui, path, create, mainrepo=None):
if create:
raise util.Abort(_('cannot create new static-http repository'))
return statichttprepository(ui, path[7:])
More information about the Mercurial-devel
mailing list