Mercurial > hg
annotate hgext/narrow/narrowcommands.py @ 43117:8ff1ecfadcd1
cleanup: join string literals that are already on one line
Thanks to Kyle for noticing this and for providing the regular
expression to run on the codebase.
This patch has been reviewed by the test suite and they approved of
it.
# skip-blame: fallout from mass reformatting
Differential Revision: https://phab.mercurial-scm.org/D7028
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 08 Oct 2019 15:06:18 -0700 |
parents | 687b865b95ad |
children | 5ff32fdf0b0b |
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 from __future__ import absolute_import |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
8 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 import itertools |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
10 import os |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 from mercurial.i18n import _ |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 from mercurial import ( |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
14 bundle2, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 cmdutil, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 commands, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 discovery, |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
18 encoding, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 error, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 exchange, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 extensions, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
22 hg, |
36160
9fd8c2a3db5a
narrowspec: move module into core
Gregory Szorc <gregory.szorc@gmail.com>
parents:
36154
diff
changeset
|
23 narrowspec, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
24 node, |
36154
4a7ba3ac9163
narrowcommands: use pycompat.{bytes,str}kwargs
Augie Fackler <augie@google.com>
parents:
36100
diff
changeset
|
25 pycompat, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
26 registrar, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
27 repair, |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
28 repoview, |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
29 sparse, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
30 util, |
40074
f7011b44d205
wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40070
diff
changeset
|
31 wireprototypes, |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
32 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
33 from mercurial.interfaces import repository |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
34 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
35 table = {} |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
36 command = registrar.command(table) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
37 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
38 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
39 def setup(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
40 """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
|
41 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
42 entry = extensions.wrapcommand(commands.table, b'clone', clonenarrowcmd) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
43 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
44 (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
|
45 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
46 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
47 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
48 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
49 b'depth', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
50 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
51 _(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
|
52 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
53 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
54 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
|
55 # 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
|
56 if b'sparse' not in extensions.enabled(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
57 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
58 (b'', b'include', [], _(b"specifically fetch this file/directory")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
59 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 entry[1].append( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
61 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
62 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
63 b'exclude', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
64 [], |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
65 _(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
|
66 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
67 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
69 entry = extensions.wrapcommand(commands.table, b'pull', pullnarrowcmd) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
70 entry[1].append( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
71 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
72 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
73 b'depth', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
74 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
75 _(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
|
76 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
77 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
79 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
|
80 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
81 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 def clonenarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 """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
|
84 opts = pycompat.byteskwargs(opts) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 wrappedextraprepare = util.nullcontextmanager() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
86 narrowspecfile = opts[b'narrowspec'] |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
87 |
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
88 if narrowspecfile: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39734
diff
changeset
|
89 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
|
90 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
|
91 try: |
39465
4062bbb1d10f
narrow: use util.readfile() and improve error message using --narrowspec
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39440
diff
changeset
|
92 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
|
93 except IOError as inst: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
94 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
95 _(b"cannot read narrowspecs from '%s': %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
96 % (filepath, encoding.strtolocal(inst.strerror)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
97 ) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
98 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
99 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
|
100 if profiles: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
101 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
102 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
103 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
|
104 b" narrowspec" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
105 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
106 ) |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
107 |
39541
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
108 narrowspec.validatepatterns(includes) |
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
109 narrowspec.validatepatterns(excludes) |
8301741e1f89
narrow: validate spec files are well-formed during clone (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39532
diff
changeset
|
110 |
39247
f4d4bd8c8911
narrow: add a --narrowspec flag to clone command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
38835
diff
changeset
|
111 # 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
|
112 opts[b'narrow'] = True |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
113 opts[b'include'].extend(includes) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
114 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
|
115 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 if opts[b'narrow']: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
117 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
118 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
119 orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
120 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
121 if opts.get(b'depth'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 kwargs[b'depth'] = opts[b'depth'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
123 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
124 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
125 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
126 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
39554
841c82d1a973
narrow: don't wrap exchange.pull() during clone
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39545
diff
changeset
|
128 with wrappedextraprepare: |
36154
4a7ba3ac9163
narrowcommands: use pycompat.{bytes,str}kwargs
Augie Fackler <augie@google.com>
parents:
36100
diff
changeset
|
129 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
|
130 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
131 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 def pullnarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 """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
|
134 wrappedextraprepare = util.nullcontextmanager() |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38528
diff
changeset
|
135 if repository.NARROW_REQUIREMENT in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 orig(pullop, kwargs) |
36456
9ff5cbfbc26a
py3: fix more keyword arguments handling
Pulkit Goyal <7895pulkit@gmail.com>
parents:
36352
diff
changeset
|
139 if opts.get(r'depth'): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
140 kwargs[b'depth'] = opts[r'depth'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
141 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
142 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
143 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
144 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
145 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 with wrappedextraprepare: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 return orig(ui, repo, *args, **opts) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
149 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 def archivenarrowcmd(orig, ui, repo, *args, **opts): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 """Wraps archive command to narrow the default includes.""" |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38528
diff
changeset
|
152 if repository.NARROW_REQUIREMENT in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 repo_includes, repo_excludes = repo.narrowpats |
36352
5dbeddbf164a
narrowcommands: add some missing strkwargs calls for py3
Augie Fackler <augie@google.com>
parents:
36166
diff
changeset
|
154 includes = set(opts.get(r'include', [])) |
5dbeddbf164a
narrowcommands: add some missing strkwargs calls for py3
Augie Fackler <augie@google.com>
parents:
36166
diff
changeset
|
155 excludes = set(opts.get(r'exclude', [])) |
36100
8fd0a9e2d7e9
narrow: make restrictpatterns a little more idiomatic
Augie Fackler <augie@google.com>
parents:
36088
diff
changeset
|
156 includes, excludes, unused_invalid = narrowspec.restrictpatterns( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
157 includes, excludes, repo_includes, repo_excludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
158 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 if includes: |
36352
5dbeddbf164a
narrowcommands: add some missing strkwargs calls for py3
Augie Fackler <augie@google.com>
parents:
36166
diff
changeset
|
160 opts[r'include'] = includes |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
161 if excludes: |
36352
5dbeddbf164a
narrowcommands: add some missing strkwargs calls for py3
Augie Fackler <augie@google.com>
parents:
36166
diff
changeset
|
162 opts[r'exclude'] = excludes |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 return orig(ui, repo, *args, **opts) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
165 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 def pullbundle2extraprepare(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 repo = pullop.repo |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38528
diff
changeset
|
168 if repository.NARROW_REQUIREMENT not in repo.requirements: |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 return orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
170 |
40074
f7011b44d205
wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40070
diff
changeset
|
171 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
|
172 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
|
173 orig(pullop, kwargs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
174 kwargs[b'narrow'] = True |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 include, exclude = repo.narrowpats |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
176 kwargs[b'oldincludepats'] = include |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
177 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
|
178 if include: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
179 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
|
180 if exclude: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
181 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
|
182 # 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
|
183 # 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
|
184 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
|
185 kwargs[b'known'] = [ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
186 node.hex(ctx.node()) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
187 for ctx in repo.set(b'::%ln', pullop.common) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
188 if ctx.node() != node.nullid |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
189 ] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
190 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
|
191 # 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
|
192 # [''], 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
|
193 # the server. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
194 del kwargs[b'known'] |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
195 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
196 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
197 extensions.wrapfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
198 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
199 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
200 |
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 def _narrow( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
203 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
204 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
205 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
206 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
207 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
208 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
209 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
210 newexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
211 force, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
212 ): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
214 newmatch = narrowspec.match(repo.root, newincludes, newexcludes) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 # 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
|
217 # 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
|
218 # 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
|
219 unfi = repo.unfiltered() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
220 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
|
221 ui.status(_(b'looking for local changes to affected paths\n')) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 localnodes = [] |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 for n in itertools.chain(outgoing.missing, outgoing.excluded): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
224 if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 localnodes.append(n) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
226 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
|
227 hiddenrevs = repoview.filterrevs(repo, b'visible') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
228 visibletostrip = list( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
229 repo.changelog.node(r) for r in (revstostrip - hiddenrevs) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
230 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 if visibletostrip: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
232 ui.status( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
233 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
234 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
|
235 b'local changes not on the remote:\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
236 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
237 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 maxnodes = 10 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 if ui.verbose or len(visibletostrip) <= maxnodes: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
240 for n in visibletostrip: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
241 ui.status(b'%s\n' % node.short(n)) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 else: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 for n in visibletostrip[:maxnodes]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
244 ui.status(b'%s\n' % node.short(n)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
245 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 _(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
|
247 % (len(visibletostrip) - maxnodes) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
248 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 if not force: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
250 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
251 _(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
|
252 hint=_(b'use --force-delete-local-changes to ignore'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
253 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
41043
diff
changeset
|
255 with ui.uninterruptible(): |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
256 if revstostrip: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
257 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
|
258 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
|
259 # 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
|
260 urev = max( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
261 repo.revs( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 b'(::%n) - %ln + null', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
263 repo[b'.'].node(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
264 visibletostrip, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
265 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
266 ) |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
267 hg.clean(repo, urev) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
268 overrides = {(b'devel', b'strip-obsmarkers'): False} |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
269 with ui.configoverride(overrides, b'narrow'): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
270 repair.strip(ui, unfi, tostrip, topic=b'narrow') |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
272 todelete = [] |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
273 for f, f2, size in repo.store.datafiles(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
274 if f.startswith(b'data/'): |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
275 file = f[5:-2] |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
276 if not newmatch(file): |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
277 todelete.append(f) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 elif f.startswith(b'meta/'): |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
279 dir = f[5:-13] |
42345
7d4ee14ff92d
narrowcommands: drop unnecessary adding of '' for root directory
Martin von Zweigbergk <martinvonz@google.com>
parents:
42341
diff
changeset
|
280 dirs = sorted(util.dirs({dir})) + [dir] |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
281 include = True |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
282 for d in dirs: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
283 visit = newmatch.visitdir(d) |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
284 if not visit: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
285 include = False |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
286 break |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
287 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
|
288 break |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
289 if not include: |
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
290 todelete.append(f) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
291 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
292 repo.destroying() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
293 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
294 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
|
295 # 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
|
296 # 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
|
297 repo.setnarrowpats(newincludes, newexcludes) |
095a0a63ad88
narrow: when narrowing, write new narrowspec before removing revlogs
Martin von Zweigbergk <martinvonz@google.com>
parents:
41027
diff
changeset
|
298 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
299 for f in todelete: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
300 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
|
301 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
|
302 repo.store.markremoved(f) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
303 |
41238
8c366af085f4
narrow: reuse narrowspec.updateworkingcopy() when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
41237
diff
changeset
|
304 narrowspec.updateworkingcopy(repo, assumeclean=True) |
8c366af085f4
narrow: reuse narrowspec.updateworkingcopy() when narrowing
Martin von Zweigbergk <martinvonz@google.com>
parents:
41237
diff
changeset
|
305 narrowspec.copytoworkingcopy(repo) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
306 |
38528
a1d5951efce7
narrow: mark the critical chunks of narrowing/widening as unsafe
Augie Fackler <augie@google.com>
parents:
36469
diff
changeset
|
307 repo.destroyed() |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
308 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
309 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
310 def _widen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
311 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
312 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
313 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
314 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
315 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
316 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
317 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
318 newexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
319 ): |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
320 # 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
|
321 # 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
|
322 # 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
|
323 # 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
|
324 # 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
|
325 # 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
|
326 remotecap = remote.capabilities() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
327 ellipsesremote = any( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
328 cap in remotecap for cap in wireprototypes.SUPPORTED_ELLIPSESCAP |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
329 ) |
42415
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
330 |
c767e655ffda
narrow: use narrow_widen wireproto command to widen in case of ellipses
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42345
diff
changeset
|
331 # 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
|
332 # ellipses capabilities |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
333 isoldellipses = ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
334 ellipsesremote |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
335 and wireprototypes.ELLIPSESCAP1 in remotecap |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
336 and wireprototypes.ELLIPSESCAP not in remotecap |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
337 ) |
39963
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
338 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
339 def pullbundle2extraprepare_widen(orig, pullop, kwargs): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
340 orig(pullop, kwargs) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
341 # 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
|
342 kwargs[b'includepats'] = newincludes |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
343 kwargs[b'excludepats'] = newexcludes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
344 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
345 wrappedextraprepare = extensions.wrappedfunction( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
346 exchange, b'_pullbundle2extraprepare', pullbundle2extraprepare_widen |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
347 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
348 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
349 # 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
|
350 # 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
|
351 def setnewnarrowpats(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
352 repo.setnarrowpats(newincludes, newexcludes) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
353 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
354 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
|
355 # 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
|
356 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
|
357 |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
358 common = commoninc[0] |
41076
8ecb17b7f432
procutil: correct spelling of uninterruptable -> uninterruptible
Kyle Lippincott <spectral@google.com>
parents:
41043
diff
changeset
|
359 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
|
360 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
|
361 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
|
362 p1, p2 = ds.p1(), ds.p2() |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
363 with ds.parentchange(): |
693dda764efe
narrow: don't do the dirstate dance if ellipses is not enabled
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39934
diff
changeset
|
364 ds.setparents(node.nullid, node.nullid) |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
365 if isoldellipses: |
41760
1eb2fc21da12
cleanup: prefer nested context managers to \-continuations
Augie Fackler <augie@google.com>
parents:
41723
diff
changeset
|
366 with wrappedextraprepare: |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
367 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
|
368 else: |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
369 known = [] |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
370 if ellipsesremote: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
371 known = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
372 ctx.node() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
373 for ctx in repo.set(b'::%ln', common) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
374 if ctx.node() != node.nullid |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
375 ] |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
376 with remote.commandexecutor() as e: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
377 bundle = e.callcommand( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
378 b'narrow_widen', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
379 { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
380 b'oldincludes': oldincludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
381 b'oldexcludes': oldexcludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
382 b'newincludes': newincludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
383 b'newexcludes': newexcludes, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
384 b'cgversion': b'03', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
385 b'commonheads': common, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
386 b'known': known, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
387 b'ellipses': ellipsesremote, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
388 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
389 ).result() |
40070
8feae5b989bc
narrow: the first version of narrow_widen wireprotocol command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39965
diff
changeset
|
390 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
391 trmanager = exchange.transactionmanager( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
392 repo, b'widen', remote.url() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
393 ) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
394 with trmanager, repo.ui.configoverride(overrides, b'widen'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
395 op = bundle2.bundleoperation( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
396 repo, trmanager.transaction, source=b'widen' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
397 ) |
42416
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
398 # TODO: we should catch error.Abort here |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
399 bundle2.processbundle(repo, bundle, op=op) |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
400 |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
401 if ellipsesremote: |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
402 with ds.parentchange(): |
8381b7067f17
narrow: refactor code around widening complicated by previous patch
Pulkit Goyal <7895pulkit@gmail.com>
parents:
42415
diff
changeset
|
403 ds.setparents(p1, p2) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
404 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
405 with repo.transaction(b'widening'): |
41237
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
406 repo.setnewnarrowpats() |
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
407 narrowspec.updateworkingcopy(repo) |
ad9ab2523149
narrow: reuse narrowspec.updateworkingcopy() when widening
Martin von Zweigbergk <martinvonz@google.com>
parents:
41236
diff
changeset
|
408 narrowspec.copytoworkingcopy(repo) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
409 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
410 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
411 # TODO(rdamazio): Make new matcher format and update description |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
412 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 b'tracked', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
414 [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 (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
|
416 (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
|
417 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
418 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
419 b'auto-remove-includes', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
420 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
421 _(b'automatically choose unused includes to remove'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
422 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
423 (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
|
424 (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
|
425 (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
|
426 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
427 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
428 b'clear', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
429 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
430 _(b'whether to replace the existing narrowspec'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
431 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
432 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
434 b'force-delete-local-changes', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
435 False, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
436 _(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
|
437 ), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
438 ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
439 b'', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
440 b'update-working-copy', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
441 False, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
442 _(b'update working copy when the store has changed'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
443 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
444 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
445 + commands.remoteopts, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
446 _(b'[OPTIONS]... [REMOTE]'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
447 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
448 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
449 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
|
450 """show or change the current narrowspec |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
451 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
452 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
|
453 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
|
454 respectively. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
455 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 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
|
460 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
|
461 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
|
462 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
463 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
|
464 'hg help patterns'. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
465 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
466 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
|
467 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
468 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
|
469 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
|
470 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
|
471 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
|
472 |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
473 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
|
474 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
|
475 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
|
476 remove. |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
477 |
41980
6cad258e1348
tracked: add documentation about `--import-rules` flag
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41760
diff
changeset
|
478 --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
|
479 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
|
480 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
|
481 """ |
36166
ccf7ae119769
narrowcommands: more byteskwargs cleanup
Augie Fackler <augie@google.com>
parents:
36160
diff
changeset
|
482 opts = pycompat.byteskwargs(opts) |
38835
a232e6744ba3
narrow: move requirement constant from changegroup to repository
Martin von Zweigbergk <martinvonz@google.com>
parents:
38528
diff
changeset
|
483 if repository.NARROW_REQUIREMENT not in repo.requirements: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
484 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
485 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 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
|
487 b'repositories cloned with --narrow' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
488 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
489 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
490 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
491 # 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
|
492 # 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
|
493 if opts[b'clear']: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
494 raise error.Abort(_(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
|
495 |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
496 # import rules from a file |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
497 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
|
498 if newrules: |
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
499 try: |
39818
24e493ec2229
py3: rename pycompat.getcwd() to encoding.getcwd() (API)
Matt Harbison <matt_harbison@yahoo.com>
parents:
39734
diff
changeset
|
500 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
|
501 fdata = util.readfile(filepath) |
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
502 except IOError as inst: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
503 raise error.Abort( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
504 _(b"cannot read narrowspecs from '%s': %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
505 % (filepath, encoding.strtolocal(inst.strerror)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
506 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
507 includepats, excludepats, profiles = sparse.parseconfig( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
508 ui, fdata, b'narrow' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
509 ) |
39440
ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39357
diff
changeset
|
510 if profiles: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
511 raise error.Abort( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
512 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
513 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
|
514 b"is not supported in narrowspec" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
515 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
516 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
517 opts[b'addinclude'].extend(includepats) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
518 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
|
519 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
520 addedincludes = narrowspec.parsepatterns(opts[b'addinclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
521 removedincludes = narrowspec.parsepatterns(opts[b'removeinclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
522 addedexcludes = narrowspec.parsepatterns(opts[b'addexclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
523 removedexcludes = narrowspec.parsepatterns(opts[b'removeexclude']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
524 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
|
525 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
526 update_working_copy = opts[b'update_working_copy'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
527 only_show = not ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
528 addedincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
529 or removedincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
530 or addedexcludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
531 or removedexcludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
532 or newrules |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
533 or autoremoveincludes |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
534 or update_working_copy |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
535 ) |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
536 |
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
537 oldincludes, oldexcludes = repo.narrowpats |
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
538 |
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
539 # filter the user passed additions and deletions into actual additions and |
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
540 # deletions of excludes and includes |
40438
5d8f291405e5
narrow: replace filtering in list comprehension by set operations
Martin von Zweigbergk <martinvonz@google.com>
parents:
40436
diff
changeset
|
541 addedincludes -= oldincludes |
5d8f291405e5
narrow: replace filtering in list comprehension by set operations
Martin von Zweigbergk <martinvonz@google.com>
parents:
40436
diff
changeset
|
542 removedincludes &= oldincludes |
5d8f291405e5
narrow: replace filtering in list comprehension by set operations
Martin von Zweigbergk <martinvonz@google.com>
parents:
40436
diff
changeset
|
543 addedexcludes -= oldexcludes |
5d8f291405e5
narrow: replace filtering in list comprehension by set operations
Martin von Zweigbergk <martinvonz@google.com>
parents:
40436
diff
changeset
|
544 removedexcludes &= oldexcludes |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
545 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
546 widening = addedincludes or removedexcludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
547 narrowing = removedincludes or addedexcludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
548 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
549 # Only print the current narrowspec. |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
550 if only_show: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
551 ui.pager(b'tracked') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
552 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
|
553 for i in sorted(oldincludes): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
554 fm.startitem() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
555 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
|
556 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
|
557 for i in sorted(oldexcludes): |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
558 fm.startitem() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
559 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
|
560 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
|
561 fm.end() |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
562 return 0 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
563 |
41043
ce0bc2952e2a
narrow: detect if narrowspec was changed in a different share
Martin von Zweigbergk <martinvonz@google.com>
parents:
41039
diff
changeset
|
564 if update_working_copy: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
565 with repo.wlock(), repo.lock(), repo.transaction(b'narrow-wc'): |
41176
4475322b7533
narrow: drop explicit dirstate write
Martin von Zweigbergk <martinvonz@google.com>
parents:
41076
diff
changeset
|
566 narrowspec.updateworkingcopy(repo) |
41229
50ca531f1f24
narrow: copy store narrowspec to working copy immediately
Martin von Zweigbergk <martinvonz@google.com>
parents:
41176
diff
changeset
|
567 narrowspec.copytoworkingcopy(repo) |
41043
ce0bc2952e2a
narrow: detect if narrowspec was changed in a different share
Martin von Zweigbergk <martinvonz@google.com>
parents:
41039
diff
changeset
|
568 return 0 |
ce0bc2952e2a
narrow: detect if narrowspec was changed in a different share
Martin von Zweigbergk <martinvonz@google.com>
parents:
41039
diff
changeset
|
569 |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
570 if not (widening or narrowing or autoremoveincludes): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
571 ui.status(_(b"nothing to widen or narrow\n")) |
40436
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
572 return 0 |
30a7d3b6b281
narrow: rework logic to check whether we need to widen and narrow
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40074
diff
changeset
|
573 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
574 with repo.wlock(), repo.lock(): |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
575 cmdutil.bailifchanged(repo) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
576 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
577 # 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
|
578 # 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
|
579 # also define the set of revisions to update for widening. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
580 remotepath = ui.expandpath(remotepath or b'default') |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
581 url, branches = hg.parseurl(remotepath) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
582 ui.status(_(b'comparing with %s\n') % util.hidepassword(url)) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
583 remote = hg.peer(repo, opts, url) |
39964
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
584 |
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
585 # check narrow support before doing anything if widening needs to be |
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
586 # performed. In future we should also abort if client is ellipses and |
06e75fbf9d6b
narrow: check for servers' narrow support before doing anything (BC)
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
39963
diff
changeset
|
587 # server does not support ellipses |
40074
f7011b44d205
wireprotoserver: move narrow capabilities to wireprototypes.py
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
40070
diff
changeset
|
588 if widening and wireprototypes.NARROWCAP not in remote.capabilities(): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
589 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
|
590 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
591 commoninc = discovery.findcommonincoming(repo, remote) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
592 |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
593 if autoremoveincludes: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
594 outgoing = discovery.findcommonoutgoing( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
595 repo, remote, commoninc=commoninc |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
596 ) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
597 ui.status(_(b'looking for unused includes to remove\n')) |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
598 localfiles = set() |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
599 for n in itertools.chain(outgoing.missing, outgoing.excluded): |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
600 localfiles.update(repo[n].files()) |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
601 suggestedremovals = [] |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
602 for include in sorted(oldincludes): |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
603 match = narrowspec.match(repo.root, [include], oldexcludes) |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
604 if not any(match(f) for f in localfiles): |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
605 suggestedremovals.append(include) |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
606 if suggestedremovals: |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
607 for s in suggestedremovals: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
608 ui.status(b'%s\n' % s) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
609 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
610 ui.promptchoice( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
611 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
612 b'remove these unused includes (yn)?' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
613 b'$$ &Yes $$ &No' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
614 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
615 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
616 == 0 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
617 ): |
42945
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
618 removedincludes.update(suggestedremovals) |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
619 narrowing = True |
40f78072fda9
narrow: add option for automatically removing unused includes
Martin von Zweigbergk <martinvonz@google.com>
parents:
42944
diff
changeset
|
620 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
621 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
|
622 |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
623 if narrowing: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
624 newincludes = oldincludes - removedincludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
625 newexcludes = oldexcludes | addedexcludes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
626 _narrow( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
627 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
628 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
629 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
630 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
631 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
632 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
633 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
634 newexcludes, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
635 opts[b'force_delete_local_changes'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
636 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
637 # _narrow() updated the narrowspec and _widen() below needs to |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
638 # use the updated values as its base (otherwise removed includes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
639 # and addedexcludes will be lost in the resulting narrowspec) |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
640 oldincludes = newincludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
641 oldexcludes = newexcludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
642 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
643 if widening: |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
644 newincludes = oldincludes | addedincludes |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
645 newexcludes = oldexcludes - removedexcludes |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
646 _widen( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
647 ui, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
648 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
649 remote, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
650 commoninc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
651 oldincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
652 oldexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
653 newincludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
654 newexcludes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42945
diff
changeset
|
655 ) |
36079
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
656 |
a2a6e724d61a
narrow: import experimental extension from narrowhg revision cb51d673e9c5
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
657 return 0 |