[PATCH 1 of 1] clone: only use stream when we understand the revlog format

Sune Foldager cryo at cyanite.org
Mon Aug 30 11:21:40 CDT 2010


# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1283183902 -7200
# Node ID 4b312421249ac4829f1d480c3611b3d18c6f2000
# Parent  6f833fc3ccabd204173bee24ed725269d8475932
clone: only use stream when we understand the revlog format

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -21,7 +21,8 @@
 
 class localrepository(repo.repository):
     capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey'))
-    supported = set('revlogv1 store fncache shared parentdelta'.split())
+    localsupported = set(('store', 'fncache', 'shared'))
+    supported = set(('revlogv1', 'parentdelta')) | localsupported
 
     def __init__(self, baseui, path=None, create=0):
         repo.repository.__init__(self)
@@ -95,6 +96,8 @@
         self.sopener.options = {}
         if 'parentdelta' in requirements:
             self.sopener.options['parentdelta'] = 1
+        reqs = ','.join(r for r in requirements if r not in self.localsupported)
+        self.capabilities.add('requires=' + reqs)
 
         # These two define the set of tags for this repository.  _tags
         # maps tag name to node; _tagtypes maps tag name to 'global' or
@@ -1780,8 +1783,12 @@
         # and format flags on "stream" capability, and use
         # uncompressed only if compatible.
 
-        if stream and not heads and remote.capable('stream'):
-            return self.stream_in(remote)
+        if stream and not heads and remote.capable('stream2'):
+            reqs = remote.capable('requires')
+            if reqs:
+                reqs = set(reqs.split(','))
+                if not reqs - self.supported:
+                    return self.stream_in(remote)
         return self.pull(remote, heads)
 
     def pushkey(self, namespace, key, old, new):
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -172,8 +172,11 @@
 def capabilities(repo, proto):
     caps = 'lookup changegroupsubset branchmap pushkey'.split()
     if _allowstream(repo.ui):
-        caps.append('stream=%d' % repo.changelog.version)
+        caps.append('stream2')
     caps.append('unbundle=%s' % ','.join(changegroupmod.bundlepriority))
+    reqs = repo.capable('requires')
+    if reqs:
+        caps.append('requires=%s' % reqs)
     return ' '.join(caps)
 
 def changegroup(repo, proto, roots):


More information about the Mercurial-devel mailing list