hgext/lfs/__init__.py
author Matt Harbison <matt_harbison@yahoo.com>
Fri, 19 Jan 2018 19:20:50 -0500
changeset 35769 f00edef84c3b
parent 35768 60a6ab7bcda7
child 35797 76cb752af07a
permissions -rw-r--r--
lfs: rename {lfsattrs} to {pointer} This seems more descriptive.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     1
# lfs - hash-preserving large file support using Git-LFS protocol
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     2
#
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     3
# Copyright 2017 Facebook, Inc.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     4
#
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     7
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     8
"""lfs - large file support (EXPERIMENTAL)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
     9
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    10
This extension allows large files to be tracked outside of the normal
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    11
repository storage and stored on a centralized server, similar to the
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    12
``largefiles`` extension.  The ``git-lfs`` protocol is used when
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    13
communicating with the server, so existing git infrastructure can be
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    14
harnessed.  Even though the files are stored outside of the repository,
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    15
they are still integrity checked in the same manner as normal files.
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    16
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    17
The files stored outside of the repository are downloaded on demand,
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    18
which reduces the time to clone, and possibly the local disk usage.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    19
This changes fundamental workflows in a DVCS, so careful thought
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    20
should be given before deploying it.  :hg:`convert` can be used to
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    21
convert LFS repositories to normal repositories that no longer
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    22
require this extension, and do so without changing the commit hashes.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    23
This allows the extension to be disabled if the centralized workflow
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    24
becomes burdensome.  However, the pre and post convert clones will
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    25
not be able to communicate with each other unless the extension is
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    26
enabled on both.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    27
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    28
To start a new repository, or add new LFS files, just create and add
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    29
an ``.hglfs`` file as described below.  Because the file is tracked in
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    30
the repository, all clones will use the same selection policy.  During
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    31
subsequent commits, Mercurial will consult this file to determine if
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    32
an added or modified file should be stored externally.  The type of
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    33
storage depends on the characteristics of the file at each commit.  A
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    34
file that is near a size threshold may switch back and forth between
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    35
LFS and normal storage, as needed.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    36
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    37
Alternately, both normal repositories and largefile controlled
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    38
repositories can be converted to LFS by using :hg:`convert` and the
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    39
``lfs.track`` config option described below.  The ``.hglfs`` file
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    40
should then be created and added, to control subsequent LFS selection.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    41
The hashes are also unchanged in this case.  The LFS and non-LFS
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    42
repositories can be distinguished because the LFS repository will
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    43
abort any command if this extension is disabled.
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    44
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    45
Committed LFS files are held locally, until the repository is pushed.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    46
Prior to pushing the normal repository data, the LFS files that are
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    47
tracked by the outgoing commits are automatically uploaded to the
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    48
configured central server.  No LFS files are transferred on
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    49
:hg:`pull` or :hg:`clone`.  Instead, the files are downloaded on
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    50
demand as they need to be read, if a cached copy cannot be found
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    51
locally.  Both committing and downloading an LFS file will link the
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    52
file to a usercache, to speed up future access.  See the `usercache`
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    53
config setting described below.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    54
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    55
.hglfs::
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    56
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    57
    The extension reads its configuration from a versioned ``.hglfs``
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    58
    configuration file found in the root of the working directory. The
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    59
    ``.hglfs`` file uses the same syntax as all other Mercurial
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    60
    configuration files. It uses a single section, ``[track]``.
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    61
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    62
    The ``[track]`` section specifies which files are stored as LFS (or
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    63
    not). Each line is keyed by a file pattern, with a predicate value.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    64
    The first file pattern match is used, so put more specific patterns
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    65
    first.  The available predicates are ``all()``, ``none()``, and
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    66
    ``size()``. See "hg help filesets.size" for the latter.
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    67
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    68
    Example versioned ``.hglfs`` file::
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    69
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    70
      [track]
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    71
      # No Makefile or python file, anywhere, will be LFS
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    72
      **Makefile = none()
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    73
      **.py = none()
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    74
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    75
      **.zip = all()
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    76
      **.exe = size(">1MB")
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    77
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    78
      # Catchall for everything not matched above
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    79
      ** = size(">10MB")
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
    80
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    81
Configs::
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    82
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    83
    [lfs]
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    84
    # Remote endpoint. Multiple protocols are supported:
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    85
    # - http(s)://user:pass@example.com/path
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    86
    #   git-lfs endpoint
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    87
    # - file:///tmp/path
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    88
    #   local filesystem, usually for testing
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    89
    # if unset, lfs will prompt setting this when it must use this value.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    90
    # (default: unset)
35768
60a6ab7bcda7 lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents: 35741
diff changeset
    91
    url = https://example.com/repo.git/info/lfs
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
    92
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    93
    # Which files to track in LFS.  Path tests are "**.extname" for file
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    94
    # extensions, and "path:under/some/directory" for path prefix.  Both
35741
73432eee0ac4 fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents: 35735
diff changeset
    95
    # are relative to the repository root.
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    96
    # File size can be tested with the "size()" fileset, and tests can be
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    97
    # joined with fileset operators.  (See "hg help filesets.operators".)
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    98
    #
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
    99
    # Some examples:
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   100
    # - all()                       # everything
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   101
    # - none()                      # nothing
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   102
    # - size(">20MB")               # larger than 20MB
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   103
    # - !**.txt                     # anything not a *.txt file
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   104
    # - **.zip | **.tar.gz | **.7z  # some types of compressed files
35741
73432eee0ac4 fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents: 35735
diff changeset
   105
    # - path:bin                    # files under "bin" in the project root
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   106
    # - (**.php & size(">2MB")) | (**.js & size(">5MB")) | **.tar.gz
35741
73432eee0ac4 fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents: 35735
diff changeset
   107
    #     | (path:bin & !path:/bin/README) | size(">1GB")
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   108
    # (default: none())
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   109
    #
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   110
    # This is ignored if there is a tracked '.hglfs' file, and this setting
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   111
    # will eventually be deprecated and removed.
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   112
    track = size(">10M")
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   113
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   114
    # how many times to retry before giving up on transferring an object
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   115
    retry = 5
35289
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   116
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   117
    # the local directory to store lfs files for sharing across local clones.
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   118
    # If not set, the cache is located in an OS specific cache location.
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   119
    usercache = /path/to/global/cache
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   120
"""
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   122
from __future__ import absolute_import
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   123
35122
b8e5fb8d2389 lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents: 35121
diff changeset
   124
