summaryrefslogtreecommitdiff
path: root/mercurial/bundlerepo.py
diff options
context:
space:
mode:
Diffstat (limited to 'mercurial/bundlerepo.py')
-rw-r--r--mercurial/bundlerepo.py56
1 files changed, 14 insertions, 42 deletions
diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
index fc78b7a..9769fcb 100644
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -14,7 +14,7 @@ were part of the actual repository.
from node import nullid
from i18n import _
import os, tempfile, shutil
-import changegroup, util, mdiff, discovery, cmdutil
+import changegroup, util, mdiff, discovery
import localrepo, changelog, manifest, filelog, revlog, error
class bundlerevlog(revlog.revlog):
@@ -54,7 +54,7 @@ class bundlerevlog(revlog.revlog):
continue
for p in (p1, p2):
- if p not in self.nodemap:
+ if not p in self.nodemap:
raise error.LookupError(p, self.indexfile,
_("unknown parent"))
# start, size, full unc. size, base (unused), link, p1, p2, node
@@ -95,23 +95,15 @@ class bundlerevlog(revlog.revlog):
return mdiff.textdiff(self.revision(self.node(rev1)),
self.revision(self.node(rev2)))
- def revision(self, nodeorrev):
- """return an uncompressed revision of a given node or revision
- number.
- """
- if isinstance(nodeorrev, int):
- rev = nodeorrev
- node = self.node(rev)
- else:
- node = nodeorrev
- rev = self.rev(node)
-
+ def revision(self, node):
+ """return an uncompressed revision of a given"""
if node == nullid:
return ""
text = None
chain = []
iter_node = node
+ rev = self.rev(iter_node)
# reconstruct the revision if it is from a changegroup
while self.inbundle(rev):
if self._cache and self._cache[0] == iter_node:
@@ -167,10 +159,6 @@ class bundlefilelog(bundlerevlog, filelog.filelog):
def _file(self, f):
self._repo.file(f)
-class bundlepeer(localrepo.localpeer):
- def canpush(self):
- return False
-
class bundlerepository(localrepo.localrepository):
def __init__(self, ui, path, bundlename):
self._tempparent = None
@@ -180,7 +168,6 @@ class bundlerepository(localrepo.localrepository):
self._tempparent = tempfile.mkdtemp()
localrepo.instance(ui, self._tempparent, 1)
localrepo.localrepository.__init__(self, ui, self._tempparent)
- self.ui.setconfig('phases', 'publish', False)
if path:
self._url = 'bundle:' + util.expandpath(path) + '+' + bundlename
@@ -276,25 +263,13 @@ class bundlerepository(localrepo.localrepository):
def cancopy(self):
return False
- def peer(self):
- return bundlepeer(self)
-
def getcwd(self):
return os.getcwd() # always outside the repo
- def _writebranchcache(self, branches, tip, tiprev):
- # don't overwrite the disk cache with bundle-augmented data
- pass
-
def instance(ui, path, create):
if create:
raise util.Abort(_('cannot create new bundle repository'))
parentpath = ui.config("bundle", "mainreporoot", "")
- if not parentpath:
- # try to find the correct path to the working directory repo
- parentpath = cmdutil.findrepo(os.getcwd())
- if parentpath is None:
- parentpath = ''
if parentpath:
# 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.
@@ -330,16 +305,13 @@ def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None,
Returns a tuple (local, csets, cleanupfn):
- "local" is a local repo from which to obtain the actual incoming
- changesets; it is a bundlerepo for the obtained bundle when the
- original "other" is remote.
+ "local" is a local repo from which to obtain the actual incoming changesets; it
+ is a bundlerepo for the obtained bundle when the original "other" is remote.
"csets" lists the incoming changeset node ids.
- "cleanupfn" must be called without arguments when you're done processing
- the changes; it closes both the original "other" and the one returned
- here.
+ "cleanupfn" must be called without arguments when you're done processing the
+ changes; it closes both the original "other" and the one returned here.
'''
- tmp = discovery.findcommonincoming(repo, other, heads=onlyheads,
- force=force)
+ tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force)
common, incoming, rheads = tmp
if not incoming:
try:
@@ -351,8 +323,8 @@ def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None,
bundle = None
bundlerepo = None
- localrepo = other.local()
- if bundlename or not localrepo:
+ localrepo = other
+ if bundlename or not other.local():
# create a bundle (uncompressed if other repo is not local)
if other.capable('getbundle'):
@@ -363,12 +335,12 @@ def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None,
rheads = None
else:
cg = other.changegroupsubset(incoming, rheads, 'incoming')
- bundletype = localrepo and "HG10BZ" or "HG10UN"
+ bundletype = other.local() and "HG10BZ" or "HG10UN"
fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
# keep written bundle?
if bundlename:
bundle = None
- if not localrepo:
+ if not other.local():
# use the created uncompressed bundlerepo
localrepo = bundlerepo = bundlerepository(ui, repo.root, fname)
# this repo contains local and other now, so filter out local again