Mercurial > hg
diff hgext/lfs/__init__.py @ 43076:2372284d9457
formatting: blacken the codebase
This is using my patch to black
(https://github.com/psf/black/pull/826) so we don't un-wrap collection
literals.
Done with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S
# skip-blame mass-reformatting only
# no-check-commit reformats foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D6971
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 06 Oct 2019 09:45:02 -0400 |
parents | 268662aac075 |
children | 687b865b95ad |
line wrap: on
line diff
--- a/hgext/lfs/__init__.py Sat Oct 05 10:29:34 2019 -0400 +++ b/hgext/lfs/__init__.py Sun Oct 06 09:45:02 2019 -0400 @@ -147,9 +147,7 @@ util, ) -from mercurial.interfaces import ( - repository, -) +from mercurial.interfaces import repository from . import ( blobstore, @@ -175,34 +173,34 @@ reposetup = eh.finalreposetup templatekeyword = eh.templatekeyword -eh.configitem('experimental', 'lfs.serve', - default=True, +eh.configitem( + 'experimental', 'lfs.serve', default=True, ) -eh.configitem('experimental', 'lfs.user-agent', - default=None, +eh.configitem( + 'experimental', 'lfs.user-agent', default=None, ) -eh.configitem('experimental', 'lfs.disableusercache', - default=False, +eh.configitem( + 'experimental', 'lfs.disableusercache', default=False, ) -eh.configitem('experimental', 'lfs.worker-enable', - default=False, +eh.configitem( + 'experimental', 'lfs.worker-enable', default=False, ) -eh.configitem('lfs', 'url', - default=None, +eh.configitem( + 'lfs', 'url', default=None, ) -eh.configitem('lfs', 'usercache', - default=None, +eh.configitem( + 'lfs', 'usercache', default=None, ) # Deprecated -eh.configitem('lfs', 'threshold', - default=None, +eh.configitem( + 'lfs', 'threshold', default=None, ) -eh.configitem('lfs', 'track', - default='none()', +eh.configitem( + 'lfs', 'track', default='none()', ) -eh.configitem('lfs', 'retry', - default=5, +eh.configitem( + 'lfs', 'retry', default=5, ) lfsprocessor = ( @@ -211,14 +209,17 @@ wrapper.bypasscheckhash, ) + def featuresetup(ui, supported): # don't die on seeing a repo with the lfs requirement supported |= {'lfs'} + @eh.uisetup def _uisetup(ui): localrepo.featuresetupfuncs.add(featuresetup) + @eh.reposetup def _reposetup(ui, repo): # Nothing to do with a remote repo @@ -237,6 +238,7 @@ repo.__class__ = lfsrepo if 'lfs' not in repo.requirements: + def checkrequireslfs(ui, repo, **kwargs): if 'lfs' in repo.requirements: return 0 @@ -250,8 +252,9 @@ match = repo._storenarrowmatch for ctx in s: # TODO: is there a way to just walk the files in the commit? - if any(ctx[f].islfs() for f in ctx.files() - if f in ctx and match(f)): + if any( + ctx[f].islfs() for f in ctx.files() if f in ctx and match(f) + ): repo.requirements.add('lfs') repo.features.add(repository.REPO_FEATURE_LFS) repo._writerequirements() @@ -263,6 +266,7 @@ else: repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) + def _trackedmatcher(repo): """Return a function (path, size) -> bool indicating whether or not to track a given file with lfs.""" @@ -288,8 +292,10 @@ cfg.parse('.hglfs', data) try: - rules = [(minifileset.compile(pattern), minifileset.compile(rule)) - for pattern, rule in cfg.items('track')] + rules = [ + (minifileset.compile(pattern), minifileset.compile(rule)) + for pattern, rule in cfg.items('track') + ] except error.ParseError as e: # The original exception gives no indicator that the error is in the # .hglfs file, so add that. @@ -306,6 +312,7 @@ return _match + # Called by remotefilelog def wrapfilelog(filelog): wrapfunction = extensions.wrapfunction @@ -314,14 +321,17 @@ wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) wrapfunction(filelog, 'size', wrapper.filelogsize) + @eh.wrapfunction(localrepo, 'resolverevlogstorevfsoptions') def _resolverevlogstorevfsoptions(orig, ui, requirements, features): opts = orig(ui, requirements, features) for name, module in extensions.extensions(ui): if module is sys.modules[__name__]: if revlog.REVIDX_EXTSTORED in opts[b'flagprocessors']: - msg = (_(b"cannot register multiple processors on flag '%#x'.") - % revlog.REVIDX_EXTSTORED) + msg = ( + _(b"cannot register multiple processors on flag '%#x'.") + % revlog.REVIDX_EXTSTORED + ) raise error.Abort(msg) opts[b'flagprocessors'][revlog.REVIDX_EXTSTORED] = lfsprocessor @@ -329,6 +339,7 @@ return opts + @eh.extsetup def _extsetup(ui): wrapfilelog(filelog.filelog) @@ -342,23 +353,27 @@ # "packed1". Using "packed1" with lfs will likely cause trouble. exchange._bundlespeccontentopts["v2"]["cg.version"] = "03" + @eh.filesetpredicate('lfs()') def lfsfileset(mctx, x): """File that uses LFS storage.""" # i18n: "lfs" is a keyword filesetlang.getargs(x, 0, 0, _("lfs takes no arguments")) ctx = mctx.ctx + def lfsfilep(f): return wrapper.pointerfromctx(ctx, f, removed=True) is not None + return mctx.predicate(lfsfilep, predrepr='<lfs>') + @eh.templatekeyword('lfs_files', requires={'ctx'}) def lfsfiles(context, mapping): """List of strings. All files modified, added, or removed by this changeset.""" ctx = context.resource(mapping, 'ctx') - pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer} + pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer} files = sorted(pointers.keys()) def pointer(v): @@ -377,8 +392,11 @@ f = templateutil._showcompatlist(context, mapping, 'lfs_file', files) return templateutil.hybrid(f, files, makemap, pycompat.identity) -@eh.command('debuglfsupload', - [('r', 'rev', [], _('upload large files introduced by REV'))]) + +@eh.command( + 'debuglfsupload', + [('r', 'rev', [], _('upload large files introduced by REV'))], +) def debuglfsupload(ui, repo, **opts): """upload lfs blobs added by the working copy parent or given revisions""" revs = opts.get(r'rev', [])