largefiles: set the extension as enabled locally after a share requiring it
authorMatt Harbison <matt_harbison@yahoo.com>
Tue, 11 Apr 2017 20:54:50 -0400
changeset 31892 9e67ce5c4fd0
parent 31891 87f293edabb6
child 31893 165428b05fca
largefiles: set the extension as enabled locally after a share requiring it This has been done for clone since e1dbe0b215ae, so it makes sense here for the same reasons.
hgext/largefiles/overrides.py
hgext/largefiles/uisetup.py
tests/test-largefiles-misc.t
tests/test-share.t
--- a/hgext/largefiles/overrides.py	Tue Apr 11 21:38:11 2017 -0400
+++ b/hgext/largefiles/overrides.py	Tue Apr 11 20:54:50 2017 -0400
@@ -903,6 +903,14 @@
 
     return result
 
+def hgpostshare(orig, sourcerepo, destrepo, bookmarks=True, defaultpath=None):
+    orig(sourcerepo, destrepo, bookmarks, defaultpath)
+
+    # If largefiles is required for this repo, permanently enable it locally
+    if 'largefiles' in destrepo.requirements:
+        with destrepo.vfs('hgrc', 'a+', text=True) as fp:
+            fp.write('\n[extensions]\nlargefiles=\n')
+
 def overriderebase(orig, ui, repo, **opts):
     if not util.safehasattr(repo, '_largefilesenabled'):
         return orig(ui, repo, **opts)
--- a/hgext/largefiles/uisetup.py	Tue Apr 11 21:38:11 2017 -0400
+++ b/hgext/largefiles/uisetup.py	Tue Apr 11 20:54:50 2017 -0400
@@ -120,6 +120,7 @@
                  _('download all versions of all largefiles'))]
     entry[1].extend(cloneopt)
     entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
+    entry = extensions.wrapfunction(hg, 'postshare', overrides.hgpostshare)
 
     entry = extensions.wrapcommand(commands.table, 'cat',
                                    overrides.overridecat)
--- a/tests/test-largefiles-misc.t	Tue Apr 11 21:38:11 2017 -0400
+++ b/tests/test-largefiles-misc.t	Tue Apr 11 20:54:50 2017 -0400
@@ -212,6 +212,18 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add files
   
+sharing a largefile repo automatically enables largefiles on the share
+
+  $ hg share --config extensions.share= . ../shared_lfrepo
+  updating working directory
+  getting changed largefiles
+  1 largefiles updated, 0 removed
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cat ../shared_lfrepo/.hg/hgrc
+  
+  [extensions]
+  largefiles=
+
 verify that large files in subrepos handled properly
   $ hg init subrepo
   $ echo "subrepo = subrepo" > .hgsub
--- a/tests/test-share.t	Tue Apr 11 21:38:11 2017 -0400
+++ b/tests/test-share.t	Tue Apr 11 20:54:50 2017 -0400
@@ -240,6 +240,14 @@
      bm3                       4:62f4ded848e4
   $ cd ..
 
+non largefiles repos won't enable largefiles
+
+  $ hg share --config extensions.largefiles= repo3 sharedrepo
+  updating working directory
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ [ -f sharedrepo/.hg/hgrc ]
+  [1]
+
 test pushing bookmarks works
 
   $ hg clone repo3 repo4