Patchwork [2,of,2] lfs: move the 'supportedoutgoingversions' handling to changegroup.py

login
register
mail settings
Submitter Matt Harbison
Date March 27, 2018, 3:14 a.m.
Message ID <544761f9f8ee47e6b35b.1522120446@Envy>
Download mbox | patch
Permalink /patch/29895/
State Accepted
Headers show

Comments

Matt Harbison - March 27, 2018, 3:14 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1522119770 14400
#      Mon Mar 26 23:02:50 2018 -0400
# Node ID 544761f9f8ee47e6b35b2b3fad0b69914e10341d
# Parent  19b73408a618666979209b9654182e6fa72364d2
lfs: move the 'supportedoutgoingversions' handling to changegroup.py

This handling already exists here for the narrow extension.  We still need to
either figure out how to enable changegroup v3 without the extension, or figure
out how to let the server detect that the client doesn't have it loaded, and
emit a user friendly error[1].  I can't tell if D1944 is the appropriate vehicle
for the latter.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2018-January/109550.html
Yuya Nishihara - March 27, 2018, 12:07 p.m.
On Mon, 26 Mar 2018 23:14:06 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1522119770 14400
> #      Mon Mar 26 23:02:50 2018 -0400
> # Node ID 544761f9f8ee47e6b35b2b3fad0b69914e10341d
> # Parent  19b73408a618666979209b9654182e6fa72364d2
> lfs: move the 'supportedoutgoingversions' handling to changegroup.py

Queued this, thanks.

Patch

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -308,9 +308,6 @@  def extsetup(ui):
                  wrapper.upgraderequirements)
 
     wrapfunction(changegroup,
-                 'supportedoutgoingversions',
-                 wrapper.supportedoutgoingversions)
-    wrapfunction(changegroup,
                  'allsupportedversions',
                  wrapper.allsupportedversions)
 
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -30,14 +30,6 @@  from . import (
     pointer,
 )
 
-def supportedoutgoingversions(orig, repo):
-    versions = orig(repo)
-    if 'lfs' in repo.requirements:
-        versions.discard('01')
-        versions.discard('02')
-    versions.add('03')
-    return versions
-
 def allsupportedversions(orig, ui):
     versions = orig(ui)
     versions.add('03')
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -36,6 +36,8 @@  from .utils import (
 _CHANGEGROUPV2_DELTA_HEADER = "20s20s20s20s20s"
 _CHANGEGROUPV3_DELTA_HEADER = ">20s20s20s20s20sH"
 
+LFS_REQUIREMENT = 'lfs'
+
 # When narrowing is finalized and no longer subject to format changes,
 # we should move this to just "narrow" or similar.
 NARROW_REQUIREMENT = 'narrowhg-experimental'
@@ -912,6 +914,12 @@  def supportedoutgoingversions(repo):
         # support that for stripping and unbundling to work.
         versions.discard('01')
         versions.discard('02')
+    if LFS_REQUIREMENT in repo.requirements:
+        # Versions 01 and 02 don't support revlog flags, and we need to
+        # mark LFS entries with REVIDX_EXTSTORED.
+        versions.discard('01')
+        versions.discard('02')
+
     return versions
 
 def localversion(repo):