from mercurial.i18n import _
b8e5fb8d2389 lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents: 35121
diff changeset
   125
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   126
from mercurial import (
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   127
    bundle2,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   128
    changegroup,
35663
a985834961f7 lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents: 35658
diff changeset
   129
    cmdutil,
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   130
    config,
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   131
    context,
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   132
    error,
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   133
    exchange,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   134
    extensions,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   135
    filelog,
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   136
    fileset,
35223
24aa4853c031 lfs: enable the extension locally after cloning a repo with 'lfs' requirement
Matt Harbison <matt_harbison@yahoo.com>
parents: 35189
diff changeset
   137
    hg,
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   138
    localrepo,
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   139
    minifileset,
35508
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   140
    node,
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   141
    pycompat,
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   142
    registrar,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   143
    revlog,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   144
    scmutil,
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   145
    templatekw,
35355
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   146
    upgrade,
35731
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   147
    util,
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   148
    vfs as vfsmod,
35510
fa865878a849 lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents: 35508
diff changeset
   149
    wireproto,
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   150
)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   151
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   152
from . import (
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   153
    blobstore,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   154
    wrapper,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   155
)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   156
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   157
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   158
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   159
# be specifying the version(s) of Mercurial they are tested with, or
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   160
# leave the attribute unspecified.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   161
testedwith = 'ships-with-hg-core'
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   162
35123
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   163
configtable = {}
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   164
configitem = registrar.configitem(configtable)
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   165
35444
e333d27514b0 lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents: 35372
diff changeset
   166
configitem('experimental', 'lfs.user-agent',
e333d27514b0 lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents: 35372
diff changeset
   167
    default=None,
e333d27514b0 lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents: 35372
diff changeset
   168
)
35732
10e62d5efa73 lfs: default to not using workers for upload/download
Matt Harbison <matt_harbison@yahoo.com>
parents: 35731
diff changeset
   169
