Mercurial > hg
comparison hgext/lfs/wrapper.py @ 35213:24aa4853c031
lfs: enable the extension locally after cloning a repo with 'lfs' requirement
We do the same thing on clone for the largefiles extension, as a convenience.
Similar to largefiles, it's probably safer to only enable this extension on a
per repo basis because it is trivial to add an lfs file. And that gives the
repository some centralized VCS characteristics.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 16 Nov 2017 20:23:20 -0500 |
parents | f8f939a2926c |
children | a8c778b2a689 |
comparison
equal
deleted
inserted
replaced
35212:c7b45db8f317 | 35213:24aa4853c031 |
---|---|
199 # also copy lfs blobstores. note: this can run before reposetup, so lfs | 199 # also copy lfs blobstores. note: this can run before reposetup, so lfs |
200 # blobstore attributes are not always ready at this time. | 200 # blobstore attributes are not always ready at this time. |
201 for name in ['lfslocalblobstore', 'lfsremoteblobstore']: | 201 for name in ['lfslocalblobstore', 'lfsremoteblobstore']: |
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 | |
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 | |
204 | 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) |
208 | 227 |