hgext/largefiles/__init__.py
author Raphaël Gomès <rgomes@octobus.net>
Wed, 08 Jun 2022 15:12:34 +0200
changeset 49345 137d6bb71937
parent 48875 6000f5b25c9b
child 49852 564d360fc98e
permissions -rw-r--r--
rust: use owned types in `Matcher` This simplifies the code a lot, allows for some refactoring to come. The original code tried to prevent allocations that were already happening anyway beforehand.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     1
# Copyright 2009-2010 Gregory P. Ward
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     2
# Copyright 2009-2010 Intelerad Medical Systems Incorporated
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     3
# Copyright 2010-2011 Fog Creek Software
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     4
# Copyright 2010-2011 Unity Technologies
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     5
#
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     6
# This software may be used and distributed according to the terms of the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     7
# GNU General Public License version 2 or any later version.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     8
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     9
'''track large binary files
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    10
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    11
Large binary files tend to be not very compressible, not very
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    12
diffable, and not at all mergeable. Such files are not handled
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    13
efficiently by Mercurial's storage format (revlog), which is based on
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    14
compressed binary deltas; storing large binary files as regular
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    15
Mercurial files wastes bandwidth and disk space and increases
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    16
Mercurial's memory usage. The largefiles extension addresses these
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    17
problems by adding a centralized client-server layer on top of
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    18
Mercurial: largefiles live in a *central store* out on the network
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    19
somewhere, and you only fetch the revisions that you need when you
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    20
need them.
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    21
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    22
largefiles works by maintaining a "standin file" in .hglf/ for each
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    23
largefile. The standins are small (41 bytes: an SHA-1 hash plus
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    24
newline) and are tracked by Mercurial. Largefile revisions are
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    25
identified by the SHA-1 hash of their contents, which is written to
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    26
the standin. largefiles uses that revision ID to get/put largefile
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    27
revisions from/to the central store. This saves both disk space and
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    28
bandwidth, since you don't need to retrieve all historical revisions
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    29
of large files when you clone or pull.
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    30
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    31
To start a new repository or add new large binary files, just add
15352
b74f74b482d8 largefiles: improve markup in module help text
Martin Geisler <mg@aragost.com>
parents: 15304
diff changeset
    32
--large to your :hg:`add` command. For example::
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    33
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    34
  $ dd if=/dev/urandom of=randomdata count=2000
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    35
  $ hg add --large randomdata
28798
c065e0ec13d1 largefiles: use double quotes for arguments
timeless <timeless@mozdev.org>
parents: 28394
diff changeset
    36
  $ hg commit -m "add randomdata as a largefile"
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    37
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    38
When you push a changeset that adds/modifies largefiles to a remote
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    39
repository, its largefile revisions will be uploaded along with it.
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    40
Note that the remote Mercurial must also have the largefiles extension
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    41
enabled for this to work.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    42
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    43
When you pull a changeset that affects largefiles from a remote
18975
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    44
repository, the largefiles for the changeset will by default not be
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    45
pulled down. However, when you update to such a revision, any
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    46
largefiles needed by that revision are downloaded and cached (if
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    47
they have never been downloaded before). One way to pull largefiles
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    48
when pulling is thus to use --update, which will update your working
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    49
copy to the latest pulled revision (and thereby downloading any new
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    50
largefiles).
18704
d69585a5c5c0 largefiles: don't cache largefiles for pulled heads by default
Na'Tosha Bard <natosha@unity3d.com>
parents: 18599
diff changeset
    51
18976
6734951e2d24 largefiles: introduce lfpull command for pulling missing largefiles
Mads Kiilerich <madski@unity3d.com>
parents: 18975
diff changeset
    52
If you want to pull largefiles you don't need for update yet, then
18978
8abaadab9abb largefiles: introduce pull --lfrev option
Mads Kiilerich <madski@unity3d.com>
parents: 18976
diff changeset
    53
you can use pull with the `--lfrev` option or the :hg:`lfpull` command.
18976
6734951e2d24 largefiles: introduce lfpull command for pulling missing largefiles
Mads Kiilerich <madski@unity3d.com>
parents: 18975
diff changeset
    54
19071
64ea454e7d76 largefiles: fix typos in documentation
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 18980
diff changeset
    55
If you know you are pulling from a non-default location and want to
64ea454e7d76 largefiles: fix typos in documentation
Wagner Bruna <wbruna@softwareexpress.com.br>
parents: 18980
diff changeset
    56
download all the largefiles that correspond to the new changesets at
18979
1176832fc757 largefiles: introduce pulled() revset expression for use in --lfrev
Mads Kiilerich <madski@unity3d.com>
parents: 18978
diff changeset
    57
the same time, then you can pull with `--lfrev "pulled()"`.
1176832fc757 largefiles: introduce pulled() revset expression for use in --lfrev
Mads Kiilerich <madski@unity3d.com>
parents: 18978
diff changeset
    58
18975
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    59
If you just want to ensure that you will have the largefiles needed to
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    60
merge or rebase with new heads that you are pulling, then you can pull
18979
1176832fc757 largefiles: introduce pulled() revset expression for use in --lfrev
Mads Kiilerich <madski@unity3d.com>
parents: 18978
diff changeset
    61
with `--lfrev "head(pulled())"` flag to pre-emptively download any largefiles
18704
d69585a5c5c0 largefiles: don't cache largefiles for pulled heads by default
Na'Tosha Bard <natosha@unity3d.com>
parents: 18599
diff changeset
    62
that are new in the heads you are pulling.
18599
5cd1dbf4c5d2 largefiles: document behavior of caching largefiles for new heads
Na'Tosha Bard <natosha@unity3d.com>
parents: 17233
diff changeset
    63
18975
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    64
Keep in mind that network access may now be required to update to
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    65
changesets that you have not previously updated to. The nature of the
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    66
largefiles extension means that updating is no longer guaranteed to
aa8205a9f51a largefiles: update help
Mads Kiilerich <madski@unity3d.com>
parents: 18704
diff changeset
    67
be a local-only operation.
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    68
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    69
If you already have large files tracked by Mercurial without the
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    70
largefiles extension, you will need to convert your repository in
15352
b74f74b482d8 largefiles: improve markup in module help text
Martin Geisler <mg@aragost.com>
parents: 15304
diff changeset
    71
order to benefit from largefiles. This is done with the
b74f74b482d8 largefiles: improve markup in module help text
Martin Geisler <mg@aragost.com>
parents: 15304
diff changeset
    72
:hg:`lfconvert` command::
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    73
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    74
  $ hg lfconvert --size 10 oldrepo newrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    75
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    76
In repositories that already have largefiles in them, any new file
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    77
over 10MB will automatically be added as a largefile. To change this
15304
9aa9d4bb3d88 largefiles: rename config setting 'size' to 'minsize'
Greg Ward <greg@gerg.ca>
parents: 15291
diff changeset
    78
threshold, set ``largefiles.minsize`` in your Mercurial config file
9aa9d4bb3d88 largefiles: rename config setting 'size' to 'minsize'
Greg Ward <greg@gerg.ca>
parents: 15291
diff changeset
    79
to the minimum size in megabytes to track as a largefile, or use the
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    80
--lfsize option to the add command (also in megabytes)::
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    81
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    82
  [largefiles]
15304
9aa9d4bb3d88 largefiles: rename config setting 'size' to 'minsize'
Greg Ward <greg@gerg.ca>
parents: 15291
diff changeset
    83
  minsize = 2
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    84
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    85
  $ hg add --lfsize 2
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    86
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    87
The ``largefiles.patterns`` config option allows you to specify a list
15352
b74f74b482d8 largefiles: improve markup in module help text
Martin Geisler <mg@aragost.com>
parents: 15304
diff changeset
    88
of filename patterns (see :hg:`help patterns`) that should always be
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    89
tracked as largefiles::
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    90
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    91
  [largefiles]
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    92
  patterns =
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    93
    *.jpg
33816
1775f93da25c largefiles: fix help text to avoid warning at "make update-pot"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 32291
diff changeset
    94
    re:.*\\.(png|bmp)$
15230
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    95
    library.zip
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    96
    content/audio/*
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    97
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    98
Files that match one of these patterns will be added as largefiles
697289c5d415 largefiles: improve help
Greg Ward <greg@gerg.ca>
parents: 15168
diff changeset
    99
regardless of their size.
15743
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   100
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   101
The ``largefiles.minsize`` and ``largefiles.patterns`` config options
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   102
will be ignored for any repositories not already containing a
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   103
largefile. To add the first largefile to a repository, you must
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   104
explicitly do so with the --large flag passed to the :hg:`add`
6266b1b970a5 largefiles: clarify help when options are ignored until first add is done
Michal Sznajder <michalsznajder@gmail.com>
parents: 15352
diff changeset
   105
command.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   106
'''
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   107
29306
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   108
from mercurial import (
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   109
    cmdutil,
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   110
    extensions,
41059
0ecf58f7c2b2 largefiles: port configitems to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 37135
diff changeset
   111
    exthelper,
29306
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   112
    hg,
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   113
    localrepo,
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   114
    wireprotov1server,
29306
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   115
)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   116
29306
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   117
from . import (
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   118
    lfcommands,
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   119
    overrides,
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   120
    proto,
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   121
    reposetup,
83cecc0b991f py3: make largefiles/__init__.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28798
diff changeset
   122
)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   123
29841
d5883fd055c6 extensions: change magic "shipped with hg" string
Augie Fackler <augie@google.com>
parents: 29306
diff changeset
   124
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
25186
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 21770
diff changeset
   125
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 21770
diff changeset
   126