configitem('experimental', 'lfs.worker-enable',
10e62d5efa73 lfs: default to not using workers for upload/download
Matt Harbison <matt_harbison@yahoo.com>
parents: 35731
diff changeset
   170
    default=False,
10e62d5efa73 lfs: default to not using workers for upload/download
Matt Harbison <matt_harbison@yahoo.com>
parents: 35731
diff changeset
   171
)
35444
e333d27514b0 lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents: 35372
diff changeset
   172
35123
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   173
configitem('lfs', 'url',
35614
6d6d20658cce lfs: drop deprecated remote store config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35510
diff changeset
   174
    default=None,
35123
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   175
)
35289
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   176
configitem('lfs', 'usercache',
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   177
    default=None,
8e72f9152c4d lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents: 35224
diff changeset
   178
)
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   179
# Deprecated
35123
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   180
configitem('lfs', 'threshold',
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   181
    default=None,
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   182
)
35618
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   183
configitem('lfs', 'track',
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   184
    default='none()',
c780e0649e41 lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents: 35614
diff changeset
   185
)
35123
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   186
configitem('lfs', 'retry',
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   187
    default=5,
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   188
)
07e97998d385 lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents: 35122
diff changeset
   189
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   190
cmdtable = {}
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   191
command = registrar.command(cmdtable)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   192
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   193
templatekeyword = registrar.templatekeyword()
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   194
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   195
def featuresetup(ui, supported):
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   196
    # don't die on seeing a repo with the lfs requirement
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   197
    supported |= {'lfs'}
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   198
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   199
def uisetup(ui):
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   200
    localrepo.localrepository.featuresetupfuncs.add(featuresetup)
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   201
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   202
def reposetup(ui, repo):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   203
    # Nothing to do with a remote repo
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   204
    if not repo.local():
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   205
        return
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   206
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   207
    repo.svfs.lfslocalblobstore = blobstore.local(repo)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   208
    repo.svfs.lfsremoteblobstore = blobstore.remote(repo)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   209
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   210
    class lfsrepo(repo.__class__):
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   211
        @localrepo.unfilteredmethod
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   212
        def commitctx(self, ctx, error=False):
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   213
            repo.svfs.options['lfstrack'] = _trackedmatcher(self, ctx)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   214
            return super(lfsrepo, self).commitctx(ctx, error)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   215
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   216
    repo.__class__ = lfsrepo
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   217
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   218
    if 'lfs' not in repo.requirements:
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   219
        def checkrequireslfs(ui, repo, **kwargs):
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   220
            if 'lfs' not in repo.requirements:
35508
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   221
                last = kwargs.get('node_last')
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   222
                _bin = node.bin
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   223
                if last:
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   224
                    s = repo.set('%n:%n', _bin(kwargs['node']), _bin(last))
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   225
                else:
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   226
                    s = repo.set('%n', _bin(kwargs['node']))
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   227
            for ctx in s:
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   228
                # TODO: is there a way to just walk the files in the commit?
35456
488634db5928 lfs: fix committing deleted files caused by e0a1b9ee93cd
Jun Wu <quark@fb.com>
parents: 35444
diff changeset
   229
                if any(ctx[f].islfs() for f in ctx.files() if f in ctx):
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   230
                    repo.requirements.add('lfs')
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   231
                    repo._writerequirements()
35735
693e3bcae19e lfs: defer registering the pre-push hook until blobs are committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35732
diff changeset
   232
                    repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
35508
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   233
                    break
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   234
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   235
        ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs')
35508
6bb940de4c4c lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35456
diff changeset
   236
        ui.setconfig('hooks', 'pretxnchangegroup.lfs', checkrequireslfs, 'lfs')
35735
693e3bcae19e lfs: defer registering the pre-push hook until blobs are committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35732
diff changeset
   237
    else:
693e3bcae19e lfs: defer registering the pre-push hook until blobs are committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35732
diff changeset
   238
        repo.prepushoutgoinghooks.add('lfs', wrapper.prepush)
