Mercurial > hg
comparison tests/test-narrow-trackedcmd.t @ 39440:ab20ee07b82d
narrow: add '--import-rules' flag to tracked command
This patch adds a `--import-rules` flag to tracked command provided by narrow
extension. Using the --import-rules flag, you can pass a filename from which
narrowspecs should be read and added to main narrowspec.
A lot of times, in automation or manually also, when you are working with big
repo, specifying each path name on commandline using '--addinclude' and
'--addexclude' is tedious and something which can scale. So we needed something
where we can pass a file to extend the narrowspecs.
Nice thing about this is that the automations which reads some file to change
the sparse profile, can now read the same file for changing narrowspecs too.
Tests are added for the new feature.
Differential Revision: https://phab.mercurial-scm.org/D4125
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Mon, 06 Aug 2018 14:06:19 +0300 |
parents | |
children | 8604f130eb43 |
comparison
equal
deleted
inserted
replaced
39439:dc61a67c1fc0 | 39440:ab20ee07b82d |
---|---|
1 #testcases flat tree | |
2 $ . "$TESTDIR/narrow-library.sh" | |
3 | |
4 #if tree | |
5 $ cat << EOF >> $HGRCPATH | |
6 > [experimental] | |
7 > treemanifest = 1 | |
8 > EOF | |
9 #endif | |
10 | |
11 $ hg init master | |
12 $ cd master | |
13 $ cat >> .hg/hgrc <<EOF | |
14 > [narrow] | |
15 > serveellipses=True | |
16 > EOF | |
17 | |
18 $ mkdir inside | |
19 $ echo 'inside' > inside/f | |
20 $ hg add inside/f | |
21 $ hg commit -m 'add inside' | |
22 | |
23 $ mkdir widest | |
24 $ echo 'widest' > widest/f | |
25 $ hg add widest/f | |
26 $ hg commit -m 'add widest' | |
27 | |
28 $ mkdir outside | |
29 $ echo 'outside' > outside/f | |
30 $ hg add outside/f | |
31 $ hg commit -m 'add outside' | |
32 | |
33 $ cd .. | |
34 | |
35 narrow clone the inside file | |
36 | |
37 $ hg clone --narrow ssh://user@dummy/master narrow --include inside | |
38 requesting all changes | |
39 adding changesets | |
40 adding manifests | |
41 adding file changes | |
42 added 2 changesets with 1 changes to 1 files | |
43 new changesets *:* (glob) | |
44 updating to branch default | |
45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
46 $ cd narrow | |
47 $ hg tracked | |
48 I path:inside | |
49 $ ls | |
50 inside | |
51 $ cat inside/f | |
52 inside | |
53 $ cd .. | |
54 | |
55 add more upstream files which we will include in a wider narrow spec | |
56 | |
57 $ cd master | |
58 | |
59 $ mkdir wider | |
60 $ echo 'wider' > wider/f | |
61 $ hg add wider/f | |
62 $ echo 'widest v2' > widest/f | |
63 $ hg commit -m 'add wider, update widest' | |
64 | |
65 $ echo 'widest v3' > widest/f | |
66 $ hg commit -m 'update widest v3' | |
67 | |
68 $ echo 'inside v2' > inside/f | |
69 $ hg commit -m 'update inside' | |
70 | |
71 $ mkdir outside2 | |
72 $ echo 'outside2' > outside2/f | |
73 $ hg add outside2/f | |
74 $ hg commit -m 'add outside2' | |
75 | |
76 $ echo 'widest v4' > widest/f | |
77 $ hg commit -m 'update widest v4' | |
78 | |
79 $ hg log -T "{if(ellipsis, '...')}{rev}: {desc}\n" | |
80 7: update widest v4 | |
81 6: add outside2 | |
82 5: update inside | |
83 4: update widest v3 | |
84 3: add wider, update widest | |
85 2: add outside | |
86 1: add widest | |
87 0: add inside | |
88 | |
89 $ cd .. | |
90 | |
91 Testing the --import-rules flag of `hg tracked` command | |
92 | |
93 $ cd narrow | |
94 $ hg tracked --import-rules | |
95 hg tracked: option --import-rules requires argument | |
96 hg tracked [OPTIONS]... [REMOTE] | |
97 | |
98 show or change the current narrowspec | |
99 | |
100 options ([+] can be repeated): | |
101 | |
102 --addinclude VALUE [+] new paths to include | |
103 --removeinclude VALUE [+] old paths to no longer include | |
104 --addexclude VALUE [+] new paths to exclude | |
105 --import-rules VALUE import narrowspecs from a file | |
106 --removeexclude VALUE [+] old paths to no longer exclude | |
107 --clear whether to replace the existing narrowspec | |
108 --force-delete-local-changes forces deletion of local changes when | |
109 narrowing | |
110 -e --ssh CMD specify ssh command to use | |
111 --remotecmd CMD specify hg command to run on the remote side | |
112 --insecure do not verify server certificate (ignoring | |
113 web.cacerts config) | |
114 | |
115 (use 'hg tracked -h' to show more help) | |
116 [255] | |
117 $ hg tracked --import-rules doesnotexist | |
118 abort: cannot read narrowspecs from '$TESTTMP/narrow/doesnotexist': $ENOENT$ | |
119 [255] | |
120 | |
121 $ cat > specs <<EOF | |
122 > %include foo | |
123 > [include] | |
124 > path:widest/ | |
125 > [exclude] | |
126 > path:inside/ | |
127 > EOF | |
128 | |
129 $ hg tracked --import-rules specs | |
130 abort: including other spec files using '%include' is not supported in narrowspec | |
131 [255] | |
132 | |
133 $ cat > specs <<EOF | |
134 > [include] | |
135 > outisde | |
136 > [exclude] | |
137 > inside | |
138 > EOF | |
139 | |
140 $ hg tracked --import-rules specs | |
141 comparing with ssh://user@dummy/master | |
142 searching for changes | |
143 looking for local changes to affected paths | |
144 deleting data/inside/f.i | |
145 deleting meta/inside/00manifest.i (tree !) | |
146 no changes found | |
147 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
148 adding changesets | |
149 adding manifests | |
150 adding file changes | |
151 added 2 changesets with 0 changes to 0 files | |
152 new changesets *:* (glob) | |
153 $ hg tracked | |
154 I path:outisde | |
155 X path:inside | |
156 | |
157 Testing the --import-rules flag with --addinclude and --addexclude | |
158 | |
159 $ cat > specs <<EOF | |
160 > [include] | |
161 > widest | |
162 > EOF | |
163 | |
164 $ hg tracked --import-rules specs --addinclude 'wider/' | |
165 comparing with ssh://user@dummy/master | |
166 searching for changes | |
167 no changes found | |
168 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
169 adding changesets | |
170 adding manifests | |
171 adding file changes | |
172 added 3 changesets with 1 changes to 1 files | |
173 new changesets *:* (glob) | |
174 $ hg tracked | |
175 I path:outisde | |
176 I path:wider | |
177 I path:widest | |
178 X path:inside | |
179 | |
180 $ cat > specs <<EOF | |
181 > [exclude] | |
182 > outside2 | |
183 > EOF | |
184 | |
185 $ hg tracked --import-rules specs --addexclude 'widest' | |
186 comparing with ssh://user@dummy/master | |
187 searching for changes | |
188 looking for local changes to affected paths | |
189 deleting data/widest/f.i | |
190 deleting meta/widest/00manifest.i (tree !) | |
191 $ hg tracked | |
192 I path:outisde | |
193 I path:wider | |
194 X path:inside | |
195 X path:outside2 | |
196 X path:widest | |
197 | |
198 $ hg tracked --import-rules specs --clear | |
199 The --clear option is not yet supported. | |
200 [1] | |
201 | |
202 Testing with passing a out of wdir file | |
203 | |
204 $ cat > ../nspecs <<EOF | |
205 > [include] | |
206 > widest | |
207 > EOF | |
208 | |
209 $ hg tracked --import-rules ../nspecs | |
210 comparing with ssh://user@dummy/master | |
211 searching for changes | |
212 no changes found | |
213 saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-widen.hg (glob) | |
214 adding changesets | |
215 adding manifests | |
216 adding file changes | |
217 added 3 changesets with 0 changes to 0 files | |
218 new changesets *:* (glob) |