##// END OF EJS Templates
tests: avoid implicit bytes -> unicode -> bytes roundtrip on Python 2...
tests: avoid implicit bytes -> unicode -> bytes roundtrip on Python 2 Before the change, there were two implicit conversions: * The format string was converted to unicode because the substituted values were unicode. * When printing the message in log(), the string was converted from unicode to str.

File last commit:

r44747:87167caa default
r44958:408a4eb4 default
Show More
__init__.py
426 lines | 14.1 KiB | text/x-python | PythonLexer
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 # lfs - hash-preserving large file support using Git-LFS protocol
#
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
"""lfs - large file support (EXPERIMENTAL)
Matt Harbison
lfs: expand the user facing documentation
r35786 This extension allows large files to be tracked outside of the normal
repository storage and stored on a centralized server, similar to the
``largefiles`` extension. The ``git-lfs`` protocol is used when
communicating with the server, so existing git infrastructure can be
harnessed. Even though the files are stored outside of the repository,
they are still integrity checked in the same manner as normal files.
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Matt Harbison
lfs: expand the user facing documentation
r35786 The files stored outside of the repository are downloaded on demand,
which reduces the time to clone, and possibly the local disk usage.
This changes fundamental workflows in a DVCS, so careful thought
should be given before deploying it. :hg:`convert` can be used to
convert LFS repositories to normal repositories that no longer
require this extension, and do so without changing the commit hashes.
This allows the extension to be disabled if the centralized workflow
becomes burdensome. However, the pre and post convert clones will
not be able to communicate with each other unless the extension is
enabled on both.
Matt Harbison
lfs: don't require the .hglfs file to be tracked to control the policy...
r35825 To start a new repository, or to add LFS files to an existing one, just
create an ``.hglfs`` file as described below in the root directory of
the repository. Typically, this file should be put under version
control, so that the settings will propagate to other repositories with
push and pull. During any commit, Mercurial will consult this file to
determine if an added or modified file should be stored externally. The
type of storage depends on the characteristics of the file at each
commit. A file that is near a size threshold may switch back and forth
between LFS and normal storage, as needed.
Matt Harbison
lfs: expand the user facing documentation
r35786
Alternately, both normal repositories and largefile controlled
repositories can be converted to LFS by using :hg:`convert` and the
``lfs.track`` config option described below. The ``.hglfs`` file
should then be created and added, to control subsequent LFS selection.
The hashes are also unchanged in this case. The LFS and non-LFS
repositories can be distinguished because the LFS repository will
abort any command if this extension is disabled.
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Matt Harbison
lfs: expand the user facing documentation
r35786 Committed LFS files are held locally, until the repository is pushed.
Prior to pushing the normal repository data, the LFS files that are
tracked by the outgoing commits are automatically uploaded to the
configured central server. No LFS files are transferred on
:hg:`pull` or :hg:`clone`. Instead, the files are downloaded on
demand as they need to be read, if a cached copy cannot be found
locally. Both committing and downloading an LFS file will link the
file to a usercache, to speed up future access. See the `usercache`
config setting described below.
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 The extension reads its configuration from a versioned ``.hglfs``
configuration file found in the root of the working directory. The
``.hglfs`` file uses the same syntax as all other Mercurial
configuration files. It uses a single section, ``[track]``.
Matt Harbison
lfs: expand the user facing documentation
r35786
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 The ``[track]`` section specifies which files are stored as LFS (or
not). Each line is keyed by a file pattern, with a predicate value.
The first file pattern match is used, so put more specific patterns
first. The available predicates are ``all()``, ``none()``, and
``size()``. See "hg help filesets.size" for the latter.
Matt Harbison
lfs: expand the user facing documentation
r35786
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 Example versioned ``.hglfs`` file::
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 [track]
# No Makefile or python file, anywhere, will be LFS
**Makefile = none()
**.py = none()
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 **.zip = all()
**.exe = size(">1MB")
Matt Harbison
lfs: expand the user facing documentation
r35786
Denis Laxalde
lfs: dedent documentation section about .hglfs file...
r43597 # Catchall for everything not matched above
** = size(">10MB")
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 Configs::
[lfs]
# Remote endpoint. Multiple protocols are supported:
# - http(s)://user:pass@example.com/path
# git-lfs endpoint
# - file:///tmp/path
# local filesystem, usually for testing
Matt Harbison
lfs: infer the blob store URL from an explicit push dest or default-push...
r37582 # if unset, lfs will assume the remote repository also handles blob storage
# for http(s) URLs. Otherwise, lfs will prompt to set this when it must
# use this value.
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 # (default: unset)
Matt Harbison
lfs: expand the user facing documentation
r35786 url = https://example.com/repo.git/info/lfs
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 # Which files to track in LFS. Path tests are "**.extname" for file
# extensions, and "path:under/some/directory" for path prefix. Both
Yuya Nishihara
fileset: add kind:pat operator...
r35759 # are relative to the repository root.
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 # File size can be tested with the "size()" fileset, and tests can be
# joined with fileset operators. (See "hg help filesets.operators".)
#
# Some examples:
# - all() # everything
# - none() # nothing
# - size(">20MB") # larger than 20MB
# - !**.txt # anything not a *.txt file
# - **.zip | **.tar.gz | **.7z # some types of compressed files
Yuya Nishihara
fileset: add kind:pat operator...
r35759 # - path:bin # files under "bin" in the project root
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 # - (**.php & size(">2MB")) | (**.js & size(">5MB")) | **.tar.gz
Yuya Nishihara
fileset: add kind:pat operator...
r35759 # | (path:bin & !path:/bin/README) | size(">1GB")
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 # (default: none())
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 #
# This is ignored if there is a tracked '.hglfs' file, and this setting
# will eventually be deprecated and removed.
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 track = size(">10M")
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
# how many times to retry before giving up on transferring an object
retry = 5
Matt Harbison
lfs: introduce a user level cache for lfs files...
r35281
# the local directory to store lfs files for sharing across local clones.
# If not set, the cache is located in an OS specific cache location.
usercache = /path/to/global/cache
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 """
from __future__ import absolute_import
Matt Harbison
lfs: register the flag processors per repository...
r40304 import sys
Matt Harbison
lfs: quiesce check-module-import warnings...
r35098 from mercurial.i18n import _
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 from mercurial import (
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 config,
Matt Harbison
exthelper: drop the addattr() decorator...
r41315 context,
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 error,
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 exchange,
extensions,
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 exthelper,
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 filelog,
Yuya Nishihara
fileset: extract language processing part to new module (API)...
r38841 filesetlang,
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167 localrepo,
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 minifileset,
Matt Harbison
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs...
r35520 node,
Matt Harbison
lfs: convert '{lfs_files}' keyword to a hybrid list...
r35675 pycompat,
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 revlog,
scmutil,
Yuya Nishihara
templater: move hybrid class and functions to templateutil module...
r36939 templateutil,
Matt Harbison
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'...
r35749 util,
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 )
Augie Fackler
formatting: blacken the codebase...
r43346 from mercurial.interfaces import repository
Pulkit Goyal
interfaces: create a new folder for interfaces and move repository.py in it...
r43078
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 from . import (
blobstore,
Matt Harbison
lfs: add basic routing for the server side wire protocol processing...
r37165 wireprotolfsserver,
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 wrapper,
)
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 testedwith = b'ships-with-hg-core'
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 eh = exthelper.exthelper()
eh.merge(wrapper.eh)
eh.merge(wireprotolfsserver.eh)
Matt Harbison
lfs: register config options...
r35099
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 cmdtable = eh.cmdtable
configtable = eh.configtable
extsetup = eh.finalextsetup
uisetup = eh.finaluisetup
Matt Harbison
exthelper: reintroduce the ability to register filesets...
r41100 filesetpredicate = eh.filesetpredicate
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 reposetup = eh.finalreposetup
Matt Harbison
exthelper: reintroduce the ability to register templates...
r41099 templatekeyword = eh.templatekeyword
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'experimental', b'lfs.serve', default=True,
Matt Harbison
lfs: add an experimental knob to disable blob serving...
r37265 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'experimental', b'lfs.user-agent', default=None,
Matt Harbison
lfs: add an experimental config to override User-Agent for the blob transfer...
r35456 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'experimental', b'lfs.disableusercache', default=False,
Matt Harbison
lfs: special case the null:// usercache instead of treating it as a url...
r37580 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Matt Harbison
lfs: enable workers by default...
r44747 b'experimental', b'lfs.worker-enable', default=True,
Matt Harbison
lfs: default to not using workers for upload/download...
r35750 )
Matt Harbison
lfs: add an experimental config to override User-Agent for the blob transfer...
r35456
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'lfs', b'url', default=None,
Matt Harbison
lfs: register config options...
r35099 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'lfs', b'usercache', default=None,
Matt Harbison
lfs: introduce a user level cache for lfs files...
r35281 )
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 # Deprecated
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'lfs', b'threshold', default=None,
Matt Harbison
lfs: register config options...
r35099 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'lfs', b'track', default=b'none()',
Matt Harbison
lfs: migrate most file filtering from threshold to custom filter...
r35636 )
Augie Fackler
formatting: blacken the codebase...
r43346 eh.configitem(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'lfs', b'retry', default=5,
Matt Harbison
lfs: register config options...
r35099 )
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
Matt Harbison
lfs: register the flag processors per repository...
r40304 lfsprocessor = (
wrapper.readfromstore,
wrapper.writetostore,
wrapper.bypasscheckhash,
)
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167 def featuresetup(ui, supported):
# don't die on seeing a repo with the lfs requirement
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 supported |= {b'lfs'}
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 @eh.uisetup
def _uisetup(ui):
Gregory Szorc
localrepo: move featuresetupfuncs out of localrepository class (API)...
r37153 localrepo.featuresetupfuncs.add(featuresetup)
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 @eh.reposetup
def _reposetup(ui, repo):
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 # Nothing to do with a remote repo
if not repo.local():
return
repo.svfs.lfslocalblobstore = blobstore.local(repo)
repo.svfs.lfsremoteblobstore = blobstore.remote(repo)
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 class lfsrepo(repo.__class__):
@localrepo.unfilteredmethod
Valentin Gatien-Baron
convert: add a config option to help doing identity hg->hg conversion...
r42839 def commitctx(self, ctx, error=False, origctx=None):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.svfs.options[b'lfstrack'] = _trackedmatcher(self)
Valentin Gatien-Baron
convert: add a config option to help doing identity hg->hg conversion...
r42839 return super(lfsrepo, self).commitctx(ctx, error, origctx=origctx)
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
repo.__class__ = lfsrepo
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'lfs' not in repo.requirements:
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167 def checkrequireslfs(ui, repo, **kwargs):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if b'lfs' in repo.requirements:
Matt Harbison
lfs: avoid a potential variable reference before assignment error in cmdserver...
r40184 return 0
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 last = kwargs.get('node_last')
Matt Harbison
lfs: avoid a potential variable reference before assignment error in cmdserver...
r40184 _bin = node.bin
if last:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 s = repo.set(b'%n:%n', _bin(kwargs['node']), _bin(last))
Matt Harbison
lfs: avoid a potential variable reference before assignment error in cmdserver...
r40184 else:
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 s = repo.set(b'%n', _bin(kwargs['node']))
Martin von Zweigbergk
narrow: extract repo property for store narrowmatcher...
r41266 match = repo._storenarrowmatch
Matt Harbison
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs...
r35520 for ctx in s:
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167 # TODO: is there a way to just walk the files in the commit?
Augie Fackler
formatting: blacken the codebase...
r43346 if any(
ctx[f].islfs() for f in ctx.files() if f in ctx and match(f)
):
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.requirements.add(b'lfs')
Gregory Szorc
lfs: add repository feature denoting the use of LFS...
r39887 repo.features.add(repository.REPO_FEATURE_LFS)
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167 repo._writerequirements()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.prepushoutgoinghooks.add(b'lfs', wrapper.prepush)
Matt Harbison
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs...
r35520 break
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ui.setconfig(b'hooks', b'commit.lfs', checkrequireslfs, b'lfs')
ui.setconfig(
b'hooks', b'pretxnchangegroup.lfs', checkrequireslfs, b'lfs'
)
Matt Harbison
lfs: defer registering the pre-push hook until blobs are committed...
r35753 else:
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 repo.prepushoutgoinghooks.add(b'lfs', wrapper.prepush)
Matt Harbison
lfs: add a repo requirement for this extension once an lfs file is committed...
r35167
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: drop an unused function parameter
r35898 def _trackedmatcher(repo):
Matt Harbison
lfs: move the tracked file function creation to a method...
r35682 """Return a function (path, size) -> bool indicating whether or not to
track a given file with lfs."""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 if not repo.wvfs.exists(b'.hglfs'):
Matt Harbison
lfs: don't require the .hglfs file to be tracked to control the policy...
r35825 # No '.hglfs' in wdir. Fallback to config for now.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 trackspec = repo.ui.config(b'lfs', b'track')
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Matt Harbison
lfs: don't require the .hglfs file to be tracked to control the policy...
r35825 # deprecated config: lfs.threshold
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 threshold = repo.ui.configbytes(b'lfs', b'threshold')
Matt Harbison
lfs: don't require the .hglfs file to be tracked to control the policy...
r35825 if threshold:
Yuya Nishihara
fileset: extract language processing part to new module (API)...
r38841 filesetlang.parse(trackspec) # make sure syntax errors are confined
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 trackspec = b"(%s) | size('>%d')" % (trackspec, threshold)
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Matt Harbison
lfs: don't require the .hglfs file to be tracked to control the policy...
r35825 return minifileset.compile(trackspec)
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 data = repo.wvfs.tryread(b'.hglfs')
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 if not data:
return lambda p, s: False
# Parse errors here will abort with a message that points to the .hglfs file
# and line number.
cfg = config.config()
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 cfg.parse(b'.hglfs', data)
Matt Harbison
lfs: move the tracked file function creation to a method...
r35682
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 try:
Augie Fackler
formatting: blacken the codebase...
r43346 rules = [
(minifileset.compile(pattern), minifileset.compile(rule))
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 for pattern, rule in cfg.items(b'track')
Augie Fackler
formatting: blacken the codebase...
r43346 ]
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683 except error.ParseError as e:
# The original exception gives no indicator that the error is in the
# .hglfs file, so add that.
# TODO: See if the line number of the file can be made available.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 raise error.Abort(_(b'parse error in .hglfs: %s') % e)
Matt Harbison
lfs: control tracked file selection via a tracked file...
r35683
def _match(path, size):
for pat, rule in rules:
if pat(path, size):
return rule(path, size)
return False
return _match
Matt Harbison
lfs: move the tracked file function creation to a method...
r35682
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 # Called by remotefilelog
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 def wrapfilelog(filelog):
wrapfunction = extensions.wrapfunction
wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision)
wrapfunction(filelog, 'renamed', wrapper.filelogrenamed)
wrapfunction(filelog, 'size', wrapper.filelogsize)
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @eh.wrapfunction(localrepo, b'resolverevlogstorevfsoptions')
Matt Harbison
lfs: register the flag processors per repository...
r40304 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']:
Augie Fackler
formatting: blacken the codebase...
r43346 msg = (
_(b"cannot register multiple processors on flag '%#x'.")
% revlog.REVIDX_EXTSTORED
)
Matt Harbison
lfs: register the flag processors per repository...
r40304 raise error.Abort(msg)
opts[b'flagprocessors'][revlog.REVIDX_EXTSTORED] = lfsprocessor
break
return opts
Augie Fackler
formatting: blacken the codebase...
r43346
Matt Harbison
lfs: convert to using exthelper to wrap functions...
r41078 @eh.extsetup
def _extsetup(ui):
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 wrapfilelog(filelog.filelog)
Matt Harbison
exthelper: drop the addattr() decorator...
r41315 context.basefilectx.islfs = wrapper.filectxislfs
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 scmutil.fileprefetchhooks.add(b'lfs', wrapper._prefetchfiles)
Matt Harbison
lfs: prefetch lfs blobs when applying merge updates...
r35940
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 # Make bundle choose changegroup3 instead of changegroup2. This affects
# "hg bundle" command. Note: it does not cover all bundle formats like
# "packed1". Using "packed1" with lfs will likely cause trouble.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 exchange._bundlespeccontentopts[b"v2"][b"cg.version"] = b"03"
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @eh.filesetpredicate(b'lfs()')
Matt Harbison
lfs: add a fileset for detecting lfs files...
r36008 def lfsfileset(mctx, x):
"""File that uses LFS storage."""
# i18n: "lfs" is a keyword
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 filesetlang.getargs(x, 0, 0, _(b"lfs takes no arguments"))
Yuya Nishihara
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)...
r38711 ctx = mctx.ctx
Augie Fackler
formatting: blacken the codebase...
r43346
Yuya Nishihara
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)...
r38711 def lfsfilep(f):
return wrapper.pointerfromctx(ctx, f, removed=True) is not None
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 return mctx.predicate(lfsfilep, predrepr=b'<lfs>')
Matt Harbison
lfs: add a fileset for detecting lfs files...
r36008
Augie Fackler
formatting: blacken the codebase...
r43346
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 @eh.templatekeyword(b'lfs_files', requires={b'ctx'})
Yuya Nishihara
templatekw: switch remainder of _showlist template keywords to new API
r36616 def lfsfiles(context, mapping):
Matt Harbison
lfs: teach '{lfs_files}' to handle removed files
r36017 """List of strings. All files modified, added, or removed by this
changeset."""
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 ctx = context.resource(mapping, b'ctx')
Matt Harbison
lfs: convert '{lfs_files}' keyword to a hybrid list...
r35675
Augie Fackler
formatting: blacken the codebase...
r43346 pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer}
Matt Harbison
lfs: convert '{lfs_files}' keyword to a hybrid list...
r35675 files = sorted(pointers.keys())
Matt Harbison
lfs: rename {lfsattrs} to {pointer}...
r35787 def pointer(v):
Matt Harbison
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'...
r35749 # In the file spec, version is first and the other keys are sorted.
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 sortkeyfunc = lambda x: (x[0] != b'version', x)
Gregory Szorc
py3: define and use pycompat.iteritems() for hgext/...
r43375 items = sorted(pycompat.iteritems(pointers[v]), key=sortkeyfunc)
Matt Harbison
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'...
r35749 return util.sortdict(items)
Matt Harbison
lfs: convert '{lfs_files}' keyword to a hybrid list...
r35675 makemap = lambda v: {
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'file': v,
b'lfsoid': pointers[v].oid() if pointers[v] else None,
b'lfspointer': templateutil.hybriddict(pointer(v)),
Matt Harbison
lfs: convert '{lfs_files}' keyword to a hybrid list...
r35675 }
# TODO: make the separator ', '?
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 f = templateutil._showcompatlist(context, mapping, b'lfs_file', files)
Yuya Nishihara
templater: move hybrid class and functions to templateutil module...
r36939 return templateutil.hybrid(f, files, makemap, pycompat.identity)
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097
Augie Fackler
formatting: blacken the codebase...
r43346
@eh.command(
Augie Fackler
formatting: byteify all mercurial/ and hgext/ string literals...
r43347 b'debuglfsupload',
[(b'r', b'rev', [], _(b'upload large files introduced by REV'))],
Augie Fackler
formatting: blacken the codebase...
r43346 )
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 def debuglfsupload(ui, repo, **opts):
"""upload lfs blobs added by the working copy parent or given revisions"""
Augie Fackler
cleanup: remove pointless r-prefixes on single-quoted strings...
r43906 revs = opts.get('rev', [])
Matt Harbison
lfs: import the Facebook git-lfs client extension...
r35097 pointers = wrapper.extractpointers(repo, scmutil.revrange(repo, revs))
wrapper.uploadblobs(repo, pointers)
Matt Harbison
lfs: add a switch to `hg verify` to ignore the content of blobs...
r44528
@eh.wrapcommand(
Matt Harbison
lfs: don't skip locally available blobs when verifying...
r44529 b'verify',
opts=[(b'', b'no-lfs', None, _(b'skip missing lfs blob content'))],
Matt Harbison
lfs: add a switch to `hg verify` to ignore the content of blobs...
r44528 )
def verify(orig, ui, repo, **opts):
skipflags = repo.ui.configint(b'verify', b'skipflags')
no_lfs = opts.pop('no_lfs')
if skipflags:
# --lfs overrides the config bit, if set.
if no_lfs is False:
skipflags &= ~repository.REVISION_FLAG_EXTSTORED
else:
skipflags = 0
if no_lfs is True:
skipflags |= repository.REVISION_FLAG_EXTSTORED
with ui.configoverride({(b'verify', b'skipflags'): skipflags}):
return orig(ui, repo, **opts)