35186
e0a1b9ee93cd lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents: 35123
diff changeset
   239
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   240
def _trackedmatcher(repo, ctx):
35664
3c838bdc57b6 lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents: 35663
diff changeset
   241
    """Return a function (path, size) -> bool indicating whether or not to
3c838bdc57b6 lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents: 35663
diff changeset
   242
    track a given file with lfs."""
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   243
    data = ''
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   244
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   245
    if '.hglfs' in ctx.added() or '.hglfs' in ctx.modified():
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   246
        data = ctx['.hglfs'].data()
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   247
    elif '.hglfs' not in ctx.removed():
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   248
        p1 = repo['.']
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   249
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   250
        if '.hglfs' not in p1:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   251
            # No '.hglfs' in wdir or in parent.  Fallback to config
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   252
            # for now.
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   253
            trackspec = repo.ui.config('lfs', 'track')
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   254
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   255
            # deprecated config: lfs.threshold
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   256
            threshold = repo.ui.configbytes('lfs', 'threshold')
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   257
            if threshold:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   258
                fileset.parse(trackspec)  # make sure syntax errors are confined
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   259
                trackspec = "(%s) | size('>%d')" % (trackspec, threshold)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   260
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   261
            return minifileset.compile(trackspec)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   262
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   263
        data = p1['.hglfs'].data()
35664
3c838bdc57b6 lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents: 35663
diff changeset
   264
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   265
    # In removed, or not in parent
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   266
    if not data:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   267
        return lambda p, s: False
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   268
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   269
    # Parse errors here will abort with a message that points to the .hglfs file
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   270
    # and line number.
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   271
    cfg = config.config()
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   272
    cfg.parse('.hglfs', data)
35664
3c838bdc57b6 lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents: 35663
diff changeset
   273
35665
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   274
    try:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   275
        rules = [(minifileset.compile(pattern), minifileset.compile(rule))
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   276
                 for pattern, rule in cfg.items('track')]
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   277
    except error.ParseError as e:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   278
        # The original exception gives no indicator that the error is in the
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   279
        # .hglfs file, so add that.
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   280
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   281
        # TODO: See if the line number of the file can be made available.
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   282
        raise error.Abort(_('parse error in .hglfs: %s') % e)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   283
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   284
    def _match(path, size):
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   285
        for pat, rule in rules:
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   286
            if pat(path, size):
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   287
                return rule(path, size)
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   288
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   289
        return False
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   290
1ad1e59b405e lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents: 35664
diff changeset
   291
    return _match
35664
3c838bdc57b6 lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents: 35663
diff changeset
   292
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   293
def wrapfilelog(filelog):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   294
    wrapfunction = extensions.wrapfunction
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   295
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   296
    wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   297
    wrapfunction(filelog, 'renamed', wrapper.filelogrenamed)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   298
    wrapfunction(filelog, 'size', wrapper.filelogsize)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   299
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   300
def extsetup(ui):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   301
    wrapfilelog(filelog.filelog)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   302
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   303
    wrapfunction = extensions.wrapfunction
35189
f8f939a2926c lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35186
diff changeset
   304
35663
a985834961f7 lfs: allow the pointer file to be viewed with `hg cat -T '{rawdata}'`
Matt Harbison <matt_harbison@yahoo.com>
parents: 35658
diff changeset
   305
    wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter)
35189
f8f939a2926c lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35186
diff changeset
   306
    wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink)
f8f939a2926c lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents: 35186
diff changeset
   307
35372
b0ba1539af01 lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents: 35355
diff changeset
   308
    wrapfunction(upgrade, '_finishdatamigration',
b0ba1539af01 lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents: 35355
diff changeset
   309
                 wrapper.upgradefinishdatamigration)
b0ba1539af01 lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents: 35355
diff changeset
   310
35355
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   311
    wrapfunction(upgrade, 'preservedrequirements',
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   312
                 wrapper.upgraderequirements)
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   313
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   314
    wrapfunction(upgrade, 'supporteddestrequirements',
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   315
                 wrapper.upgraderequirements)
9eb19b13e92a lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents: 35289
diff changeset
   316
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   317
    wrapfunction(changegroup,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   318
                 'supportedoutgoingversions',
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   319
                 wrapper.supportedoutgoingversions)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   320
    wrapfunction(changegroup,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   321
                 'allsupportedversions',
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   322
                 wrapper.allsupportedversions)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   323
35510
fa865878a849 lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents: 35508
diff changeset
   324
    wrapfunction(exchange, 'push', wrapper.push)
fa865878a849 lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents: 35508
diff changeset
   325
    wrapfunction(wireproto, '_capabilities', wrapper._capabilities)
