Show More
@@ -1,100 +1,102 | |||||
1 | # Copyright 2009-2010 Gregory P. Ward |
|
1 | # Copyright 2009-2010 Gregory P. Ward | |
2 | # Copyright 2009-2010 Intelerad Medical Systems Incorporated |
|
2 | # Copyright 2009-2010 Intelerad Medical Systems Incorporated | |
3 | # Copyright 2010-2011 Fog Creek Software |
|
3 | # Copyright 2010-2011 Fog Creek Software | |
4 | # Copyright 2010-2011 Unity Technologies |
|
4 | # Copyright 2010-2011 Unity Technologies | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | '''track large binary files |
|
9 | '''track large binary files | |
10 |
|
10 | |||
11 | Large binary files tend to be not very compressible, not very |
|
11 | Large binary files tend to be not very compressible, not very | |
12 | diffable, and not at all mergeable. Such files are not handled |
|
12 | diffable, and not at all mergeable. Such files are not handled | |
13 | efficiently by Mercurial's storage format (revlog), which is based on |
|
13 | efficiently by Mercurial's storage format (revlog), which is based on | |
14 | compressed binary deltas; storing large binary files as regular |
|
14 | compressed binary deltas; storing large binary files as regular | |
15 | Mercurial files wastes bandwidth and disk space and increases |
|
15 | Mercurial files wastes bandwidth and disk space and increases | |
16 | Mercurial's memory usage. The largefiles extension addresses these |
|
16 | Mercurial's memory usage. The largefiles extension addresses these | |
17 | problems by adding a centralized client-server layer on top of |
|
17 | problems by adding a centralized client-server layer on top of | |
18 | Mercurial: largefiles live in a *central store* out on the network |
|
18 | Mercurial: largefiles live in a *central store* out on the network | |
19 | somewhere, and you only fetch the revisions that you need when you |
|
19 | somewhere, and you only fetch the revisions that you need when you | |
20 | need them. |
|
20 | need them. | |
21 |
|
21 | |||
22 | largefiles works by maintaining a "standin file" in .hglf/ for each |
|
22 | largefiles works by maintaining a "standin file" in .hglf/ for each | |
23 | largefile. The standins are small (41 bytes: an SHA-1 hash plus |
|
23 | largefile. The standins are small (41 bytes: an SHA-1 hash plus | |
24 | newline) and are tracked by Mercurial. Largefile revisions are |
|
24 | newline) and are tracked by Mercurial. Largefile revisions are | |
25 | identified by the SHA-1 hash of their contents, which is written to |
|
25 | identified by the SHA-1 hash of their contents, which is written to | |
26 | the standin. largefiles uses that revision ID to get/put largefile |
|
26 | the standin. largefiles uses that revision ID to get/put largefile | |
27 | revisions from/to the central store. This saves both disk space and |
|
27 | revisions from/to the central store. This saves both disk space and | |
28 | bandwidth, since you don't need to retrieve all historical revisions |
|
28 | bandwidth, since you don't need to retrieve all historical revisions | |
29 | of large files when you clone or pull. |
|
29 | of large files when you clone or pull. | |
30 |
|
30 | |||
31 | To start a new repository or add new large binary files, just add |
|
31 | To start a new repository or add new large binary files, just add | |
32 | --large to your :hg:`add` command. For example:: |
|
32 | --large to your :hg:`add` command. For example:: | |
33 |
|
33 | |||
34 | $ dd if=/dev/urandom of=randomdata count=2000 |
|
34 | $ dd if=/dev/urandom of=randomdata count=2000 | |
35 | $ hg add --large randomdata |
|
35 | $ hg add --large randomdata | |
36 | $ hg commit -m 'add randomdata as a largefile' |
|
36 | $ hg commit -m 'add randomdata as a largefile' | |
37 |
|
37 | |||
38 | When you push a changeset that adds/modifies largefiles to a remote |
|
38 | When you push a changeset that adds/modifies largefiles to a remote | |
39 | repository, its largefile revisions will be uploaded along with it. |
|
39 | repository, its largefile revisions will be uploaded along with it. | |
40 | Note that the remote Mercurial must also have the largefiles extension |
|
40 | Note that the remote Mercurial must also have the largefiles extension | |
41 | enabled for this to work. |
|
41 | enabled for this to work. | |
42 |
|
42 | |||
43 | When you pull a changeset that affects largefiles from a remote |
|
43 | When you pull a changeset that affects largefiles from a remote | |
44 | repository, Mercurial behaves as normal. However, when you update to |
|
44 | repository, Mercurial behaves as normal. However, when you update to | |
45 | such a revision, any largefiles needed by that revision are downloaded |
|
45 | such a revision, any largefiles needed by that revision are downloaded | |
46 | and cached (if they have never been downloaded before). This means |
|
46 | and cached (if they have never been downloaded before). This means | |
47 | that network access may be required to update to changesets you have |
|
47 | that network access may be required to update to changesets you have | |
48 | not previously updated to. |
|
48 | not previously updated to. | |
49 |
|
49 | |||
50 | If you already have large files tracked by Mercurial without the |
|
50 | If you already have large files tracked by Mercurial without the | |
51 | largefiles extension, you will need to convert your repository in |
|
51 | largefiles extension, you will need to convert your repository in | |
52 | order to benefit from largefiles. This is done with the |
|
52 | order to benefit from largefiles. This is done with the | |
53 | :hg:`lfconvert` command:: |
|
53 | :hg:`lfconvert` command:: | |
54 |
|
54 | |||
55 | $ hg lfconvert --size 10 oldrepo newrepo |
|
55 | $ hg lfconvert --size 10 oldrepo newrepo | |
56 |
|
56 | |||
57 | In repositories that already have largefiles in them, any new file |
|
57 | In repositories that already have largefiles in them, any new file | |
58 | over 10MB will automatically be added as a largefile. To change this |
|
58 | over 10MB will automatically be added as a largefile. To change this | |
59 | threshold, set ``largefiles.minsize`` in your Mercurial config file |
|
59 | threshold, set ``largefiles.minsize`` in your Mercurial config file | |
60 | to the minimum size in megabytes to track as a largefile, or use the |
|
60 | to the minimum size in megabytes to track as a largefile, or use the | |
61 | --lfsize option to the add command (also in megabytes):: |
|
61 | --lfsize option to the add command (also in megabytes):: | |
62 |
|
62 | |||
63 | [largefiles] |
|
63 | [largefiles] | |
64 | minsize = 2 |
|
64 | minsize = 2 | |
65 |
|
65 | |||
66 | $ hg add --lfsize 2 |
|
66 | $ hg add --lfsize 2 | |
67 |
|
67 | |||
68 | The ``largefiles.patterns`` config option allows you to specify a list |
|
68 | The ``largefiles.patterns`` config option allows you to specify a list | |
69 | of filename patterns (see :hg:`help patterns`) that should always be |
|
69 | of filename patterns (see :hg:`help patterns`) that should always be | |
70 | tracked as largefiles:: |
|
70 | tracked as largefiles:: | |
71 |
|
71 | |||
72 | [largefiles] |
|
72 | [largefiles] | |
73 | patterns = |
|
73 | patterns = | |
74 | *.jpg |
|
74 | *.jpg | |
75 | re:.*\.(png|bmp)$ |
|
75 | re:.*\.(png|bmp)$ | |
76 | library.zip |
|
76 | library.zip | |
77 | content/audio/* |
|
77 | content/audio/* | |
78 |
|
78 | |||
79 | Files that match one of these patterns will be added as largefiles |
|
79 | Files that match one of these patterns will be added as largefiles | |
80 | regardless of their size. |
|
80 | regardless of their size. | |
81 |
|
81 | |||
82 | The ``largefiles.minsize`` and ``largefiles.patterns`` config options |
|
82 | The ``largefiles.minsize`` and ``largefiles.patterns`` config options | |
83 | will be ignored for any repositories not already containing a |
|
83 | will be ignored for any repositories not already containing a | |
84 | largefile. To add the first largefile to a repository, you must |
|
84 | largefile. To add the first largefile to a repository, you must | |
85 | explicitly do so with the --large flag passed to the :hg:`add` |
|
85 | explicitly do so with the --large flag passed to the :hg:`add` | |
86 | command. |
|
86 | command. | |
87 | ''' |
|
87 | ''' | |
88 |
|
88 | |||
89 | from mercurial import commands |
|
89 | from mercurial import commands | |
90 |
|
90 | |||
91 | import lfcommands |
|
91 | import lfcommands | |
92 | import reposetup |
|
92 | import reposetup | |
93 | import uisetup |
|
93 | import uisetup | |
94 |
|
94 | |||
|
95 | testedwith = 'internal' | |||
|
96 | ||||
95 | reposetup = reposetup.reposetup |
|
97 | reposetup = reposetup.reposetup | |
96 | uisetup = uisetup.uisetup |
|
98 | uisetup = uisetup.uisetup | |
97 |
|
99 | |||
98 | commands.norepo += " lfconvert" |
|
100 | commands.norepo += " lfconvert" | |
99 |
|
101 | |||
100 | cmdtable = lfcommands.cmdtable |
|
102 | cmdtable = lfcommands.cmdtable |
General Comments 0
You need to be logged in to leave comments.
Login now