Mercurial > hg
annotate hgext/sparse.py @ 48863:c76255cde807
tests: unconditionalize _bytes2sys()
As part of requiring Python 3.
Differential Revision: https://phab.mercurial-scm.org/D12241
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Feb 2022 13:24:25 -0700 |
parents | a6efb9180764 |
children | 6000f5b25c9b |
rev | line source |
---|---|
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
1 # sparse.py - allow sparse checkouts of the working directory |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 # |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2014 Facebook, Inc. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 """allow sparse checkouts of the working directory (EXPERIMENTAL) |
33290
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
9 |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
10 (This extension is not yet protected by backwards compatibility |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
11 guarantees. Any aspect may break in future releases until this |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
12 notice is removed.) |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
13 |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
14 This extension allows the working directory to only consist of a |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
15 subset of files for the revision. This allows specific files or |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
16 directories to be explicitly included or excluded. Many repository |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
17 operations have performance proportional to the number of files in |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
18 the working directory. So only realizing a subset of files in the |
cd1c275c9482
sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33289
diff
changeset
|
19 working directory can improve performance. |
33294
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
20 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
21 Sparse Config Files |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
22 ------------------- |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
23 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
24 The set of files that are part of a sparse checkout are defined by |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
25 a sparse config file. The file defines 3 things: includes (files to |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
26 include in the sparse checkout), excludes (files to exclude from the |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
27 sparse checkout), and profiles (links to other config files). |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
28 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
29 The file format is newline delimited. Empty lines and lines beginning |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
30 with ``#`` are ignored. |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
31 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
32 Lines beginning with ``%include `` denote another sparse config file |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
33 to include. e.g. ``%include tests.sparse``. The filename is relative |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
34 to the repository root. |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
35 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
36 The special lines ``[include]`` and ``[exclude]`` denote the section |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
37 for includes and excludes that follow, respectively. It is illegal to |
33551
1d1779734c99
sparse: require [section] in sparse config files (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33496
diff
changeset
|
38 have ``[include]`` after ``[exclude]``. |
33294
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
39 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
40 Non-special lines resemble file patterns to be added to either includes |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
41 or excludes. The syntax of these lines is documented by :hg:`help patterns`. |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
42 Patterns are interpreted as ``glob:`` by default and match against the |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
43 root of the repository. |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
44 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
45 Exclusion patterns take precedence over inclusion patterns. So even |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
46 if a file is explicitly included, an ``[exclude]`` entry can remove it. |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
47 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
48 For example, say you have a repository with 3 directories, ``frontend/``, |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
49 ``backend/``, and ``tools/``. ``frontend/`` and ``backend/`` correspond |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
50 to different projects and it is uncommon for someone working on one |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
51 to need the files for the other. But ``tools/`` contains files shared |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
52 between both projects. Your sparse config files may resemble:: |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
53 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
54 # frontend.sparse |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
55 frontend/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
56 tools/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
57 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
58 # backend.sparse |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
59 backend/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
60 tools/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
61 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
62 Say the backend grows in size. Or there's a directory with thousands |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
63 of files you wish to exclude. You can modify the profile to exclude |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
64 certain files:: |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
65 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
66 [include] |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
67 backend/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
68 tools/** |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
69 |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
70 [exclude] |
a5921ad2eb99
sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33293
diff
changeset
|
71 tools/tests/** |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
72 """ |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
73 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
74 from __future__ import absolute_import |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
75 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
76 from mercurial.i18n import _ |
43087
66f2cc210a29
py3: manually import pycompat.setattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
77 from mercurial.pycompat import setattr |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
78 from mercurial import ( |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
79 cmdutil, |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
80 commands, |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
81 dirstate, |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
82 error, |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
83 extensions, |
35885
7625b4f7db70
cmdutil: split functions of log-like commands to new module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
35192
diff
changeset
|
84 logcmdutil, |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
85 match as matchmod, |
45577
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45565
diff
changeset
|
86 merge as mergemod, |
35192
d8d06a930d60
py3: use byteskwargs in sparse.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33685
diff
changeset
|
87 pycompat, |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
88 registrar, |
33297
ba5d89774db6
sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33296
diff
changeset
|
89 sparse, |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
90 util, |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
91 ) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
92 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
93 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
94 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
95 # be specifying the version(s) of Mercurial they are tested with, or |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 # leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
97 testedwith = b'ships-with-hg-core' |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
99 cmdtable = {} |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
100 command = registrar.command(cmdtable) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
102 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 def extsetup(ui): |
33299
41448fc51510
sparse: variable to track if sparse is enabled
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33298
diff
changeset
|
104 sparse.enabled = True |
41448fc51510
sparse: variable to track if sparse is enabled
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33298
diff
changeset
|
105 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
106 _setupclone(ui) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
107 _setuplog(ui) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
108 _setupadd(ui) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 _setupdirstate(ui) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
110 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
111 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
112 def replacefilecache(cls, propname, replacement): |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
113 """Replace a filecache property with a new class. This allows changing the |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
114 cache invalidation condition.""" |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 origcls = cls |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 assert callable(replacement) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
117 while cls is not object: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 if propname in cls.__dict__: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 orig = cls.__dict__[propname] |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
120 setattr(cls, propname, replacement(orig)) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 break |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 cls = cls.__bases__[0] |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
124 if cls is object: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
125 raise AttributeError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
126 _(b"type '%s' has no property '%s'") % (origcls, propname) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
127 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
128 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
129 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
130 def _setuplog(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 entry = commands.table[b'log|history'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
132 entry[1].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
133 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
134 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
135 b'sparse', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
136 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 b"limit to changesets affecting the sparse checkout", |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
138 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
139 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
140 |
45565
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
44452
diff
changeset
|
141 def _initialrevs(orig, repo, wopts): |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
44452
diff
changeset
|
142 revs = orig(repo, wopts) |
c1d0f83d62c4
log: introduce struct that carries log traversal options
Yuya Nishihara <yuya@tcha.org>
parents:
44452
diff
changeset
|
143 if wopts.opts.get(b'sparse'): |
33320
153456f02426
sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33319
diff
changeset
|
144 sparsematch = sparse.matcher(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
145 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
146 def ctxmatch(rev): |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
147 ctx = repo[rev] |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
148 return any(f for f in ctx.files() if sparsematch(f)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
149 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
150 revs = revs.filter(ctxmatch) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
151 return revs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
152 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
153 extensions.wrapfunction(logcmdutil, b'_initialrevs', _initialrevs) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
154 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
155 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
156 def _clonesparsecmd(orig, ui, repo, *args, **opts): |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
157 include = opts.get('include') |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
158 exclude = opts.get('exclude') |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
159 enableprofile = opts.get('enable_profile') |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43087
diff
changeset
|
160 narrow_pat = opts.get('narrow') |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
161 |
41148
8eaf693b1409
sparse: don't enable on clone if it was a narrow clone
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40295
diff
changeset
|
162 # if --narrow is passed, it means they are includes and excludes for narrow |
8eaf693b1409
sparse: don't enable on clone if it was a narrow clone
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40295
diff
changeset
|
163 # clone |
8eaf693b1409
sparse: don't enable on clone if it was a narrow clone
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40295
diff
changeset
|
164 if not narrow_pat and (include or exclude or enableprofile): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
165 |
45577
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45565
diff
changeset
|
166 def clonesparse(orig, ctx, *args, **kwargs): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
167 sparse.updateconfig( |
45577
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45565
diff
changeset
|
168 ctx.repo().unfiltered(), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
169 {}, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
170 include=include, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
171 exclude=exclude, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
172 enableprofile=enableprofile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
173 usereporootpaths=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
174 ) |
45577
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45565
diff
changeset
|
175 return orig(ctx, *args, **kwargs) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
176 |
45577
5c8230ca37f2
merge: replace calls to hg.updaterepo() by merge.update()
Martin von Zweigbergk <martinvonz@google.com>
parents:
45565
diff
changeset
|
177 extensions.wrapfunction(mergemod, b'update', clonesparse) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
178 return orig(ui, repo, *args, **opts) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
179 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
180 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
181 def _setupclone(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
182 entry = commands.table[b'clone'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
183 entry[1].append((b'', b'enable-profile', [], b'enable a sparse profile')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
184 entry[1].append((b'', b'include', [], b'include sparse pattern')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
185 entry[1].append((b'', b'exclude', [], b'exclude sparse pattern')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
186 extensions.wrapcommand(commands.table, b'clone', _clonesparsecmd) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
187 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
188 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
189 def _setupadd(ui): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
190 entry = commands.table[b'add'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
191 entry[1].append( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
192 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
193 b's', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
194 b'sparse', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
195 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
196 b'also include directories of added files in sparse config', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
197 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
198 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
199 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
200 def _add(orig, ui, repo, *pats, **opts): |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43087
diff
changeset
|
201 if opts.get('sparse'): |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
202 dirs = set() |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
203 for pat in pats: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
204 dirname, basename = util.split(pat) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
205 dirs.add(dirname) |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
206 sparse.updateconfig(repo, opts, include=list(dirs)) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
207 return orig(ui, repo, *pats, **opts) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
208 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
209 extensions.wrapcommand(commands.table, b'add', _add) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
210 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
211 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
212 def _setupdirstate(ui): |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
213 """Modify the dirstate to prevent stat'ing excluded files, |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
214 and to prevent modifications to files outside the checkout. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
215 """ |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
216 |
33496
258298f4712b
sparse: override dirstate.walk() instead of dirstate._ignore
Martin von Zweigbergk <martinvonz@google.com>
parents:
33374
diff
changeset
|
217 def walk(orig, self, match, subrepos, unknown, ignored, full=True): |
36200
deb851914fd7
dirstate: drop explicit files that shouldn't match (BC) (issue4679)
Yuya Nishihara <yuya@tcha.org>
parents:
35887
diff
changeset
|
218 # hack to not exclude explicitly-specified paths so that they can |
deb851914fd7
dirstate: drop explicit files that shouldn't match (BC) (issue4679)
Yuya Nishihara <yuya@tcha.org>
parents:
35887
diff
changeset
|
219 # be warned later on e.g. dirstate.add() |
41676
0531dff73d0b
match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
41675
diff
changeset
|
220 em = matchmod.exact(match.files()) |
36200
deb851914fd7
dirstate: drop explicit files that shouldn't match (BC) (issue4679)
Yuya Nishihara <yuya@tcha.org>
parents:
35887
diff
changeset
|
221 sm = matchmod.unionmatcher([self._sparsematcher, em]) |
deb851914fd7
dirstate: drop explicit files that shouldn't match (BC) (issue4679)
Yuya Nishihara <yuya@tcha.org>
parents:
35887
diff
changeset
|
222 match = matchmod.intersectmatchers(match, sm) |
33496
258298f4712b
sparse: override dirstate.walk() instead of dirstate._ignore
Martin von Zweigbergk <martinvonz@google.com>
parents:
33374
diff
changeset
|
223 return orig(self, match, subrepos, unknown, ignored, full) |
33320
153456f02426
sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33319
diff
changeset
|
224 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
225 extensions.wrapfunction(dirstate.dirstate, b'walk', walk) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
226 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
227 # dirstate.rebuild should not add non-matching files |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
228 def _rebuild(orig, self, parent, allfiles, changedfiles=None): |
33373
fb320398a21c
dirstate: expose a sparse matcher on dirstate (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33372
diff
changeset
|
229 matcher = self._sparsematcher |
33320
153456f02426
sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33319
diff
changeset
|
230 if not matcher.always(): |
41150
b05eb98a6b67
sparse: fix debugrebuilddirsate when narrow extension is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41148
diff
changeset
|
231 allfiles = [f for f in allfiles if matcher(f)] |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
232 if changedfiles: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
233 changedfiles = [f for f in changedfiles if matcher(f)] |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
234 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
235 if changedfiles is not None: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
236 # In _rebuild, these files will be deleted from the dirstate |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
237 # when they are not found to be in allfiles |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
43506
diff
changeset
|
238 dirstatefilestoremove = {f for f in self if not matcher(f)} |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
239 changedfiles = dirstatefilestoremove.union(changedfiles) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
240 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
241 return orig(self, parent, allfiles, changedfiles) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
242 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
243 extensions.wrapfunction(dirstate.dirstate, b'rebuild', _rebuild) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
244 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
245 # Prevent adding files that are outside the sparse checkout |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 editfuncs = [ |
47593
f927ad5a4e2c
dirstate: add a `set_tracked` method for "hg add"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45577
diff
changeset
|
247 b'set_tracked', |
47599
cce51119bfe6
dirstate: add a `set_untracked` method for "hg remove"-like usage
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47593
diff
changeset
|
248 b'set_untracked', |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
249 b'copy', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
250 ] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
251 hint = _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 b'include file with `hg debugsparse --include <pattern>` or use ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
253 + b'`hg add -s <file>` to include file directory while adding' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
254 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
255 for func in editfuncs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
256 |
42456
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
41988
diff
changeset
|
257 def _wrapper(orig, self, *args, **kwargs): |
33373
fb320398a21c
dirstate: expose a sparse matcher on dirstate (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33372
diff
changeset
|
258 sparsematch = self._sparsematcher |
33320
153456f02426
sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33319
diff
changeset
|
259 if not sparsematch.always(): |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
260 for f in args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
261 if f is not None and not sparsematch(f) and f not in self: |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
262 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
263 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
264 b"cannot add '%s' - it is outside " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
265 b"the sparse checkout" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
266 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
267 % f, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
268 hint=hint, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
269 ) |
42456
87a34c767384
merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
41988
diff
changeset
|
270 return orig(self, *args, **kwargs) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
271 |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
272 extensions.wrapfunction(dirstate.dirstate, func, _wrapper) |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
273 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
274 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
275 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
276 b'debugsparse', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
277 [ |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
278 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
279 b'I', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
280 b'include', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
281 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
282 _(b'include files in the sparse checkout'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
283 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
284 ), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
285 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
286 b'X', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
287 b'exclude', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
288 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
289 _(b'exclude files in the sparse checkout'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
290 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
291 ), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
292 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
293 b'd', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
294 b'delete', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
295 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
296 _(b'delete an include/exclude rule'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
297 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
298 ), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
299 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
300 b'f', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
301 b'force', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
302 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
303 _(b'allow changing rules even with pending changes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
304 ), |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
305 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
306 b'', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
307 b'enable-profile', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
308 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
309 _(b'enables the specified profile'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
310 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
311 ), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
312 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
313 b'', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
314 b'disable-profile', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
315 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
316 _(b'disables the specified profile'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
317 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
318 ), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
319 ( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
320 b'', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
321 b'import-rules', |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
322 [], |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
323 _(b'imports rules from a file'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
324 _(b'PATTERN'), |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
325 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
326 (b'', b'clear-rules', False, _(b'clears local include/exclude rules')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
327 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
328 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
329 b'refresh', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
330 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
331 _(b'updates the working after sparseness changes'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
332 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
333 (b'', b'reset', False, _(b'makes the repo full again')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
334 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
335 + commands.templateopts, |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
336 _(b'[--OPTION]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
337 helpbasic=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
338 ) |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
339 def debugsparse(ui, repo, **opts): |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
340 """make the current checkout sparse, or edit the existing checkout |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
341 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
342 The sparse command is used to make the current checkout sparse. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
343 This means files that don't meet the sparse condition will not be |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
344 written to disk, or show up in any working copy operations. It does |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
345 not affect files in history in any way. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
346 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
347 Passing no arguments prints the currently applied sparse rules. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
348 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
349 --include and --exclude are used to add and remove files from the sparse |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
350 checkout. The effects of adding an include or exclude rule are applied |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
351 immediately. If applying the new rule would cause a file with pending |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
352 changes to be added or removed, the command will fail. Pass --force to |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
353 force a rule change even with pending changes (the changes on disk will |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
354 be preserved). |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
355 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
356 --delete removes an existing include/exclude rule. The effects are |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
357 immediate. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
358 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
359 --refresh refreshes the files on disk based on the sparse rules. This is |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
360 only necessary if .hg/sparse was changed by hand. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
361 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
362 --enable-profile and --disable-profile accept a path to a .hgsparse file. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
363 This allows defining sparse checkouts and tracking them inside the |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
364 repository. This is useful for defining commonly used sparse checkouts for |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
365 many people to use. As the profile definition changes over time, the sparse |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
366 checkout will automatically be updated appropriately, depending on which |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
367 changeset is checked out. Changes to .hgsparse are not applied until they |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
368 have been committed. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
369 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
370 --import-rules accepts a path to a file containing rules in the .hgsparse |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
371 format, allowing you to add --include, --exclude and --enable-profile rules |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
372 in bulk. Like the --include, --exclude and --enable-profile switches, the |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
373 changes are applied immediately. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
374 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
375 --clear-rules removes all local include and exclude rules, while leaving |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
376 any enabled profiles in place. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
377 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
378 Returns 0 if editing the sparse checkout succeeds. |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
379 """ |
35192
d8d06a930d60
py3: use byteskwargs in sparse.py
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33685
diff
changeset
|
380 opts = pycompat.byteskwargs(opts) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
381 include = opts.get(b'include') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
382 exclude = opts.get(b'exclude') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
383 force = opts.get(b'force') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
384 enableprofile = opts.get(b'enable_profile') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
385 disableprofile = opts.get(b'disable_profile') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
386 importrules = opts.get(b'import_rules') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 clearrules = opts.get(b'clear_rules') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
388 delete = opts.get(b'delete') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
389 refresh = opts.get(b'refresh') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
390 reset = opts.get(b'reset') |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
391 action = cmdutil.check_at_most_one_arg( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
392 opts, b'import_rules', b'clear_rules', b'refresh' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
393 ) |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
394 updateconfig = bool( |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
395 include or exclude or delete or reset or enableprofile or disableprofile |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
396 ) |
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
397 count = sum([updateconfig, bool(action)]) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
398 if count > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
399 raise error.Abort(_(b"too many flags specified")) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
400 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
401 if count == 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
402 if repo.vfs.exists(b'sparse'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
403 ui.status(repo.vfs.read(b"sparse") + b"\n") |
33304
3e1accab7447
sparse: move some temporary includes functions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33303
diff
changeset
|
404 temporaryincludes = sparse.readtemporaryincludes(repo) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
405 if temporaryincludes: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
406 ui.status( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
407 _(b"Temporarily Included Files (for merge/rebase):\n") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
408 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
409 ui.status((b"\n".join(temporaryincludes) + b"\n")) |
41988
f9344d04909e
debugsparse: abort if the repository is not sparse instead of ui.status()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41676
diff
changeset
|
410 return |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
411 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
412 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
413 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 b'the debugsparse command is only supported on' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 b' sparse repositories' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
416 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
417 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
418 |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
419 if updateconfig: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
420 sparse.updateconfig( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
421 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
422 opts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
423 include=include, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
424 exclude=exclude, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
425 reset=reset, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
426 delete=delete, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
427 enableprofile=enableprofile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
428 disableprofile=disableprofile, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
429 force=force, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
430 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
431 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
432 if importrules: |
48737
a6efb9180764
sparse: rework debugsparse's interface
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
47914
diff
changeset
|
433 sparse.importfromfiles(repo, opts, importrules, force=force) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
434 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
435 if clearrules: |
33354
4695f1829045
sparse: move code for clearing rules to core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33353
diff
changeset
|
436 sparse.clearrules(repo, force=force) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
437 |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
438 if refresh: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
439 try: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
440 wlock = repo.wlock() |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
441 fcounts = map( |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
442 len, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
443 sparse.refreshwdir( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
444 repo, repo.status(), sparse.matcher(repo), force=force |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
445 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
446 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
447 sparse.printchanges( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
448 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
449 opts, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
450 added=fcounts[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
451 dropped=fcounts[1], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
452 conflicting=fcounts[2], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42456
diff
changeset
|
453 ) |
33289
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
454 finally: |
abd7dedbaa36
sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
455 wlock.release() |