Mercurial > hg
annotate hgext/lfs/__init__.py @ 40881:8695fbe17f7c
tests: update network related errors for Debian 9
We have a CI job that runs the Mercurial tests in parallel. Some of the
network related failures seems to be different on the environment. Oddly,
those failures happens only when running the tests in parallel, not when
running the test file only.
I have no idea how to get the windows formatted message for the error, if
someone could give me an hand, I will update this changeset with the value.
Differential Revision: https://phab.mercurial-scm.org/D5401
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 10 Dec 2018 10:21:08 +0100 |
parents | ef0baff11aea |
children | 84d61fdcefa5 |
rev | line source |
---|---|
35098
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 |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
28 To start a new repository, or to add LFS files to an existing one, just |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
29 create an ``.hglfs`` file as described below in the root directory of |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
30 the repository. Typically, this file should be put under version |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
31 control, so that the settings will propagate to other repositories with |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
32 push and pull. During any commit, Mercurial will consult this file to |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
33 determine if an added or modified file should be stored externally. The |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
34 type of storage depends on the characteristics of the file at each |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
35 commit. A file that is near a size threshold may switch back and forth |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
36 between LFS and normal storage, as needed. |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
37 |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
38 Alternately, both normal repositories and largefile controlled |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
39 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
|
40 ``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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 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
|
50 :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
|
51 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
|
52 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
|
53 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
|
54 config setting described below. |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
55 |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
56 .hglfs:: |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
57 |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
58 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
|
59 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
|
60 ``.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
|
61 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
|
62 |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 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
|
67 ``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
|
68 |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
69 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
|
70 |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
71 [track] |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
72 # 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
|
73 **Makefile = none() |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
74 **.py = none() |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
75 |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
76 **.zip = all() |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
77 **.exe = size(">1MB") |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
78 |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
79 # Catchall for everything not matched above |
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
80 ** = size(">10MB") |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
81 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
82 Configs:: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
83 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
84 [lfs] |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
85 # Remote endpoint. Multiple protocols are supported: |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
86 # - 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
|
87 # git-lfs endpoint |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
88 # - file:///tmp/path |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
89 # local filesystem, usually for testing |
37564
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37562
diff
changeset
|
90 # if unset, lfs will assume the remote repository also handles blob storage |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37562
diff
changeset
|
91 # for http(s) URLs. Otherwise, lfs will prompt to set this when it must |
31a4ea773369
lfs: infer the blob store URL from an explicit push dest or default-push
Matt Harbison <matt_harbison@yahoo.com>
parents:
37562
diff
changeset
|
92 # use this value. |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
93 # (default: unset) |
35768
60a6ab7bcda7
lfs: expand the user facing documentation
Matt Harbison <matt_harbison@yahoo.com>
parents:
35741
diff
changeset
|
94 url = https://example.com/repo.git/info/lfs |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
95 |
35618
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
96 # 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
|
97 # 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
|
98 # 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
|
99 # 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
|
100 # 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
|
101 # |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
102 # Some examples: |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
103 # - all() # everything |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
104 # - none() # nothing |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
105 # - 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
|
106 # - !**.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
|
107 # - **.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
|
108 # - 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
|
109 # - (**.php & size(">2MB")) | (**.js & size(">5MB")) | **.tar.gz |
35741
73432eee0ac4
fileset: add kind:pat operator
Yuya Nishihara <yuya@tcha.org>
parents:
35735
diff
changeset
|
110 # | (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
|
111 # (default: none()) |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
112 # |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
113 # 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
|
114 # 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
|
115 track = size(">10M") |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
116 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
117 # 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
|
118 retry = 5 |
35280
8e72f9152c4d
lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35214
diff
changeset
|
119 |
8e72f9152c4d
lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35214
diff
changeset
|
120 # 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:
35214
diff
changeset
|
121 # 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:
35214
diff
changeset
|
122 usercache = /path/to/global/cache |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
123 """ |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
124 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
125 from __future__ import absolute_import |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
126 |
40268
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
127 import sys |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
128 |
35099
b8e5fb8d2389
lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents:
35098
diff
changeset
|
129 from mercurial.i18n import _ |
b8e5fb8d2389
lfs: quiesce check-module-import warnings
Matt Harbison <matt_harbison@yahoo.com>
parents:
35098
diff
changeset
|
130 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
131 from mercurial import ( |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
132 bundle2, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
133 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
|
134 cmdutil, |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
135 config, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
136 context, |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
137 error, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
138 exchange, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
139 extensions, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
140 filelog, |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38800
diff
changeset
|
141 filesetlang, |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
142 localrepo, |
35618
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
143 minifileset, |
35504
6bb940de4c4c
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35452
diff
changeset
|
144 node, |
35657
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
145 pycompat, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
146 registrar, |
39851
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38805
diff
changeset
|
147 repository, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
148 revlog, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
149 scmutil, |
36921
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36598
diff
changeset
|
150 templateutil, |
35346
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
151 upgrade, |
35731
f58245b9e3ea
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents:
35665
diff
changeset
|
152 util, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
153 vfs as vfsmod, |
37147
a2566597acb5
lfs: add basic routing for the server side wire protocol processing
Matt Harbison <matt_harbison@yahoo.com>
parents:
37138
diff
changeset
|
154 wireprotoserver, |
37785
b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37564
diff
changeset
|
155 wireprotov1server, |
35098
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 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
158 from . import ( |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
159 blobstore, |
37147
a2566597acb5
lfs: add basic routing for the server side wire protocol processing
Matt Harbison <matt_harbison@yahoo.com>
parents:
37138
diff
changeset
|
160 wireprotolfsserver, |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
161 wrapper, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
162 ) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
163 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
164 # 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
|
165 # 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
|
166 # 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
|
167 # leave the attribute unspecified. |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
168 testedwith = 'ships-with-hg-core' |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
169 |
35100
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
170 configtable = {} |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
171 configitem = registrar.configitem(configtable) |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
172 |
37248
dfb38c4850a9
lfs: add an experimental knob to disable blob serving
Matt Harbison <matt_harbison@yahoo.com>
parents:
37165
diff
changeset
|
173 configitem('experimental', 'lfs.serve', |
dfb38c4850a9
lfs: add an experimental knob to disable blob serving
Matt Harbison <matt_harbison@yahoo.com>
parents:
37165
diff
changeset
|
174 default=True, |
dfb38c4850a9
lfs: add an experimental knob to disable blob serving
Matt Harbison <matt_harbison@yahoo.com>
parents:
37165
diff
changeset
|
175 ) |
35440
e333d27514b0
lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents:
35363
diff
changeset
|
176 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:
35363
diff
changeset
|
177 default=None, |
e333d27514b0
lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents:
35363
diff
changeset
|
178 ) |
37562
e5cd8d1a094d
lfs: special case the null:// usercache instead of treating it as a url
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
179 configitem('experimental', 'lfs.disableusercache', |
e5cd8d1a094d
lfs: special case the null:// usercache instead of treating it as a url
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
180 default=False, |
e5cd8d1a094d
lfs: special case the null:// usercache instead of treating it as a url
Matt Harbison <matt_harbison@yahoo.com>
parents:
37518
diff
changeset
|
181 ) |
35732
10e62d5efa73
lfs: default to not using workers for upload/download
Matt Harbison <matt_harbison@yahoo.com>
parents:
35731
diff
changeset
|
182 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
|
183 default=False, |
10e62d5efa73
lfs: default to not using workers for upload/download
Matt Harbison <matt_harbison@yahoo.com>
parents:
35731
diff
changeset
|
184 ) |
35440
e333d27514b0
lfs: add an experimental config to override User-Agent for the blob transfer
Matt Harbison <matt_harbison@yahoo.com>
parents:
35363
diff
changeset
|
185 |
35100
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
186 configitem('lfs', 'url', |
35614
6d6d20658cce
lfs: drop deprecated remote store config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35506
diff
changeset
|
187 default=None, |
35100
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
188 ) |
35280
8e72f9152c4d
lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35214
diff
changeset
|
189 configitem('lfs', 'usercache', |
8e72f9152c4d
lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35214
diff
changeset
|
190 default=None, |
8e72f9152c4d
lfs: introduce a user level cache for lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35214
diff
changeset
|
191 ) |
35618
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
192 # Deprecated |
35100
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
193 configitem('lfs', 'threshold', |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
194 default=None, |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
195 ) |
35618
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
196 configitem('lfs', 'track', |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
197 default='none()', |
c780e0649e41
lfs: migrate most file filtering from threshold to custom filter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35614
diff
changeset
|
198 ) |
35100
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
199 configitem('lfs', 'retry', |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
200 default=5, |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
201 ) |
07e97998d385
lfs: register config options
Matt Harbison <matt_harbison@yahoo.com>
parents:
35099
diff
changeset
|
202 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
203 cmdtable = {} |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
204 command = registrar.command(cmdtable) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
205 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
206 templatekeyword = registrar.templatekeyword() |
35990
eefb5d603482
lfs: add a fileset for detecting lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
207 filesetpredicate = registrar.filesetpredicate() |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
208 |
40268
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
209 lfsprocessor = ( |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
210 wrapper.readfromstore, |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
211 wrapper.writetostore, |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
212 wrapper.bypasscheckhash, |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
213 ) |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
214 |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
215 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:
35100
diff
changeset
|
216 # 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:
35100
diff
changeset
|
217 supported |= {'lfs'} |
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
218 |
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
219 def uisetup(ui): |
37135
ecac0006b90e
localrepo: move featuresetupfuncs out of localrepository class (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37132
diff
changeset
|
220 localrepo.featuresetupfuncs.add(featuresetup) |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
221 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
222 def reposetup(ui, repo): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
223 # 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
|
224 if not repo.local(): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
225 return |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
226 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
227 repo.svfs.lfslocalblobstore = blobstore.local(repo) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
228 repo.svfs.lfsremoteblobstore = blobstore.remote(repo) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
229 |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
230 class lfsrepo(repo.__class__): |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
231 @localrepo.unfilteredmethod |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
232 def commitctx(self, ctx, error=False): |
35880
6bd2846a82e8
lfs: drop an unused function parameter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35807
diff
changeset
|
233 repo.svfs.options['lfstrack'] = _trackedmatcher(self) |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
234 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
|
235 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
236 repo.__class__ = lfsrepo |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
237 |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
238 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:
35100
diff
changeset
|
239 def checkrequireslfs(ui, repo, **kwargs): |
40131
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
240 if 'lfs' in repo.requirements: |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
241 return 0 |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
242 |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
243 last = kwargs.get(r'node_last') |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
244 _bin = node.bin |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
245 if last: |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
246 s = repo.set('%n:%n', _bin(kwargs[r'node']), _bin(last)) |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
247 else: |
535fc8a22365
lfs: avoid a potential variable reference before assignment error in cmdserver
Matt Harbison <matt_harbison@yahoo.com>
parents:
38689
diff
changeset
|
248 s = repo.set('%n', _bin(kwargs[r'node'])) |
37138
4d63f3bc1e1a
lfs: respect narrowmatcher when testing to add 'lfs' requirement (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37135
diff
changeset
|
249 match = repo.narrowmatch() |
35504
6bb940de4c4c
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35452
diff
changeset
|
250 for ctx in s: |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
251 # TODO: is there a way to just walk the files in the commit? |
37138
4d63f3bc1e1a
lfs: respect narrowmatcher when testing to add 'lfs' requirement (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37135
diff
changeset
|
252 if any(ctx[f].islfs() for f in ctx.files() |
4d63f3bc1e1a
lfs: respect narrowmatcher when testing to add 'lfs' requirement (issue5794)
Matt Harbison <matt_harbison@yahoo.com>
parents:
37135
diff
changeset
|
253 if f in ctx and match(f)): |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
254 repo.requirements.add('lfs') |
39851
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38805
diff
changeset
|
255 repo.features.add(repository.REPO_FEATURE_LFS) |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
256 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
|
257 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) |
35504
6bb940de4c4c
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35452
diff
changeset
|
258 break |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
259 |
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
260 ui.setconfig('hooks', 'commit.lfs', checkrequireslfs, 'lfs') |
35504
6bb940de4c4c
lfs: add the 'lfs' requirement in the changegroup transaction introducing lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35452
diff
changeset
|
261 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
|
262 else: |
693e3bcae19e
lfs: defer registering the pre-push hook until blobs are committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35732
diff
changeset
|
263 repo.prepushoutgoinghooks.add('lfs', wrapper.prepush) |
35175
e0a1b9ee93cd
lfs: add a repo requirement for this extension once an lfs file is committed
Matt Harbison <matt_harbison@yahoo.com>
parents:
35100
diff
changeset
|
264 |
35880
6bd2846a82e8
lfs: drop an unused function parameter
Matt Harbison <matt_harbison@yahoo.com>
parents:
35807
diff
changeset
|
265 def _trackedmatcher(repo): |
35664
3c838bdc57b6
lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents:
35663
diff
changeset
|
266 """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
|
267 track a given file with lfs.""" |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
268 if not repo.wvfs.exists('.hglfs'): |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
269 # No '.hglfs' in wdir. Fallback to config for now. |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
270 trackspec = repo.ui.config('lfs', 'track') |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
271 |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
272 # deprecated config: lfs.threshold |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
273 threshold = repo.ui.configbytes('lfs', 'threshold') |
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
274 if threshold: |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38800
diff
changeset
|
275 filesetlang.parse(trackspec) # make sure syntax errors are confined |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
276 trackspec = "(%s) | size('>%d')" % (trackspec, threshold) |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
277 |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
278 return minifileset.compile(trackspec) |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
279 |
35807
4425790f2373
lfs: don't require the .hglfs file to be tracked to control the policy
Matt Harbison <matt_harbison@yahoo.com>
parents:
35798
diff
changeset
|
280 data = repo.wvfs.tryread('.hglfs') |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
281 if not data: |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
282 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
|
283 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
284 # 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
|
285 # and line number. |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
286 cfg = config.config() |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
287 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
|
288 |
35665
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
289 try: |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 # 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
|
294 # .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
|
295 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
296 # 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
|
297 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
|
298 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
299 def _match(path, size): |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
300 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
|
301 if pat(path, size): |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
302 return rule(path, size) |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
303 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
304 return False |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
305 |
1ad1e59b405e
lfs: control tracked file selection via a tracked file
Matt Harbison <matt_harbison@yahoo.com>
parents:
35664
diff
changeset
|
306 return _match |
35664
3c838bdc57b6
lfs: move the tracked file function creation to a method
Matt Harbison <matt_harbison@yahoo.com>
parents:
35663
diff
changeset
|
307 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
308 def wrapfilelog(filelog): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
309 wrapfunction = extensions.wrapfunction |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
310 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
311 wrapfunction(filelog, 'addrevision', wrapper.filelogaddrevision) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
312 wrapfunction(filelog, 'renamed', wrapper.filelogrenamed) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
313 wrapfunction(filelog, 'size', wrapper.filelogsize) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
314 |
40268
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
315 def _resolverevlogstorevfsoptions(orig, ui, requirements, features): |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
316 opts = orig(ui, requirements, features) |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
317 for name, module in extensions.extensions(ui): |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
318 if module is sys.modules[__name__]: |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
319 if revlog.REVIDX_EXTSTORED in opts[b'flagprocessors']: |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
320 msg = (_(b"cannot register multiple processors on flag '%#x'.") |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
321 % revlog.REVIDX_EXTSTORED) |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
322 raise error.Abort(msg) |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
323 |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
324 opts[b'flagprocessors'][revlog.REVIDX_EXTSTORED] = lfsprocessor |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
325 break |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
326 |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
327 return opts |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
328 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
329 def extsetup(ui): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
330 wrapfilelog(filelog.filelog) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
331 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
332 wrapfunction = extensions.wrapfunction |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35175
diff
changeset
|
333 |
39851
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38805
diff
changeset
|
334 wrapfunction(localrepo, 'makefilestorage', wrapper.localrepomakefilestorage) |
40268
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
335 wrapfunction(localrepo, 'resolverevlogstorevfsoptions', |
9c4cbbb0fc51
lfs: register the flag processors per repository
Matt Harbison <matt_harbison@yahoo.com>
parents:
39868
diff
changeset
|
336 _resolverevlogstorevfsoptions) |
39851
1f7b3b980af8
lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38805
diff
changeset
|
337 |
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
|
338 wrapfunction(cmdutil, '_updatecatformatter', wrapper._updatecatformatter) |
35178
f8f939a2926c
lfs: add a repo requirement for this extension when converting to lfs
Matt Harbison <matt_harbison@yahoo.com>
parents:
35175
diff
changeset
|
339 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:
35175
diff
changeset
|
340 |
35363
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
341 wrapfunction(upgrade, '_finishdatamigration', |
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
342 wrapper.upgradefinishdatamigration) |
b0ba1539af01
lfs: restore the local blob store after a repo upgrade
Matt Harbison <matt_harbison@yahoo.com>
parents:
35346
diff
changeset
|
343 |
35346
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
344 wrapfunction(upgrade, 'preservedrequirements', |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
345 wrapper.upgraderequirements) |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
346 |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
347 wrapfunction(upgrade, 'supporteddestrequirements', |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
348 wrapper.upgraderequirements) |
9eb19b13e92a
lfs: allow to run 'debugupgraderepo' on repo with largefiles
Boris Feld <boris.feld@octobus.net>
parents:
35280
diff
changeset
|
349 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
350 wrapfunction(changegroup, |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
351 'allsupportedversions', |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
352 wrapper.allsupportedversions) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
353 |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35504
diff
changeset
|
354 wrapfunction(exchange, 'push', wrapper.push) |
37785
b4d85bc122bd
wireproto: rename wireproto to wireprotov1server (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37564
diff
changeset
|
355 wrapfunction(wireprotov1server, '_capabilities', wrapper._capabilities) |
37147
a2566597acb5
lfs: add basic routing for the server side wire protocol processing
Matt Harbison <matt_harbison@yahoo.com>
parents:
37138
diff
changeset
|
356 wrapfunction(wireprotoserver, 'handlewsgirequest', |
a2566597acb5
lfs: add basic routing for the server side wire protocol processing
Matt Harbison <matt_harbison@yahoo.com>
parents:
37138
diff
changeset
|
357 wireprotolfsserver.handlewsgirequest) |
35506
fa865878a849
lfs: show a friendly message when pushing lfs to a server without lfs enabled
Matt Harbison <matt_harbison@yahoo.com>
parents:
35504
diff
changeset
|
358 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
359 wrapfunction(context.basefilectx, 'cmp', wrapper.filectxcmp) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
360 wrapfunction(context.basefilectx, 'isbinary', wrapper.filectxisbinary) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
361 context.basefilectx.islfs = wrapper.filectxislfs |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
362 |
36138
a991fcc48222
lfs: migrate to the fileprefetch callback mechanism
Matt Harbison <matt_harbison@yahoo.com>
parents:
36000
diff
changeset
|
363 scmutil.fileprefetchhooks.add('lfs', wrapper._prefetchfiles) |
35922
0b79f99fd7b0
lfs: prefetch lfs blobs when applying merge updates
Matt Harbison <matt_harbison@yahoo.com>
parents:
35880
diff
changeset
|
364 |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
365 # 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
|
366 # "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
|
367 # "packed1". Using "packed1" with lfs will likely cause trouble. |
37165
6c7a6b04b274
bundlespec: move computing the bundle contentops in parsebundlespec
Boris Feld <boris.feld@octobus.net>
parents:
37147
diff
changeset
|
368 exchange._bundlespeccontentopts["v2"]["cg.version"] = "03" |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
369 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
370 # 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
|
371 # 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
|
372 wrapfunction(vfsmod.readonlyvfs, '__init__', wrapper.vfsinit) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
373 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
374 # 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
|
375 wrapfunction(bundle2, 'writenewbundle', wrapper.writenewbundle) |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
376 |
38800
7790cd70842a
lfs: remove callstatus property from 'lfs()' fileset
Yuya Nishihara <yuya@tcha.org>
parents:
38689
diff
changeset
|
377 @filesetpredicate('lfs()') |
35990
eefb5d603482
lfs: add a fileset for detecting lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
378 def lfsfileset(mctx, x): |
eefb5d603482
lfs: add a fileset for detecting lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
379 """File that uses LFS storage.""" |
eefb5d603482
lfs: add a fileset for detecting lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
380 # i18n: "lfs" is a keyword |
38805
b9162ea1b815
fileset: extract language processing part to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
38800
diff
changeset
|
381 filesetlang.getargs(x, 0, 0, _("lfs takes no arguments")) |
38689
ff5b6fca1082
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37785
diff
changeset
|
382 ctx = mctx.ctx |
ff5b6fca1082
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37785
diff
changeset
|
383 def lfsfilep(f): |
ff5b6fca1082
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37785
diff
changeset
|
384 return wrapper.pointerfromctx(ctx, f, removed=True) is not None |
ff5b6fca1082
fileset: rewrite predicates to return matcher not closed to subset (API) (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
37785
diff
changeset
|
385 return mctx.predicate(lfsfilep, predrepr='<lfs>') |
35990
eefb5d603482
lfs: add a fileset for detecting lfs files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35924
diff
changeset
|
386 |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
36921
diff
changeset
|
387 @templatekeyword('lfs_files', requires={'ctx'}) |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36519
diff
changeset
|
388 def lfsfiles(context, mapping): |
35999
8c7d5e90e6bd
lfs: teach '{lfs_files}' to handle removed files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35990
diff
changeset
|
389 """List of strings. All files modified, added, or removed by this |
8c7d5e90e6bd
lfs: teach '{lfs_files}' to handle removed files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35990
diff
changeset
|
390 changeset.""" |
36598
c3f9d0c303e8
templatekw: switch remainder of _showlist template keywords to new API
Yuya Nishihara <yuya@tcha.org>
parents:
36519
diff
changeset
|
391 ctx = context.resource(mapping, 'ctx') |
35657
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
392 |
35999
8c7d5e90e6bd
lfs: teach '{lfs_files}' to handle removed files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35990
diff
changeset
|
393 pointers = wrapper.pointersfromctx(ctx, removed=True) # {path: pointer} |
35657
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
394 files = sorted(pointers.keys()) |
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
395 |
35769
f00edef84c3b
lfs: rename {lfsattrs} to {pointer}
Matt Harbison <matt_harbison@yahoo.com>
parents:
35768
diff
changeset
|
396 def pointer(v): |
35731
f58245b9e3ea
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents:
35665
diff
changeset
|
397 # 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
|
398 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
|
399 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
|
400 return util.sortdict(items) |
f58245b9e3ea
lfs: add the '{lfsattrs}' template keyword to '{lfs_files}'
Matt Harbison <matt_harbison@yahoo.com>
parents:
35665
diff
changeset
|
401 |
35657
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
402 makemap = lambda v: { |
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
403 'file': v, |
35999
8c7d5e90e6bd
lfs: teach '{lfs_files}' to handle removed files
Matt Harbison <matt_harbison@yahoo.com>
parents:
35990
diff
changeset
|
404 'lfsoid': pointers[v].oid() if pointers[v] else None, |
36921
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36598
diff
changeset
|
405 'lfspointer': templateutil.hybriddict(pointer(v)), |
35657
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
406 } |
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
407 |
8580e5898cb7
lfs: convert '{lfs_files}' keyword to a hybrid list
Matt Harbison <matt_harbison@yahoo.com>
parents:
35618
diff
changeset
|
408 # TODO: make the separator ', '? |
37068
aa97e06a1912
templater: use template context to render old-style list template
Yuya Nishihara <yuya@tcha.org>
parents:
36921
diff
changeset
|
409 f = templateutil._showcompatlist(context, mapping, 'lfs_file', files) |
36921
32f9b7e3f056
templater: move hybrid class and functions to templateutil module
Yuya Nishihara <yuya@tcha.org>
parents:
36598
diff
changeset
|
410 return templateutil.hybrid(f, files, makemap, pycompat.identity) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
411 |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
412 @command('debuglfsupload', |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
413 [('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
|
414 def debuglfsupload(ui, repo, **opts): |
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
415 """upload lfs blobs added by the working copy parent or given revisions""" |
36456
9ff5cbfbc26a
py3: fix more keyword arguments handling
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36400
diff
changeset
|
416 revs = opts.get(r'rev', []) |
35098
66c5a8cf2868
lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
417 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
|
418 wrapper.uploadblobs(repo, pointers) |