fa865878a849 lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents: 35508
diff changeset
   326
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   327
    wrapfunction(context.basefilectx, 'cmp', wrapper.filectxcmp)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   328
    wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   329
    context.basefilectx.islfs = wrapper.filectxislfs
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   330
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   331
    revlog.addflagprocessor(
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   332
        revlog.REVIDX_EXTSTORED,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   333
        (
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   334
            wrapper.readfromstore,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   335
            wrapper.writetostore,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   336
            wrapper.bypasscheckhash,
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   337
        ),
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   338
    )
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   339
35223
24aa4853c031 lfs: enable the extension locally after cloning a repo with 'lfs' requirement
Matt Harbison <matt_harbison@yahoo.com>
parents: 35189
diff changeset
   340
    wrapfunction(hg, 'clone', wrapper.hgclone)
35224
a8c778b2a689 lfs: enable the extension locally after sharing a repo with 'lfs' requirement
Matt Harbison <matt_harbison@yahoo.com>
parents: 35223
diff changeset
   341
    wrapfunction(hg, 'postshare', wrapper.hgpostshare)
35223
24aa4853c031 lfs: enable the extension locally after cloning a repo with 'lfs' requirement
Matt Harbison <matt_harbison@yahoo.com>
parents: 35189
diff changeset
   342
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   343
    # Make bundle choose changegroup3 instead of changegroup2. This affects
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   344
    # "hg bundle" command. Note: it does not cover all bundle formats like
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   345
    # "packed1". Using "packed1" with lfs will likely cause trouble.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   346
    names = [k for k, v in exchange._bundlespeccgversions.items() if v == '02']
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   347
    for k in names:
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   348
        exchange._bundlespeccgversions[k] = '03'
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   349
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   350
    # bundlerepo uses "vfsmod.readonlyvfs(othervfs)", we need to make sure lfs
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   351
    # options and blob stores are passed from othervfs to the new readonlyvfs.
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   352
    wrapfunction(vfsmod.readonlyvfs, '__init__', wrapper.vfsinit)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   353
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   354
    # when writing a bundle via "hg bundle" command, upload related LFS blobs
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   355
    wrapfunction(bundle2, 'writenewbundle', wrapper.writenewbundle)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   356
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   357
@templatekeyword('lfs_files')
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   358
def lfsfiles(repo, ctx, **args):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   359
    """List of strings. LFS files added or modified by the changeset."""
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   360
    args = pycompat.byteskwargs(args)
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   361
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   362
    pointers = wrapper.pointersfromctx(ctx) # {path: pointer}
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   363
    files = sorted(pointers.keys())
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   364
35769
f00edef84c3b lfs: rename {lfsattrs} to {pointer}
Matt Harbison <matt_harbison@yahoo.com>
parents: 35768
diff changeset
   365
    def pointer(v):
35731
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   366
        # In the file spec, version is first and the other keys are sorted.
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   367
        sortkeyfunc = lambda x: (x[0] != 'version', x)
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   368
        items = sorted(pointers[v].iteritems(), key=sortkeyfunc)
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   369
        return util.sortdict(items)
f58245b9e3ea lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35665
diff changeset
   370
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   371
    makemap = lambda v: {
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   372
        'file': v,
35658
a1222a8cc93b lfs: add the '{oid}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents: 35657
diff changeset
   373
        'oid': pointers[v].oid(),
35769
f00edef84c3b lfs: rename {lfsattrs} to {pointer}
Matt Harbison <matt_harbison@yahoo.com>
parents: 35768
diff changeset
   374
        'pointer': templatekw.hybriddict(pointer(v)),
35657
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   375
    }
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   376
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   377
    # TODO: make the separator ', '?
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   378
    f = templatekw._showlist('lfs_file', files, args)
8580e5898cb7 lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents: 35618
diff changeset
   379
    return templatekw._hybrid(f, files, makemap, pycompat.identity)
35121
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   380
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   381
@command('debuglfsupload',
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   382
         [('r', 'rev', [], _('upload large files introduced by REV'))])
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   383
def debuglfsupload(ui, repo, **opts):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   384
    """upload lfs blobs added by the working copy parent or given revisions"""
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   385
    revs = opts.get('rev', [])
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   386
    pointers = wrapper.extractpointers(repo, scmutil.revrange(repo, revs))
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
   387
    wrapper.uploadblobs(repo, pointers)