# be specifying the version(s) of Mercurial they are tested with, or
80c5b2666a96 extensions: document that `testedwith = 'internal'` is special
Augie Fackler <augie@google.com>
parents: 21770
diff changeset
   127
# leave the attribute unspecified.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   128
testedwith = b'ships-with-hg-core'
17233
acea82757d8a largefiles: mark as a first party extension
Matt Harbison <matt_harbison@yahoo.com>
parents: 15743
diff changeset
   129
41059
0ecf58f7c2b2 largefiles: port configitems to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 37135
diff changeset
   130
eh = exthelper.exthelper()
41061
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   131
eh.merge(lfcommands.eh)
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   132
eh.merge(overrides.eh)
41062
0a7f582f6f1f largefiles: port wrapped functions to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41061
diff changeset
   133
eh.merge(proto.eh)
34755
66adbe3c1046 configitems: register the 'largefiles.minsize' config
Boris Feld <boris.feld@octobus.net>
parents: 33816
diff changeset
   134
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   135
eh.configitem(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   136
    b'largefiles',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   137
    b'minsize',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   138
    default=eh.configitem.dynamicdefault,
34755
66adbe3c1046 configitems: register the 'largefiles.minsize' config
Boris Feld <boris.feld@octobus.net>
parents: 33816
diff changeset
   139
)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   140
eh.configitem(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   141
    b'largefiles',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   142
    b'patterns',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   143
    default=list,
34756
3f3c6d12095d configitems: register the 'largefiles.patterns' config
Boris Feld <boris.feld@octobus.net>
parents: 34755
diff changeset
   144
)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   145
eh.configitem(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   146
    b'largefiles',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   147
    b'usercache',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45545
diff changeset
   148
    default=None,
34757
8cf0a6cd1ed2 configitems: register the 'largefiles.usercache' config
Boris Feld <boris.feld@octobus.net>
parents: 34756
diff changeset
   149
)
8cf0a6cd1ed2 configitems: register the 'largefiles.usercache' config
Boris Feld <boris.feld@octobus.net>
parents: 34756
diff changeset
   150
