##// END OF EJS Templates
lfs: enable the extension locally after cloning a repo with 'lfs' requirement...
Matt Harbison -
r35214:24aa4853 default
parent child Browse files
Show More
@@ -37,6 +37,7 b' from mercurial import ('
37 exchange,
37 exchange,
38 extensions,
38 extensions,
39 filelog,
39 filelog,
40 hg,
40 localrepo,
41 localrepo,
41 registrar,
42 registrar,
42 revlog,
43 revlog,
@@ -151,6 +152,8 b' def extsetup(ui):'
151 ),
152 ),
152 )
153 )
153
154
155 wrapfunction(hg, 'clone', wrapper.hgclone)
156
154 # Make bundle choose changegroup3 instead of changegroup2. This affects
157 # Make bundle choose changegroup3 instead of changegroup2. This affects
155 # "hg bundle" command. Note: it does not cover all bundle formats like
158 # "hg bundle" command. Note: it does not cover all bundle formats like
156 # "packed1". Using "packed1" with lfs will likely cause trouble.
159 # "packed1". Using "packed1" with lfs will likely cause trouble.
@@ -202,6 +202,25 b' def vfsinit(orig, self, othervfs):'
202 if util.safehasattr(othervfs, name):
202 if util.safehasattr(othervfs, name):
203 setattr(self, name, getattr(othervfs, name))
203 setattr(self, name, getattr(othervfs, name))
204
204
205 def hgclone(orig, ui, opts, *args, **kwargs):
206 result = orig(ui, opts, *args, **kwargs)
207
208 if result is not None:
209 sourcerepo, destrepo = result
210 repo = destrepo.local()
211
212 # When cloning to a remote repo (like through SSH), no repo is available
213 # from the peer. Therefore the hgrc can't be updated.
214 if not repo:
215 return result
216
217 # If lfs is required for this repo, permanently enable it locally
218 if 'lfs' in repo.requirements:
219 with repo.vfs('hgrc', 'a', text=True) as fp:
220 fp.write('\n[extensions]\nlfs=\n')
221
222 return result
223
205 def _canskipupload(repo):
224 def _canskipupload(repo):
206 # if remotestore is a null store, upload is a no-op and can be skipped
225 # if remotestore is a null store, upload is a no-op and can be skipped
207 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote)
226 return isinstance(repo.svfs.lfsremoteblobstore, blobstore._nullremote)
@@ -199,6 +199,8 b''
199 updating to branch default
199 updating to branch default
200 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
200 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
201 $ cd repo7
201 $ cd repo7
202 $ hg config extensions --debug | grep lfs
203 $TESTTMP/repo7/.hg/hgrc:*: extensions.lfs= (glob)
202 $ cat large
204 $ cat large
203 LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES
205 LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES
204 $ cat small
206 $ cat small
General Comments 0
You need to be logged in to leave comments. Login now