changeset 40513:525dcf5c1d41

remotefilelog: remove some BC code related to streamclone Since remotefilelog is now moved to core and we have streamclone._walkstreamfiles() in core, we don't need to have the backward compatibility code. People with old mercurial version should use remotefilelog from hg-experimental repo as IMO remotefilelog will go under a good refactoring and old clients will break. # no-check-commit foo_bar function name Differential Revision: https://phab.mercurial-scm.org/D5189
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 24 Oct 2018 16:59:05 +0300
parents b35a096b9bff
children 6f0b6905ef6f
files hgext/remotefilelog/__init__.py
diffstat 1 files changed, 21 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotefilelog/__init__.py	Wed Oct 17 09:12:29 2018 -0400
+++ b/hgext/remotefilelog/__init__.py	Wed Oct 24 16:59:05 2018 +0300
@@ -121,6 +121,7 @@
     revset,
     scmutil,
     smartset,
+    streamclone,
     templatekw,
     util,
 )
@@ -142,13 +143,6 @@
 # ensures debug commands are registered
 hgdebugcommands.command
 
-try:
-    from mercurial import streamclone
-    streamclone._walkstreamfiles
-    hasstreamclone = True
-except Exception:
-    hasstreamclone = False
-
 cmdtable = {}
 command = registrar.command(cmdtable)
 
@@ -305,36 +299,28 @@
                 else:
                     return orig()
             extensions.wrapfunction(remote, 'stream_out', stream_out_shallow)
-        if hasstreamclone:
-            def stream_wrap(orig, op):
-                setup_streamout(op.repo, op.remote)
-                return orig(op)
-            extensions.wrapfunction(
-                streamclone, 'maybeperformlegacystreamclone', stream_wrap)
+        def stream_wrap(orig, op):
+            setup_streamout(op.repo, op.remote)
+            return orig(op)
+        extensions.wrapfunction(
+            streamclone, 'maybeperformlegacystreamclone', stream_wrap)
 
-            def canperformstreamclone(orig, pullop, bundle2=False):
-                # remotefilelog is currently incompatible with the
-                # bundle2 flavor of streamclones, so force us to use
-                # v1 instead.
-                if 'v2' in pullop.remotebundle2caps.get('stream', []):
-                    pullop.remotebundle2caps['stream'] = [
-                        c for c in pullop.remotebundle2caps['stream']
-                        if c != 'v2']
-                if bundle2:
-                    return False, None
-                supported, requirements = orig(pullop, bundle2=bundle2)
-                if requirements is not None:
-                    requirements.add(constants.SHALLOWREPO_REQUIREMENT)
-                return supported, requirements
-            extensions.wrapfunction(
-                streamclone, 'canperformstreamclone', canperformstreamclone)
-        else:
-            def stream_in_shallow(orig, repo, remote, requirements):
-                setup_streamout(repo, remote)
+        def canperformstreamclone(orig, pullop, bundle2=False):
+            # remotefilelog is currently incompatible with the
+            # bundle2 flavor of streamclones, so force us to use
+            # v1 instead.
+            if 'v2' in pullop.remotebundle2caps.get('stream', []):
+                pullop.remotebundle2caps['stream'] = [
+                    c for c in pullop.remotebundle2caps['stream']
+                    if c != 'v2']
+            if bundle2:
+                return False, None
+            supported, requirements = orig(pullop, bundle2=bundle2)
+            if requirements is not None:
                 requirements.add(constants.SHALLOWREPO_REQUIREMENT)
-                return orig(repo, remote, requirements)
-            extensions.wrapfunction(
-                localrepo.localrepository, 'stream_in', stream_in_shallow)
+            return supported, requirements
+        extensions.wrapfunction(
+            streamclone, 'canperformstreamclone', canperformstreamclone)
 
     try:
         orig(ui, repo, *args, **opts)