Mercurial > hg
annotate hgext/narrow/narrowcommands.py @ 50750:fa2eca7423f3 stable
Added signature for changeset 3ffc7209bbae
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 06 Jul 2023 16:04:36 +0200 |
parents | e5c1e7aec973 |
children | 584fc92dd8d7 |
rev | line source |
---|---|
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 # narrowcommands.py - command modifications for narrowhg extension |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 # |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 # Copyright 2017 Google, Inc. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 # |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
7 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 import itertools |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
9 import os |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 from mercurial.i18n import _ |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
12 from mercurial.node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
13 hex, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
14 short, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
15 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 from mercurial import ( |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
17 bundle2, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 cmdutil, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 commands, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 discovery, |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
21 encoding, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 error, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
23 exchange, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 extensions, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
25 hg, |
36160
9fd8c2a3db5a
narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36154
diff
changeset
|
26 narrowspec, |
43523
c21aca51b392
utils: move the `dirs` definition in pathutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43506
diff
changeset
|
27 pathutil, |
36154
4a7ba3ac9163
narrowcommands: use pycompat.{bytes,str}kwargs
Augie Fackler <augie@google.com>
parents:
36100
diff
changeset
|
28 pycompat, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
29 registrar, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 repair, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
31 repoview, |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43523
diff
changeset
|
32 requirements, |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
33 sparse, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 util, |
40074
f7011b44d205
wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40070
diff
changeset
|
35 wireprototypes, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 ) |
46907
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46895
diff
changeset
|
37 from mercurial.utils import ( |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46895
diff
changeset
|
38 urlutil, |
ffd3e823a7e5
urlutil: extract `url` related code from `util` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46895
diff
changeset
|
39 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
41 table = {} |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
42 command = registrar.command(table) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
43 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
44 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
45 def setup(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
46 """Wraps user-facing mercurial commands with narrow-aware versions.""" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
47 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
48 entry = extensions.wrapcommand(commands.table, b'clone', clonenarrowcmd) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
49 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
50 (b'', b'narrow', None, _(b"create a narrow clone of select files")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
51 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
52 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
53 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
54 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
55 b'depth', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
56 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
57 _(b"limit the history fetched by distance from heads"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
58 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
59 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
60 entry[1].append((b'', b'narrowspec', b'', _(b"read narrowspecs from file"))) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 if b'sparse' not in extensions.enabled(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
63 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
64 (b'', b'include', [], _(b"specifically fetch this file/directory")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
65 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 entry[1].append( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
67 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
68 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
69 b'exclude', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
70 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
71 _(b"do not fetch this file/directory, even if included"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
72 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
73 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
75 entry = extensions.wrapcommand(commands.table, b'pull', pullnarrowcmd) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
76 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
77 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
78 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 b'depth', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
80 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
81 _(b"limit the history fetched by distance from heads"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
82 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
83 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
84 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
85 extensions.wrapcommand(commands.table, b'archive', archivenarrowcmd) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
87 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 def clonenarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 """Wraps clone command, so 'hg clone' first wraps localrepo.clone().""" |
36154
4a7ba3ac9163
narrowcommands: use pycompat.{bytes,str}kwargs
Augie Fackler <augie@google.com>
parents:
36100
diff
changeset
|
90 opts = pycompat.byteskwargs(opts) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 wrappedextraprepare = util.nullcontextmanager() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
92 narrowspecfile = opts[b'narrowspec'] |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
93 |
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
94 if narrowspecfile: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39734
diff
changeset
|
95 filepath = os.path.join(encoding.getcwd(), narrowspecfile) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
96 ui.status(_(b"reading narrowspec from '%s'\n") % filepath) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
97 try: |
39465
4062bbb1d10f
narrow: use util.readfile() and improve error message using --narrowspec
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39440
diff
changeset
|
98 fdata = util.readfile(filepath) |
4062bbb1d10f
narrow: use util.readfile() and improve error message using --narrowspec
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39440
diff
changeset
|
99 except IOError as inst: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
100 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
101 _(b"cannot read narrowspecs from '%s': %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
102 % (filepath, encoding.strtolocal(inst.strerror)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
103 ) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
104 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
105 includes, excludes, profiles = sparse.parseconfig(ui, fdata, b'narrow') |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
106 if profiles: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
107 raise error.ConfigError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
108 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
109 b"cannot specify other files using '%include' in" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
110 b" narrowspec" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
111 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
112 ) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
113 |
39541
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
114 narrowspec.validatepatterns(includes) |
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
115 narrowspec.validatepatterns(excludes) |
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
116 |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
117 # narrowspec is passed so we should assume that user wants narrow clone |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
118 opts[b'narrow'] = True |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
119 opts[b'include'].extend(includes) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
120 opts[b'exclude'].extend(excludes) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
121 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 if opts[b'narrow']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
123 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
127 if opts.get(b'depth'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
128 kwargs[b'depth'] = opts[b'depth'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
129 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
130 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
131 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
132 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 |
39554
841c82d1a973
narrow: don't wrap exchange.pull() during clone
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39545
diff
changeset
|
134 with wrappedextraprepare: |
36154
4a7ba3ac9163
narrowcommands: use pycompat.{bytes,str}kwargs
Augie Fackler <augie@google.com>
parents:
36100
diff
changeset
|
135 return orig(ui, repo, *args, **pycompat.strkwargs(opts)) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
137 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 def pullnarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 """Wraps pull command to allow modifying narrow spec.""" |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 wrappedextraprepare = util.nullcontextmanager() |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43523
diff
changeset
|
141 if requirements.NARROW_REQUIREMENT in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 orig(pullop, kwargs) |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
145 if opts.get('depth'): |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
146 kwargs[b'depth'] = opts['depth'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
147 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
148 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
149 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
150 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 with wrappedextraprepare: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 return orig(ui, repo, *args, **opts) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
155 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 def archivenarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 """Wraps archive command to narrow the default includes.""" |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43523
diff
changeset
|
158 if requirements.NARROW_REQUIREMENT in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 repo_includes, repo_excludes = repo.narrowpats |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
160 includes = set(opts.get('include', [])) |
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
161 excludes = set(opts.get('exclude', [])) |
36100
8fd0a9e2d7e9
narrow: make restrictpatterns a little more idiomatic
Augie Fackler <augie@google.com>
parents:
36088
diff
changeset
|
162 includes, excludes, unused_invalid = narrowspec.restrictpatterns( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
163 includes, excludes, repo_includes, repo_excludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
164 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 if includes: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
166 opts['include'] = includes |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 if excludes: |
43506
9f70512ae2cf
cleanup: remove pointless r-prefixes on single-quoted strings
Augie Fackler <augie@google.com>
parents:
43181
diff
changeset
|
168 opts['exclude'] = excludes |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 return orig(ui, repo, *args, **opts) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
171 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 def pullbundle2extraprepare(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
173 repo = pullop.repo |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43523
diff
changeset
|
174 if requirements.NARROW_REQUIREMENT not in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 return orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
176 |
40074
f7011b44d205
wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40070
diff
changeset
|
177 if wireprototypes.NARROWCAP not in pullop.remote.capabilities(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
178 raise error.Abort(_(b"server does not support narrow clones")) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 orig(pullop, kwargs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
180 kwargs[b'narrow'] = True |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 include, exclude = repo.narrowpats |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
182 kwargs[b'oldincludepats'] = include |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
183 kwargs[b'oldexcludepats'] = exclude |
40493
a2c4502e409b
narrow: only send includepats and excludepats if they are not empty
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40438
diff
changeset
|
184 if include: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
185 kwargs[b'includepats'] = include |
40493
a2c4502e409b
narrow: only send includepats and excludepats if they are not empty
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40438
diff
changeset
|
186 if exclude: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
187 kwargs[b'excludepats'] = exclude |
39524
294c571490f0
narrow: build the known set of nodes only when ellipses is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39465
diff
changeset
|
188 # calculate known nodes only in ellipses cases because in non-ellipses cases |
294c571490f0
narrow: build the known set of nodes only when ellipses is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39465
diff
changeset
|
189 # we have all the nodes |
42415
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
190 if wireprototypes.ELLIPSESCAP1 in pullop.remote.capabilities(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
191 kwargs[b'known'] = [ |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
192 hex(ctx.node()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
193 for ctx in repo.set(b'::%ln', pullop.common) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46937
diff
changeset
|
194 if ctx.node() != repo.nullid |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
195 ] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
196 if not kwargs[b'known']: |
39524
294c571490f0
narrow: build the known set of nodes only when ellipses is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39465
diff
changeset
|
197 # Mercurial serializes an empty list as '' and deserializes it as |
294c571490f0
narrow: build the known set of nodes only when ellipses is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39465
diff
changeset
|
198 # [''], so delete it instead to avoid handling the empty string on |
294c571490f0
narrow: build the known set of nodes only when ellipses is enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39465
diff
changeset
|
199 # the server. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
200 del kwargs[b'known'] |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
202 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
203 extensions.wrapfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
204 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
205 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
206 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
208 def _narrow( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
209 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
210 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
211 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
212 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
213 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
214 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
215 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
216 newexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
217 force, |
46477
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
218 backup, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
219 ): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 newmatch = narrowspec.match(repo.root, newincludes, newexcludes) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 # This is essentially doing "hg outgoing" to find all local-only |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
224 # commits. We will then check that the local-only commits don't |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 # have any changes to files that will be untracked. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
226 unfi = repo.unfiltered() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
227 outgoing = discovery.findcommonoutgoing(unfi, remote, commoninc=commoninc) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
228 ui.status(_(b'looking for local changes to affected paths\n')) |
47025
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
229 progress = ui.makeprogress( |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
230 topic=_(b'changesets'), |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
231 unit=_(b'changesets'), |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
232 total=len(outgoing.missing) + len(outgoing.excluded), |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
233 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 localnodes = [] |
47025
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
235 with progress: |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
236 for n in itertools.chain(outgoing.missing, outgoing.excluded): |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
237 progress.increment() |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
238 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()): |
124fe94016c0
narrow: add progress-reporting when looking for local changes in `hg tracked`
Martin von Zweigbergk <martinvonz@google.com>
parents:
47012
diff
changeset
|
239 localnodes.append(n) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
240 revstostrip = unfi.revs(b'descendants(%ln)', localnodes) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
241 hiddenrevs = repoview.filterrevs(repo, b'visible') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
242 visibletostrip = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
243 repo.changelog.node(r) for r in (revstostrip - hiddenrevs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
244 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 if visibletostrip: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
246 ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
247 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
248 b'The following changeset(s) or their ancestors have ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
249 b'local changes not on the remote:\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
250 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
251 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
252 maxnodes = 10 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 if ui.verbose or len(visibletostrip) <= maxnodes: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 for n in visibletostrip: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
255 ui.status(b'%s\n' % short(n)) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
257 for n in visibletostrip[:maxnodes]: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
258 ui.status(b'%s\n' % short(n)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
259 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
260 _(b'...and %d more, use --verbose to list all\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
261 % (len(visibletostrip) - maxnodes) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
262 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 if not force: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
264 raise error.StateError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
265 _(b'local changes found'), |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
266 hint=_(b'use --force-delete-local-changes to ignore'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
267 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
41043
diff
changeset
|
269 with ui.uninterruptible(): |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
270 if revstostrip: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
271 tostrip = [unfi.changelog.node(r) for r in revstostrip] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
272 if repo[b'.'].node() in tostrip: |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
273 # stripping working copy, so move to a different commit first |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
274 urev = max( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
275 repo.revs( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
276 b'(::%n) - %ln + null', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
277 repo[b'.'].node(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 visibletostrip, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
279 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
280 ) |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
281 hg.clean(repo, urev) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
282 overrides = {(b'devel', b'strip-obsmarkers'): False} |
47026
20eba5cef2e0
narrow: add more status messages when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
47025
diff
changeset
|
283 if backup: |
20eba5cef2e0
narrow: add more status messages when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
47025
diff
changeset
|
284 ui.status(_(b'moving unwanted changesets to backup\n')) |
20eba5cef2e0
narrow: add more status messages when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
47025
diff
changeset
|
285 else: |
20eba5cef2e0
narrow: add more status messages when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
47025
diff
changeset
|
286 ui.status(_(b'deleting unwanted changesets\n')) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 with ui.configoverride(overrides, b'narrow'): |
46477
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
288 repair.strip(ui, unfi, tostrip, topic=b'narrow', backup=backup) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
289 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
290 todelete = [] |
50504
862e3a13da44
store: rename `datafiles` to `data_entries`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50499
diff
changeset
|
291 for entry in repo.store.data_entries(): |
50484
17a822d7943e
store: use StoreEntry API instead of parsing filename in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50472
diff
changeset
|
292 if not entry.is_revlog: |
17a822d7943e
store: use StoreEntry API instead of parsing filename in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50472
diff
changeset
|
293 continue |
50499
7a1a0a236187
store: use the new boolean property in `narrow`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50484
diff
changeset
|
294 if entry.is_filelog: |
50484
17a822d7943e
store: use StoreEntry API instead of parsing filename in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50472
diff
changeset
|
295 if not newmatch(entry.target_id): |
50472
9fdc28e21b68
store: introduce a EntryFile object to actually access file info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
296 for file_ in entry.files(): |
9fdc28e21b68
store: introduce a EntryFile object to actually access file info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
297 todelete.append(file_.unencoded_path) |
50499
7a1a0a236187
store: use the new boolean property in `narrow`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50484
diff
changeset
|
298 elif entry.is_manifestlog: |
50484
17a822d7943e
store: use StoreEntry API instead of parsing filename in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50472
diff
changeset
|
299 dir = entry.target_id |
43523
c21aca51b392
utils: move the `dirs` definition in pathutil (API)
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43506
diff
changeset
|
300 dirs = sorted(pathutil.dirs({dir})) + [dir] |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
301 include = True |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
302 for d in dirs: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
303 visit = newmatch.visitdir(d) |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
304 if not visit: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
305 include = False |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
306 break |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 if visit == b'all': |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
308 break |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
309 if not include: |
50472
9fdc28e21b68
store: introduce a EntryFile object to actually access file info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
310 for file_ in entry.files(): |
9fdc28e21b68
store: introduce a EntryFile object to actually access file info
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50471
diff
changeset
|
311 todelete.append(file_.unencoded_path) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
312 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
313 repo.destroying() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
314 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
315 with repo.transaction(b'narrowing'): |
41028
095a0a63ad88
narrow: when narrowing, write new narrowspec before removing revlogs
Martin von Zweigbergk <martinvonz@google.com>
parents:
41027
diff
changeset
|
316 # Update narrowspec before removing revlogs, so repo won't be |
095a0a63ad88
narrow: when narrowing, write new narrowspec before removing revlogs
Martin von Zweigbergk <martinvonz@google.com>
parents:
41027
diff
changeset
|
317 # corrupt in case of crash |
095a0a63ad88
narrow: when narrowing, write new narrowspec before removing revlogs
Martin von Zweigbergk <martinvonz@google.com>
parents:
41027
diff
changeset
|
318 repo.setnarrowpats(newincludes, newexcludes) |
095a0a63ad88
narrow: when narrowing, write new narrowspec before removing revlogs
Martin von Zweigbergk <martinvonz@google.com>
parents:
41027
diff
changeset
|
319 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
320 for f in todelete: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
321 ui.status(_(b'deleting %s\n') % f) |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
322 util.unlinkpath(repo.svfs.join(f)) |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
323 repo.store.markremoved(f) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
324 |
47026
20eba5cef2e0
narrow: add more status messages when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
47025
diff
changeset
|
325 ui.status(_(b'deleting unwanted files from working copy\n')) |
49961
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
326 with repo.dirstate.changing_parents(repo): |
47604
090fc6a95e50
narrow: update narrow spec within a dirstate.parentchange context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47026
diff
changeset
|
327 narrowspec.updateworkingcopy(repo, assumeclean=True) |
090fc6a95e50
narrow: update narrow spec within a dirstate.parentchange context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47026
diff
changeset
|
328 narrowspec.copytoworkingcopy(repo) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
329 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
330 repo.destroyed() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
331 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
332 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
333 def _widen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
334 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
335 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
336 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
337 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
338 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
339 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
340 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
341 newexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
342 ): |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
343 # for now we assume that if a server has ellipses enabled, we will be |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
344 # exchanging ellipses nodes. In future we should add ellipses as a client |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
345 # side requirement (maybe) to distinguish a client is shallow or not and |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
346 # then send that information to server whether we want ellipses or not. |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
347 # Theoretically a non-ellipses repo should be able to use narrow |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
348 # functionality from an ellipses enabled server |
42415
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
349 remotecap = remote.capabilities() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
350 ellipsesremote = any( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
351 cap in remotecap for cap in wireprototypes.SUPPORTED_ELLIPSESCAP |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
352 ) |
42415
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
353 |
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
354 # check whether we are talking to a server which supports old version of |
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
355 # ellipses capabilities |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
356 isoldellipses = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
357 ellipsesremote |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
358 and wireprototypes.ELLIPSESCAP1 in remotecap |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
359 and wireprototypes.ELLIPSESCAP not in remotecap |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
360 ) |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
361 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
362 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
363 orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
364 # The old{in,ex}cludepats have already been set by orig() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
365 kwargs[b'includepats'] = newincludes |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
366 kwargs[b'excludepats'] = newexcludes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
367 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
368 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
369 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
370 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
371 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
372 # define a function that narrowbundle2 can call after creating the |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
373 # backup bundle, but before applying the bundle from the server |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
374 def setnewnarrowpats(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
375 repo.setnarrowpats(newincludes, newexcludes) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
376 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
377 repo.setnewnarrowpats = setnewnarrowpats |
39673
f1844a10ee19
narrow: don't send the changelog information when widening without ellipses
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39555
diff
changeset
|
378 # silence the devel-warning of applying an empty changegroup |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
379 overrides = {(b'devel', b'all-warnings'): False} |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
380 |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
381 common = commoninc[0] |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
41043
diff
changeset
|
382 with ui.uninterruptible(): |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
383 if ellipsesremote: |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
384 ds = repo.dirstate |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
385 p1, p2 = ds.p1(), ds.p2() |
49961
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
386 with ds.changing_parents(repo): |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46937
diff
changeset
|
387 ds.setparents(repo.nullid, repo.nullid) |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
388 if isoldellipses: |
41760
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41723
diff
changeset
|
389 with wrappedextraprepare: |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
390 exchange.pull(repo, remote, heads=common) |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
391 else: |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
392 known = [] |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
393 if ellipsesremote: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
394 known = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
395 ctx.node() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 for ctx in repo.set(b'::%ln', common) |
47012
d55b71393907
node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46937
diff
changeset
|
397 if ctx.node() != repo.nullid |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
398 ] |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
399 with remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
400 bundle = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
401 b'narrow_widen', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
402 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
403 b'oldincludes': oldincludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
404 b'oldexcludes': oldexcludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
405 b'newincludes': newincludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
406 b'newexcludes': newexcludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
407 b'cgversion': b'03', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
408 b'commonheads': common, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
409 b'known': known, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
410 b'ellipses': ellipsesremote, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
411 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
412 ).result() |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
413 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
414 trmanager = exchange.transactionmanager( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 repo, b'widen', remote.url() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
417 with trmanager, repo.ui.configoverride(overrides, b'widen'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
418 op = bundle2.bundleoperation( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
419 repo, trmanager.transaction, source=b'widen' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
420 ) |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
421 # TODO: we should catch error.Abort here |
49765
4188e75af983
bundleoperation: optionnaly record the `remote` that produced the bundle
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49732
diff
changeset
|
422 bundle2.processbundle(repo, bundle, op=op, remote=remote) |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
423 |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
424 if ellipsesremote: |
49961
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
425 with ds.changing_parents(repo): |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
426 ds.setparents(p1, p2) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
427 |
49961
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
428 with repo.transaction(b'widening'), repo.dirstate.changing_parents( |
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
429 repo |
7a8bfc05b691
dirstate: rename parentchange to changing_parents
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49960
diff
changeset
|
430 ): |
41237
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
431 repo.setnewnarrowpats() |
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
432 narrowspec.updateworkingcopy(repo) |
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
433 narrowspec.copytoworkingcopy(repo) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
434 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
435 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
436 # TODO(rdamazio): Make new matcher format and update description |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
437 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
438 b'tracked', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
439 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
440 (b'', b'addinclude', [], _(b'new paths to include')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
441 (b'', b'removeinclude', [], _(b'old paths to no longer include')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
442 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
443 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
444 b'auto-remove-includes', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
445 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
446 _(b'automatically choose unused includes to remove'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
447 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
448 (b'', b'addexclude', [], _(b'new paths to exclude')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
449 (b'', b'import-rules', b'', _(b'import narrowspecs from a file')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
450 (b'', b'removeexclude', [], _(b'old paths to no longer exclude')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
451 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
452 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
453 b'clear', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
454 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
455 _(b'whether to replace the existing narrowspec'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
456 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
457 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
458 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
459 b'force-delete-local-changes', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
460 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
461 _(b'forces deletion of local changes when narrowing'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
462 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
463 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
464 b'', |
46477
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
465 b'backup', |
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
466 True, |
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
467 _(b'back up local changes when narrowing'), |
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
468 ), |
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
469 ( |
3c360ab2688d
narrow: add --no-backup option for narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
46117
diff
changeset
|
470 b'', |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
471 b'update-working-copy', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
473 _(b'update working copy when the store has changed'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
474 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
475 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
476 + commands.remoteopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
477 _(b'[OPTIONS]... [REMOTE]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
478 inferrepo=True, |
43181
5ff32fdf0b0b
help: adding a help category to narrow and remotefilelog commands
Rodrigo Damazio <rdamazio@google.com>
parents:
43117
diff
changeset
|
479 helpcategory=command.CATEGORY_MAINTENANCE, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
480 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
481 def trackedcmd(ui, repo, remotepath=None, *pats, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
482 """show or change the current narrowspec |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
483 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
484 With no argument, shows the current narrowspec entries, one per line. Each |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
485 line will be prefixed with 'I' or 'X' for included or excluded patterns, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
486 respectively. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
487 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
488 The narrowspec is comprised of expressions to match remote files and/or |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
489 directories that should be pulled into your client. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
490 The narrowspec has *include* and *exclude* expressions, with excludes always |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
491 trumping includes: that is, if a file matches an exclude expression, it will |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
492 be excluded even if it also matches an include expression. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
493 Excluding files that were never included has no effect. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
494 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
495 Each included or excluded entry is in the format described by |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
496 'hg help patterns'. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
497 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
498 The options allow you to add or remove included and excluded expressions. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
499 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
500 If --clear is specified, then all previous includes and excludes are DROPPED |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
501 and replaced by the new ones specified to --addinclude and --addexclude. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
502 If --clear is specified without any further options, the narrowspec will be |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
503 empty and will not match any files. |
41980
6cad258e1348
tracked: add documentation about `--import-rules` flag
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41760
diff
changeset
|
504 |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
505 If --auto-remove-includes is specified, then those includes that don't match |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
506 any files modified by currently visible local commits (those not shared by |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
507 the remote) will be added to the set of explicitly specified includes to |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
508 remove. |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
509 |
41980
6cad258e1348
tracked: add documentation about `--import-rules` flag
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41760
diff
changeset
|
510 --import-rules accepts a path to a file containing rules, allowing you to |
6cad258e1348
tracked: add documentation about `--import-rules` flag
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41760
diff
changeset
|
511 add --addinclude, --addexclude rules in bulk. Like the other include and |
6cad258e1348
tracked: add documentation about `--import-rules` flag
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41760
diff
changeset
|
512 exclude switches, the changes are applied immediately. |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
513 """ |
36166
ccf7ae119769
narrowcommands: more byteskwargs cleanup
Augie Fackler <augie@google.com>
parents:
36160
diff
changeset
|
514 opts = pycompat.byteskwargs(opts) |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
43523
diff
changeset
|
515 if requirements.NARROW_REQUIREMENT not in repo.requirements: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
516 raise error.InputError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
517 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
518 b'the tracked command is only supported on ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
519 b'repositories cloned with --narrow' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
520 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
521 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
522 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
523 # Before supporting, decide whether it "hg tracked --clear" should mean |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
524 # tracking no paths or all paths. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
525 if opts[b'clear']: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
526 raise error.InputError(_(b'the --clear option is not yet supported')) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
527 |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
528 # import rules from a file |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
529 newrules = opts.get(b'import_rules') |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
530 if newrules: |
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
531 try: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39734
diff
changeset
|
532 filepath = os.path.join(encoding.getcwd(), newrules) |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
533 fdata = util.readfile(filepath) |
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
534 except IOError as inst: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
535 raise error.StorageError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
536 _(b"cannot read narrowspecs from '%s': %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
537 % (filepath, encoding.strtolocal(inst.strerror)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
538 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
539 includepats, excludepats, profiles = sparse.parseconfig( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
540 ui, fdata, b'narrow' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
541 ) |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
542 if profiles: |
46117
6cc269bd1c29
errors: raise more specifc errors from narrowcommands
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
543 raise error.InputError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
544 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 b"including other spec files using '%include' " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
546 b"is not supported in narrowspec" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
547 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
548 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
549 opts[b'addinclude'].extend(includepats) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
550 opts[b'addexclude'].extend(excludepats) |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
551 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
552 addedincludes = narrowspec.parsepatterns(opts[b'addinclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
553 removedincludes = narrowspec.parsepatterns(opts[b'removeinclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
554 addedexcludes = narrowspec.parsepatterns(opts[b'addexclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
555 removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
556 autoremoveincludes = opts[b'auto_remove_includes'] |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
557 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
558 update_working_copy = opts[b'update_working_copy'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
559 only_show = not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
560 addedincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
561 or removedincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
562 or addedexcludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
563 or removedexcludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
564 or newrules |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
565 or autoremoveincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
566 or update_working_copy |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
567 ) |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
568 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
569 # Only print the current narrowspec. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
570 if only_show: |
50183
c74d4ce646fb
narrow: move `only_show` handling sooner in `tracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
571 oldincludes, oldexcludes = repo.narrowpats |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
572 ui.pager(b'tracked') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
573 fm = ui.formatter(b'narrow', opts) |
40766
773572e5cba2
narrowcommands: remove an unrequired `repo.narrowpats` call
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40493
diff
changeset
|
574 for i in sorted(oldincludes): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
575 fm.startitem() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
576 fm.write(b'status', b'%s ', b'I', label=b'narrow.included') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
577 fm.write(b'pat', b'%s\n', i, label=b'narrow.included') |
40766
773572e5cba2
narrowcommands: remove an unrequired `repo.narrowpats` call
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40493
diff
changeset
|
578 for i in sorted(oldexcludes): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
579 fm.startitem() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
580 fm.write(b'status', b'%s ', b'X', label=b'narrow.excluded') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
581 fm.write(b'pat', b'%s\n', i, label=b'narrow.excluded') |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
582 fm.end() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
583 return 0 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
584 |
50184
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
585 with repo.wlock(), repo.lock(): |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
586 oldincludes, oldexcludes = repo.narrowpats |
50183
c74d4ce646fb
narrow: move `only_show` handling sooner in `tracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
587 |
50184
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
588 # filter the user passed additions and deletions into actual additions and |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
589 # deletions of excludes and includes |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
590 addedincludes -= oldincludes |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
591 removedincludes &= oldincludes |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
592 addedexcludes -= oldexcludes |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
593 removedexcludes &= oldexcludes |
50183
c74d4ce646fb
narrow: move `only_show` handling sooner in `tracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
594 |
50184
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
595 widening = addedincludes or removedexcludes |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
596 narrowing = removedincludes or addedexcludes |
50183
c74d4ce646fb
narrow: move `only_show` handling sooner in `tracked`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
597 |
50184
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
598 if update_working_copy: |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
599 with repo.transaction(b'narrow-wc'), repo.dirstate.changing_parents( |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
600 repo |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
601 ): |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
602 narrowspec.updateworkingcopy(repo) |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
603 narrowspec.copytoworkingcopy(repo) |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
604 return 0 |
41043
ce0bc2952e2a
narrow: detect if narrowspec was changed in a different share
Martin von Zweigbergk <martinvonz@google.com>
parents:
41039
diff
changeset
|
605 |
50184
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
606 if not (widening or narrowing or autoremoveincludes): |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
607 ui.status(_(b"nothing to widen or narrow\n")) |
a6ca61fd1fa8
narrow: widden the lock context in `tracking`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50183
diff
changeset
|
608 return 0 |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
609 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
610 cmdutil.bailifchanged(repo) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
611 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
612 # Find the revisions we have in common with the remote. These will |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
613 # be used for finding local-only changes for narrowing. They will |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
614 # also define the set of revisions to update for widening. |
49732
0058c74d7f72
path: pass `path` to `peer` in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48875
diff
changeset
|
615 path = urlutil.get_unique_pull_path_obj(b'tracked', ui, remotepath) |
0058c74d7f72
path: pass `path` to `peer` in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48875
diff
changeset
|
616 ui.status(_(b'comparing with %s\n') % urlutil.hidepassword(path.loc)) |
0058c74d7f72
path: pass `path` to `peer` in narrow
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
48875
diff
changeset
|
617 remote = hg.peer(repo, opts, path) |
39964
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
618 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
619 try: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
620 # check narrow support before doing anything if widening needs to be |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
621 # performed. In future we should also abort if client is ellipses and |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
622 # server does not support ellipses |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
623 if ( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
624 widening |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
625 and wireprototypes.NARROWCAP not in remote.capabilities() |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
626 ): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
627 raise error.Abort(_(b"server does not support narrow clones")) |
39964
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
628 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
629 commoninc = discovery.findcommonincoming(repo, remote) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
630 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
631 if autoremoveincludes: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
632 outgoing = discovery.findcommonoutgoing( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
633 repo, remote, commoninc=commoninc |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
634 ) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
635 ui.status(_(b'looking for unused includes to remove\n')) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
636 localfiles = set() |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
637 for n in itertools.chain(outgoing.missing, outgoing.excluded): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
638 localfiles.update(repo[n].files()) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
639 suggestedremovals = [] |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
640 for include in sorted(oldincludes): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
641 match = narrowspec.match(repo.root, [include], oldexcludes) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
642 if not any(match(f) for f in localfiles): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
643 suggestedremovals.append(include) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
644 if suggestedremovals: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
645 for s in suggestedremovals: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
646 ui.status(b'%s\n' % s) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
647 if ( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
648 ui.promptchoice( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
649 _( |
50714
e5c1e7aec973
narrow: indicated the default of 'Yes' when confirming auto-remove-includes
Jason R. Coombs <jaraco@jaraco.com>
parents:
50504
diff
changeset
|
650 b'remove these unused includes (Yn)?' |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
651 b'$$ &Yes $$ &No' |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
652 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
653 ) |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
654 == 0 |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
655 ): |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
656 removedincludes.update(suggestedremovals) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
657 narrowing = True |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
658 else: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
659 ui.status(_(b'found no unused includes\n')) |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
660 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
661 if narrowing: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
662 newincludes = oldincludes - removedincludes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
663 newexcludes = oldexcludes | addedexcludes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
664 _narrow( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
665 ui, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
666 repo, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
667 remote, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
668 commoninc, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
669 oldincludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
670 oldexcludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
671 newincludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
672 newexcludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
673 opts[b'force_delete_local_changes'], |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
674 opts[b'backup'], |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
675 ) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
676 # _narrow() updated the narrowspec and _widen() below needs to |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
677 # use the updated values as its base (otherwise removed includes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
678 # and addedexcludes will be lost in the resulting narrowspec) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
679 oldincludes = newincludes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
680 oldexcludes = newexcludes |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
681 |
46663
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
682 if widening: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
683 newincludes = oldincludes | addedincludes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
684 newexcludes = oldexcludes - removedexcludes |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
685 _widen( |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
686 ui, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
687 repo, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
688 remote, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
689 commoninc, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
690 oldincludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
691 oldexcludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
692 newincludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
693 newexcludes, |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
694 ) |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
695 finally: |
a4c19a162615
sshpeer: enable+fix warning about sshpeers not being closed explicitly
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
46477
diff
changeset
|
696 remote.close() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
697 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
698 return 0 |