Show More
@@ -19,8 +19,23 b' Configs::' | |||||
19 | # (default: unset) |
|
19 | # (default: unset) | |
20 | url = https://example.com/lfs |
|
20 | url = https://example.com/lfs | |
21 |
|
21 | |||
22 | # size of a file to make it use LFS |
|
22 | # Which files to track in LFS. Path tests are "**.extname" for file | |
23 | threshold = 10M |
|
23 | # extensions, and "path:under/some/directory" for path prefix. Both | |
|
24 | # are relative to the repository root, and the latter must be quoted. | |||
|
25 | # File size can be tested with the "size()" fileset, and tests can be | |||
|
26 | # joined with fileset operators. (See "hg help filesets.operators".) | |||
|
27 | # | |||
|
28 | # Some examples: | |||
|
29 | # - all() # everything | |||
|
30 | # - none() # nothing | |||
|
31 | # - size(">20MB") # larger than 20MB | |||
|
32 | # - !**.txt # anything not a *.txt file | |||
|
33 | # - **.zip | **.tar.gz | **.7z # some types of compressed files | |||
|
34 | # - "path:bin" # files under "bin" in the project root | |||
|
35 | # - (**.php & size(">2MB")) | (**.js & size(">5MB")) | **.tar.gz | |||
|
36 | # | ("path:bin" & !"path:/bin/README") | size(">1GB") | |||
|
37 | # (default: none()) | |||
|
38 | track = size(">10M") | |||
24 |
|
39 | |||
25 | # how many times to retry before giving up on transferring an object |
|
40 | # how many times to retry before giving up on transferring an object | |
26 | retry = 5 |
|
41 | retry = 5 | |
@@ -41,8 +56,10 b' from mercurial import (' | |||||
41 | exchange, |
|
56 | exchange, | |
42 | extensions, |
|
57 | extensions, | |
43 | filelog, |
|
58 | filelog, | |
|
59 | fileset, | |||
44 | hg, |
|
60 | hg, | |
45 | localrepo, |
|
61 | localrepo, | |
|
62 | minifileset, | |||
46 | node, |
|
63 | node, | |
47 | registrar, |
|
64 | registrar, | |
48 | revlog, |
|
65 | revlog, | |
@@ -76,9 +93,13 b" configitem('lfs', 'url'," | |||||
76 | configitem('lfs', 'usercache', |
|
93 | configitem('lfs', 'usercache', | |
77 | default=None, |
|
94 | default=None, | |
78 | ) |
|
95 | ) | |
|
96 | # Deprecated | |||
79 | configitem('lfs', 'threshold', |
|
97 | configitem('lfs', 'threshold', | |
80 | default=None, |
|
98 | default=None, | |
81 | ) |
|
99 | ) | |
|
100 | configitem('lfs', 'track', | |||
|
101 | default='none()', | |||
|
102 | ) | |||
82 | configitem('lfs', 'retry', |
|
103 | configitem('lfs', 'retry', | |
83 | default=5, |
|
104 | default=5, | |
84 | ) |
|
105 | ) | |
@@ -100,9 +121,15 b' def reposetup(ui, repo):' | |||||
100 | if not repo.local(): |
|
121 | if not repo.local(): | |
101 | return |
|
122 | return | |
102 |
|
123 | |||
103 |
t |
|
124 | trackspec = repo.ui.config('lfs', 'track') | |
104 |
|
125 | |||
105 | repo.svfs.options['lfsthreshold'] = threshold |
|
126 | # deprecated config: lfs.threshold | |
|
127 | threshold = repo.ui.configbytes('lfs', 'threshold') | |||
|
128 | if threshold: | |||
|
129 | fileset.parse(trackspec) # make sure syntax errors are confined | |||
|
130 | trackspec = "(%s) | size('>%d')" % (trackspec, threshold) | |||
|
131 | ||||
|
132 | repo.svfs.options['lfstrack'] = minifileset.compile(trackspec) | |||
106 | repo.svfs.lfslocalblobstore = blobstore.local(repo) |
|
133 | repo.svfs.lfslocalblobstore = blobstore.local(repo) | |
107 | repo.svfs.lfsremoteblobstore = blobstore.remote(repo) |
|
134 | repo.svfs.lfsremoteblobstore = blobstore.remote(repo) | |
108 |
|
135 |
@@ -123,14 +123,14 b' def _islfs(rlog, node=None, rev=None):' | |||||
123 | def filelogaddrevision(orig, self, text, transaction, link, p1, p2, |
|
123 | def filelogaddrevision(orig, self, text, transaction, link, p1, p2, | |
124 | cachedelta=None, node=None, |
|
124 | cachedelta=None, node=None, | |
125 | flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds): |
|
125 | flags=revlog.REVIDX_DEFAULT_FLAGS, **kwds): | |
126 | threshold = self.opener.options['lfsthreshold'] |
|
|||
127 | textlen = len(text) |
|
126 | textlen = len(text) | |
128 | # exclude hg rename meta from file size |
|
127 | # exclude hg rename meta from file size | |
129 | meta, offset = filelog.parsemeta(text) |
|
128 | meta, offset = filelog.parsemeta(text) | |
130 | if offset: |
|
129 | if offset: | |
131 | textlen -= offset |
|
130 | textlen -= offset | |
132 |
|
131 | |||
133 | if threshold and textlen > threshold: |
|
132 | lfstrack = self.opener.options['lfstrack'] | |
|
133 | if lfstrack(self.filename, textlen): | |||
134 | flags |= revlog.REVIDX_EXTSTORED |
|
134 | flags |= revlog.REVIDX_EXTSTORED | |
135 |
|
135 | |||
136 | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, |
|
136 | return orig(self, text, transaction, link, p1, p2, cachedelta=cachedelta, |
@@ -30,7 +30,7 b'' | |||||
30 | > lfs= |
|
30 | > lfs= | |
31 | > [lfs] |
|
31 | > [lfs] | |
32 | > url=http://foo:bar@$LFS_HOST/ |
|
32 | > url=http://foo:bar@$LFS_HOST/ | |
33 | > threshold=1 |
|
33 | > track=all() | |
34 | > EOF |
|
34 | > EOF | |
35 |
|
35 | |||
36 | $ hg init repo1 |
|
36 | $ hg init repo1 |
@@ -4,6 +4,7 b'' | |||||
4 | > [extensions] |
|
4 | > [extensions] | |
5 | > lfs= |
|
5 | > lfs= | |
6 | > [lfs] |
|
6 | > [lfs] | |
|
7 | > # Test deprecated config | |||
7 | > threshold=1000B |
|
8 | > threshold=1000B | |
8 | > EOF |
|
9 | > EOF | |
9 |
|
10 | |||
@@ -140,7 +141,7 b' enabled adds the lfs requirement' | |||||
140 | $ cd repo3 |
|
141 | $ cd repo3 | |
141 | $ cat >> .hg/hgrc << EOF |
|
142 | $ cat >> .hg/hgrc << EOF | |
142 | > [lfs] |
|
143 | > [lfs] | |
143 | > threshold=10B |
|
144 | > track=size(">10B") | |
144 | > EOF |
|
145 | > EOF | |
145 |
|
146 | |||
146 | $ echo LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS > large |
|
147 | $ echo LONGER-THAN-TEN-BYTES-WILL-TRIGGER-LFS > large | |
@@ -203,7 +204,7 b' enabled adds the lfs requirement' | |||||
203 | $ cd repo6 |
|
204 | $ cd repo6 | |
204 | $ cat >> .hg/hgrc << EOF |
|
205 | $ cat >> .hg/hgrc << EOF | |
205 | > [lfs] |
|
206 | > [lfs] | |
206 | > threshold=30B |
|
207 | > track=size(">30B") | |
207 | > EOF |
|
208 | > EOF | |
208 |
|
209 | |||
209 | $ echo LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES > large |
|
210 | $ echo LARGE-BECAUSE-IT-IS-MORE-THAN-30-BYTES > large | |
@@ -239,7 +240,7 b' enabled adds the lfs requirement' | |||||
239 | $ cd repo8 |
|
240 | $ cd repo8 | |
240 | $ cat >> .hg/hgrc << EOF |
|
241 | $ cat >> .hg/hgrc << EOF | |
241 | > [lfs] |
|
242 | > [lfs] | |
242 | > threshold=10B |
|
243 | > track=size(">10B") | |
243 | > EOF |
|
244 | > EOF | |
244 |
|
245 | |||
245 | $ echo THIS-IS-LFS-BECAUSE-10-BYTES > a1 |
|
246 | $ echo THIS-IS-LFS-BECAUSE-10-BYTES > a1 | |
@@ -320,7 +321,7 b' enabled adds the lfs requirement' | |||||
320 | $ cd repo9 |
|
321 | $ cd repo9 | |
321 | $ cat >> .hg/hgrc << EOF |
|
322 | $ cat >> .hg/hgrc << EOF | |
322 | > [lfs] |
|
323 | > [lfs] | |
323 | > threshold=10B |
|
324 | > track=size(">10B") | |
324 | > [diff] |
|
325 | > [diff] | |
325 | > git=1 |
|
326 | > git=1 | |
326 | > EOF |
|
327 | > EOF | |
@@ -454,7 +455,7 b' enabled adds the lfs requirement' | |||||
454 | > [extensions] |
|
455 | > [extensions] | |
455 | > lfs= |
|
456 | > lfs= | |
456 | > [lfs] |
|
457 | > [lfs] | |
457 | > threshold=1 |
|
458 | > track=all() | |
458 | > EOF |
|
459 | > EOF | |
459 | $ $PYTHON <<'EOF' |
|
460 | $ $PYTHON <<'EOF' | |
460 | > def write(path, content): |
|
461 | > def write(path, content): | |
@@ -542,6 +543,47 b' enabled adds the lfs requirement' | |||||
542 |
|
543 | |||
543 | $ cd .. |
|
544 | $ cd .. | |
544 |
|
545 | |||
|
546 | # Test filter | |||
|
547 | ||||
|
548 | $ hg init repo11 | |||
|
549 | $ cd repo11 | |||
|
550 | $ cat >> .hg/hgrc << EOF | |||
|
551 | > [lfs] | |||
|
552 | > track=(**.a & size(">5B")) | (**.b & !size(">5B")) | |||
|
553 | > | (**.c & "path:d" & !"path:d/c.c") | size(">10B") | |||
|
554 | > EOF | |||
|
555 | ||||
|
556 | $ mkdir a | |||
|
557 | $ echo aaaaaa > a/1.a | |||
|
558 | $ echo a > a/2.a | |||
|
559 | $ echo aaaaaa > 1.b | |||
|
560 | $ echo a > 2.b | |||
|
561 | $ echo a > 1.c | |||
|
562 | $ mkdir d | |||
|
563 | $ echo a > d/c.c | |||
|
564 | $ echo a > d/d.c | |||
|
565 | $ echo aaaaaaaaaaaa > x | |||
|
566 | $ hg add . -q | |||
|
567 | $ hg commit -m files | |||
|
568 | ||||
|
569 | $ for p in a/1.a a/2.a 1.b 2.b 1.c d/c.c d/d.c x; do | |||
|
570 | > if hg debugdata $p 0 2>&1 | grep git-lfs >/dev/null; then | |||
|
571 | > echo "${p}: is lfs" | |||
|
572 | > else | |||
|
573 | > echo "${p}: not lfs" | |||
|
574 | > fi | |||
|
575 | > done | |||
|
576 | a/1.a: is lfs | |||
|
577 | a/2.a: not lfs | |||
|
578 | 1.b: not lfs | |||
|
579 | 2.b: is lfs | |||
|
580 | 1.c: not lfs | |||
|
581 | d/c.c: not lfs | |||
|
582 | d/d.c: is lfs | |||
|
583 | x: is lfs | |||
|
584 | ||||
|
585 | $ cd .. | |||
|
586 | ||||
545 | # Verify the repos |
|
587 | # Verify the repos | |
546 |
|
588 | |||
547 | $ cat > $TESTTMP/dumpflog.py << EOF |
|
589 | $ cat > $TESTTMP/dumpflog.py << EOF |
General Comments 0
You need to be logged in to leave comments.
Login now