mercurial/changegroup.py
branchstable
changeset 27953 88609cfa3745
parent 27946 ca8d2b73155d
child 28227 1c36cc8e7870
equal deleted inserted replaced
27952:c5ffbd4c033b 27953:88609cfa3745
   947              '02': (cg2packer, cg2unpacker),
   947              '02': (cg2packer, cg2unpacker),
   948              # cg3 adds support for exchanging revlog flags and treemanifests
   948              # cg3 adds support for exchanging revlog flags and treemanifests
   949              '03': (cg3packer, cg3unpacker),
   949              '03': (cg3packer, cg3unpacker),
   950 }
   950 }
   951 
   951 
   952 def supportedversions(repo):
   952 def allsupportedversions(ui):
   953     versions = set(_packermap.keys())
   953     versions = set(_packermap.keys())
   954     if ('treemanifest' in repo.requirements or
   954     versions.discard('03')
   955         repo.ui.configbool('experimental', 'treemanifest')):
   955     if (ui.configbool('experimental', 'changegroup3') or
       
   956         ui.configbool('experimental', 'treemanifest')):
       
   957         versions.add('03')
       
   958     return versions
       
   959 
       
   960 # Changegroup versions that can be applied to the repo
       
   961 def supportedincomingversions(repo):
       
   962     versions = allsupportedversions(repo.ui)
       
   963     if 'treemanifest' in repo.requirements:
       
   964         versions.add('03')
       
   965     return versions
       
   966 
       
   967 # Changegroup versions that can be created from the repo
       
   968 def supportedoutgoingversions(repo):
       
   969     versions = allsupportedversions(repo.ui)
       
   970     if 'treemanifest' in repo.requirements:
   956         # Versions 01 and 02 support only flat manifests and it's just too
   971         # Versions 01 and 02 support only flat manifests and it's just too
   957         # expensive to convert between the flat manifest and tree manifest on
   972         # expensive to convert between the flat manifest and tree manifest on
   958         # the fly. Since tree manifests are hashed differently, all of history
   973         # the fly. Since tree manifests are hashed differently, all of history
   959         # would have to be converted. Instead, we simply don't even pretend to
   974         # would have to be converted. Instead, we simply don't even pretend to
   960         # support versions 01 and 02.
   975         # support versions 01 and 02.
   961         versions.discard('01')
   976         versions.discard('01')
   962         versions.discard('02')
   977         versions.discard('02')
   963     elif not repo.ui.configbool('experimental', 'changegroup3'):
   978         versions.add('03')
   964         versions.discard('03')
       
   965     return versions
   979     return versions
   966 
   980 
   967 def safeversion(repo):
   981 def safeversion(repo):
   968     # Finds the smallest version that it's safe to assume clients of the repo
   982     # Finds the smallest version that it's safe to assume clients of the repo
   969     # will support. For example, all hg versions that support generaldelta also
   983     # will support. For example, all hg versions that support generaldelta also
   970     # support changegroup 02.
   984     # support changegroup 02.
   971     versions = supportedversions(repo)
   985     versions = supportedoutgoingversions(repo)
   972     if 'generaldelta' in repo.requirements:
   986     if 'generaldelta' in repo.requirements:
   973         versions.discard('01')
   987         versions.discard('01')
   974     assert versions
   988     assert versions
   975     return min(versions)
   989     return min(versions)
   976 
   990 
   977 def getbundler(version, repo, bundlecaps=None):
   991 def getbundler(version, repo, bundlecaps=None):
   978     assert version in supportedversions(repo)
   992     assert version in supportedoutgoingversions(repo)
   979     return _packermap[version][0](repo, bundlecaps)
   993     return _packermap[version][0](repo, bundlecaps)
   980 
   994 
   981 def getunbundler(version, fh, alg):
   995 def getunbundler(version, fh, alg):
   982     return _packermap[version][1](fh, alg)
   996     return _packermap[version][1](fh, alg)
   983 
   997