lfs: don't add extension to hgrc after clone or share (BC)
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 20 Sep 2018 15:18:13 -0700
changeset 39853 bcf72d7b1524
parent 39852 2c2fadbc9851
child 39854 823a580448d7
lfs: don't add extension to hgrc after clone or share (BC) Now that repository loading in core supports automatically loading the lfs extension when the "lfs" requirement is present, we no longer need to update the .hg/hgrc of newly-created repos to load the lfs extension! I'm marking this as BC because it is a change in behavior. But users should not notice unless they create an LFS repo with new Mercurial and then attempt to use it with an old versions that doesn't support automatic extension loading. Differential Revision: https://phab.mercurial-scm.org/D4712
hgext/lfs/__init__.py
hgext/lfs/wrapper.py
tests/test-lfs.t
--- a/hgext/lfs/__init__.py	Thu Sep 20 15:06:43 2018 -0700
+++ b/hgext/lfs/__init__.py	Thu Sep 20 15:18:13 2018 -0700
@@ -344,9 +344,6 @@
         ),
     )
 
-    wrapfunction(hg, 'clone', wrapper.hgclone)
-    wrapfunction(hg, 'postshare', wrapper.hgpostshare)
-
     scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles)
 
     # Make bundle choose changegroup3 instead of changegroup2. This affects
--- a/hgext/lfs/wrapper.py	Thu Sep 20 15:06:43 2018 -0700
+++ b/hgext/lfs/wrapper.py	Thu Sep 20 15:18:13 2018 -0700
@@ -228,32 +228,6 @@
         if util.safehasattr(othervfs, name):
             setattr(self, name, getattr(othervfs, name))
 
-def hgclone(orig, ui, opts, *args, **kwargs):
-    result = orig(ui, opts, *args, **kwargs)
-
-    if result is not None:
-        sourcerepo, destrepo = result
-        repo = destrepo.local()
-
-        # When cloning to a remote repo (like through SSH), no repo is available
-        # from the peer.  Therefore the hgrc can't be updated.
-        if not repo:
-            return result
-
-        # If lfs is required for this repo, permanently enable it locally
-        if 'lfs' in repo.requirements:
-            repo.vfs.append('hgrc',
-                            util.tonativeeol('\n[extensions]\nlfs=\n'))
-
-    return result
-
-def hgpostshare(orig, sourcerepo, destrepo, defaultpath=None):
-    orig(sourcerepo, destrepo, defaultpath=defaultpath)
-
-    # If lfs is required for this repo, permanently enable it locally
-    if 'lfs' in destrepo.requirements:
-        destrepo.vfs.append('hgrc', util.tonativeeol('\n[extensions]\nlfs=\n'))
-
 def _prefetchfiles(repo, revs, match):
     """Ensure that required LFS blobs are present, fetching them as a group if
     needed."""
--- a/tests/test-lfs.t	Thu Sep 20 15:06:43 2018 -0700
+++ b/tests/test-lfs.t	Thu Sep 20 15:18:13 2018 -0700
@@ -295,8 +295,6 @@
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ cd repo7
-  $ hg config extensions --debug | grep lfs
-  $TESTTMP/repo7/.hg/hgrc:*: extensions.lfs= (glob)
   $ cat large
   LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES
   $ cat small
@@ -307,8 +305,8 @@
   $ hg --config extensions.share= share repo7 sharedrepo
   updating working directory
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ hg -R sharedrepo config extensions --debug | grep lfs
-  $TESTTMP/sharedrepo/.hg/hgrc:*: extensions.lfs= (glob)
+  $ grep lfs sharedrepo/.hg/requires
+  lfs
 
 # Test rename and status