41061
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   151
cmdtable = eh.cmdtable
41059
0ecf58f7c2b2 largefiles: port configitems to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 37135
diff changeset
   152
configtable = eh.configtable
41061
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   153
extsetup = eh.finalextsetup
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   154
reposetup = reposetup.reposetup
41061
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   155
uisetup = eh.finaluisetup
19779
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19071
diff changeset
   156
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   157
19779
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19071
diff changeset
   158
def featuresetup(ui, supported):
19928
d1ac3790e10a localrepo: invoke only feature setup functions for enabled extensions
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19779
diff changeset
   159
    # don't die on seeing a repo with the largefiles requirement
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   160
    supported |= {b'largefiles'}
19779
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19071
diff changeset
   161
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   162
41061
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   163
@eh.uisetup
98681293c890 largefiles: port commands to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41059
diff changeset
   164
def _uisetup(ui):
37135
ecac0006b90e localrepo: move featuresetupfuncs out of localrepository class (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 34917
diff changeset
   165
    localrepo.featuresetupfuncs.add(featuresetup)
20858
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19928
diff changeset
   166
    hg.wirepeersetupfuncs.append(proto.wirereposetup)
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   167
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   168
    cmdutil.outgoinghooks.add(b'largefiles', overrides.outgoinghook)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   169
    cmdutil.summaryremotehooks.add(b'largefiles', overrides.summaryremotehook)
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   170
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   171
    # create the new wireproto commands ...
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   172
    wireprotov1server.wireprotocommand(b'putlfile', b'sha', permission=b'push')(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   173
        proto.putlfile
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   174
    )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   175
    wireprotov1server.wireprotocommand(b'getlfile', b'sha', permission=b'pull')(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   176
        proto.getlfile
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   177
    )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   178
    wireprotov1server.wireprotocommand(
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   179
        b'statlfile', b'sha', permission=b'pull'
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   180
    )(proto.statlfile)
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   181
    wireprotov1server.wireprotocommand(b'lheads', b'', permission=b'pull')(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   182
        wireprotov1server.heads
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   183
    )
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   184
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   185
    extensions.wrapfunction(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   186
        wireprotov1server.commands[b'heads'], b'func', proto.heads
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   187
    )
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   188
    # TODO also wrap wireproto.commandsv2 once heads is implemented there.
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   189
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   190
    # override some extensions' stuff as well
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   191
    for name, module in extensions.extensions():
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   192
        if name == b'rebase':
41065
0840862977c8 largefiles: drop the uisetup module
Matt Harbison <matt_harbison@yahoo.com>
parents: 41062
diff changeset
   193
            # TODO: teach exthelper to handle this
45545
e5e1285b6f6f largefiles: prevent in-memory merge instead of switching to on-disk
Martin von Zweigbergk <martinvonz@google.com>
parents: 43077
diff changeset
   194
            extensions.wrapfunction(
e5e1285b6f6f largefiles: prevent in-memory merge instead of switching to on-disk
Martin von Zweigbergk <martinvonz@google.com>
parents: 43077
diff changeset
   195
                module, b'rebase', overrides.overriderebasecmd
e5e1285b6f6f largefiles: prevent in-memory merge instead of switching to on-disk
Martin von Zweigbergk <martinvonz@google.com>
parents: 43077
diff changeset
   196
            )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 41072
diff changeset
   197
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   198
41067
f2601cbce209 largefiles: port revset registration to exthelper
Matt Harbison <matt_harbison@yahoo.com>
parents: 41065
diff changeset
   199
revsetpredicate = eh.revsetpredicate