hgext/lfs/wrapper.py
changeset 35213 24aa4853c031
parent 35178 f8f939a2926c
child 35214 a8c778b2a689
--- a/hgext/lfs/wrapper.py	Sat Dec 02 16:29:49 2017 +0900
+++ b/hgext/lfs/wrapper.py	Thu Nov 16 20:23:20 2017 -0500
@@ -202,6 +202,25 @@
         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:
+            with repo.vfs('hgrc', 'a', text=True) as fp:
+                fp.write('\n[extensions]\nlfs=\n')
+
+    return result
+
 def _canskipupload(repo):
     # if remotestore is a null store, upload is a no-op and can be skipped
     return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote)