mercurial/bundlerepo.py
changeset 12734 5dfd1c49dcc5
parent 12347 6277a9469dff
child 12961 ad63e5f834e1
equal deleted inserted replaced
12733:098dfb2b7596 12734:5dfd1c49dcc5
    12 """
    12 """
    13 
    13 
    14 from node import nullid
    14 from node import nullid
    15 from i18n import _
    15 from i18n import _
    16 import os, struct, tempfile, shutil
    16 import os, struct, tempfile, shutil
    17 import changegroup, util, mdiff
    17 import changegroup, util, mdiff, discovery
    18 import localrepo, changelog, manifest, filelog, revlog, error
    18 import localrepo, changelog, manifest, filelog, revlog, error
    19 
    19 
    20 class bundlerevlog(revlog.revlog):
    20 class bundlerevlog(revlog.revlog):
    21     def __init__(self, opener, indexfile, bundle,
    21     def __init__(self, opener, indexfile, bundle,
    22                  linkmapper=None):
    22                  linkmapper=None):
   286         else:
   286         else:
   287             repopath, bundlename = s
   287             repopath, bundlename = s
   288     else:
   288     else:
   289         repopath, bundlename = parentpath, path
   289         repopath, bundlename = parentpath, path
   290     return bundlerepository(ui, repopath, bundlename)
   290     return bundlerepository(ui, repopath, bundlename)
       
   291 
       
   292 def getremotechanges(ui, repo, other, revs=None, bundlename=None, force=False):
       
   293     tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force)
       
   294     common, incoming, rheads = tmp
       
   295     if not incoming:
       
   296         try:
       
   297             os.unlink(bundlename)
       
   298         except:
       
   299             pass
       
   300         return other, None, None
       
   301 
       
   302     bundle = None
       
   303     if bundlename or not other.local():
       
   304         # create a bundle (uncompressed if other repo is not local)
       
   305 
       
   306         if revs is None and other.capable('changegroupsubset'):
       
   307             revs = rheads
       
   308 
       
   309         if revs is None:
       
   310             cg = other.changegroup(incoming, "incoming")
       
   311         else:
       
   312             cg = other.changegroupsubset(incoming, revs, 'incoming')
       
   313         bundletype = other.local() and "HG10BZ" or "HG10UN"
       
   314         fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
       
   315         # keep written bundle?
       
   316         if bundlename:
       
   317             bundle = None
       
   318         if not other.local():
       
   319             # use the created uncompressed bundlerepo
       
   320             other = bundlerepository(ui, repo.root, fname)
       
   321     return (other, incoming, bundle)
       
   322