comparison mercurial/hg.py @ 40324:6637b079ae45

lfs: autoload the extension when cloning from repo with lfs enabled This is based on a patch by Gregory Szorc. I made small adjustments to clean up the messaging when the server has the extension enabled, but the client has it disabled (to prevent autoloading). Additionally, I added a second server capability to distinguish between the server having the extension enabled, and the server having LFS commits. This helps prevent unnecessary requirement propagation- the client shouldn't add a requirement that the server doesn't have, just because the server had the extension loaded. The TODO I had about advertising a capability when the server can natively serve up blobs isn't relevant anymore (we've had 2 releases that support this), so I dropped it. Currently, we lazily add the "lfs" requirement to a repo when we first encounter LFS data. Due to a pretxnchangegroup hook that looks for LFS data, this can happen at the end of clone. Now that we have more control over how repositories are created, we can do better. This commit adds a repo creation option to add the "lfs" requirement. hg.clone() sets this creation option if the remote peer is advertising lfs usage (as opposed to just support needed to push). So, what this change effectively does is have cloned repos automatically inherit the "lfs" requirement. Differential Revision: https://phab.mercurial-scm.org/D5130
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 20 Sep 2018 17:27:01 -0700
parents d3d4b4b5f725
children ac59de55c8b4
comparison
equal deleted inserted replaced
40323:2c0aa02ecd5a 40324:6637b079ae45
575 # Include everything by default if only exclusion patterns defined. 575 # Include everything by default if only exclusion patterns defined.
576 if storeexcludepats and not storeincludepats: 576 if storeexcludepats and not storeincludepats:
577 storeincludepats = {'path:.'} 577 storeincludepats = {'path:.'}
578 578
579 createopts['narrowfiles'] = True 579 createopts['narrowfiles'] = True
580
581 if srcpeer.capable(b'lfs-serve'):
582 # Repository creation honors the config if it disabled the extension, so
583 # we can't just announce that lfs will be enabled. This check avoids
584 # saying that lfs will be enabled, and then saying it's an unknown
585 # feature. The lfs creation option is set in either case so that a
586 # requirement is added. If the extension is explicitly disabled but the
587 # requirement is set, the clone aborts early, before transferring any
588 # data.
589 createopts['lfs'] = True
590
591 if extensions.disabledext('lfs'):
592 ui.status(_('(remote is using large file support (lfs), but it is '
593 'explicitly disabled in the local configuration)\n'))
594 else:
595 ui.status(_('(remote is using large file support (lfs); lfs will '
596 'be enabled for this repository)\n'))
580 597
581 shareopts = shareopts or {} 598 shareopts = shareopts or {}
582 sharepool = shareopts.get('pool') 599 sharepool = shareopts.get('pool')
583 sharenamemode = shareopts.get('mode') 600 sharenamemode = shareopts.get('mode')
584 if sharepool and islocal(dest): 601 if sharepool and islocal(dest):