comparison tests/test-narrow.t @ 36079:a2a6e724d61a

narrow: import experimental extension from narrowhg revision cb51d673e9c5 Adjustments: * renamed src to hgext/narrow * marked extension experimental * added correct copyright header where it was missing * updated hgrc extension enable line in library.sh * renamed library.sh to narrow-library.sh * dropped all files from repo root as they're not interesting * dropped test-pyflakes.t, test-check-code.t and test-check-py3-compat.t * renamed remaining tests to all be test-narrow-* when they didn't already * fixed test-narrow-expanddirstate.t to refer to narrow and not narrowhg * fixed tests that wanted `update -C .` instead of `merge --abort` * corrected a two-space indent in narrowspec.py * added a missing _() in narrowcommands.py * fixed imports to pass the import checker * narrow only adds its --include and --exclude to clone if sparse isn't enabled to avoid breaking test-duplicateoptions.py. This is a kludge, and we'll need to come up with a better solution in the future. These were more or less the minimum to import something that would pass tests and not create a bunch of files we'll never use. Changes I intend to make as followups: * rework the test-narrow-*-tree.t tests to use the new testcases functionality in run-tests.py * remove lots of monkeypatches of core things Differential Revision: https://phab.mercurial-scm.org/D1974
author Augie Fackler <augie@google.com>
date Mon, 29 Jan 2018 16:19:33 -0500
parents
children dc01484606da
comparison
equal deleted inserted replaced
36078:7f68235f23ff 36079:a2a6e724d61a
1 $ . "$TESTDIR/narrow-library.sh"
2
3 $ hg init master
4 $ cd master
5 $ cat >> .hg/hgrc <<EOF
6 > [narrow]
7 > serveellipses=True
8 > EOF
9 $ for x in `$TESTDIR/seq.py 0 10`
10 > do
11 > mkdir d$x
12 > echo $x > d$x/f
13 > hg add d$x/f
14 > hg commit -m "add d$x/f"
15 > done
16 $ hg log -T "{node|short}: {desc}\n"
17 *: add d10/f (glob)
18 *: add d9/f (glob)
19 *: add d8/f (glob)
20 *: add d7/f (glob)
21 *: add d6/f (glob)
22 *: add d5/f (glob)
23 *: add d4/f (glob)
24 *: add d3/f (glob)
25 *: add d2/f (glob)
26 *: add d1/f (glob)
27 *: add d0/f (glob)
28 $ cd ..
29
30 Error if '.' or '..' are in the directory to track.
31 $ hg clone --narrow ssh://user@dummy/master foo --include ./asdf
32 requesting all changes
33 abort: "." and ".." are not allowed in narrowspec paths
34 [255]
35 $ hg clone --narrow ssh://user@dummy/master foo --include asdf/..
36 requesting all changes
37 abort: "." and ".." are not allowed in narrowspec paths
38 [255]
39 $ hg clone --narrow ssh://user@dummy/master foo --include a/./c
40 requesting all changes
41 abort: "." and ".." are not allowed in narrowspec paths
42 [255]
43
44 Names with '.' in them are OK.
45 $ hg clone --narrow ssh://user@dummy/master $RANDOM --include a/.b/c
46 requesting all changes
47 adding changesets
48 adding manifests
49 adding file changes
50 added 1 changesets with 0 changes to 0 files
51 new changesets * (glob)
52 updating to branch default
53 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
54
55 Test repo with local changes
56 $ hg clone --narrow ssh://user@dummy/master narrow-local-changes --include d0 --include d3 --include d6
57 requesting all changes
58 adding changesets
59 adding manifests
60 adding file changes
61 added 6 changesets with 3 changes to 3 files
62 new changesets *:* (glob)
63 updating to branch default
64 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 $ cd narrow-local-changes
66 $ cat >> $HGRCPATH << EOF
67 > [experimental]
68 > evolution=createmarkers
69 > EOF
70 $ echo local change >> d0/f
71 $ hg ci -m 'local change to d0'
72 $ hg co '.^'
73 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
74 $ echo local change >> d3/f
75 $ hg ci -m 'local hidden change to d3'
76 created new head
77 $ hg ci --amend -m 'local change to d3'
78 $ hg tracked --removeinclude d0
79 comparing with ssh://user@dummy/master
80 searching for changes
81 looking for local changes to affected paths
82 The following changeset(s) or their ancestors have local changes not on the remote:
83 * (glob)
84 abort: local changes found
85 (use --force-delete-local-changes to ignore)
86 [255]
87 Check that nothing was removed by the failed attempts
88 $ hg tracked
89 I path:d0
90 I path:d3
91 I path:d6
92 $ hg files
93 d0/f
94 d3/f
95 d6/f
96 $ find *
97 d0
98 d0/f
99 d3
100 d3/f
101 d6
102 d6/f
103 $ hg verify -q
104 Force deletion of local changes
105 $ hg log -T "{node|short}: {desc} {outsidenarrow}\n"
106 *: local change to d3 (glob)
107 *: local change to d0 (glob)
108 *: add d10/f outsidenarrow (glob)
109 *: add d6/f (glob)
110 *: add d5/f outsidenarrow (glob)
111 *: add d3/f (glob)
112 *: add d2/f outsidenarrow (glob)
113 *: add d0/f (glob)
114 $ hg tracked --removeinclude d0 --force-delete-local-changes
115 comparing with ssh://user@dummy/master
116 searching for changes
117 looking for local changes to affected paths
118 The following changeset(s) or their ancestors have local changes not on the remote:
119 * (glob)
120 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
121 deleting data/d0/f.i
122 $ hg log -T "{node|short}: {desc} {outsidenarrow}\n"
123 *: local change to d3 (glob)
124 *: add d10/f outsidenarrow (glob)
125 *: add d6/f (glob)
126 *: add d5/f outsidenarrow (glob)
127 *: add d3/f (glob)
128 *: add d2/f outsidenarrow (glob)
129 *: add d0/f outsidenarrow (glob)
130 Can restore stripped local changes after widening
131 $ hg tracked --addinclude d0 -q
132 $ hg unbundle .hg/strip-backup/*-narrow.hg -q
133 $ hg --hidden co -r 'desc("local change to d0")' -q
134 $ cat d0/f
135 0
136 local change
137 Pruned commits affecting removed paths should not prevent narrowing
138 $ hg co '.^'
139 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 $ hg debugobsolete `hg log -T '{node}' -r 'desc("local change to d0")'`
141 obsoleted 1 changesets
142 $ hg tracked --removeinclude d0
143 comparing with ssh://user@dummy/master
144 searching for changes
145 looking for local changes to affected paths
146 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
147 deleting data/d0/f.i
148 Updates off of stripped commit if necessary
149 $ hg co -r 'desc("local change to d3")' -q
150 $ echo local change >> d6/f
151 $ hg ci -m 'local change to d6'
152 $ hg tracked --removeinclude d3 --force-delete-local-changes
153 comparing with ssh://user@dummy/master
154 searching for changes
155 looking for local changes to affected paths
156 The following changeset(s) or their ancestors have local changes not on the remote:
157 * (glob)
158 * (glob)
159 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
161 deleting data/d3/f.i
162 $ hg log -T '{desc}\n' -r .
163 add d10/f
164 Updates to nullid if necessary
165 $ hg tracked --addinclude d3 -q
166 $ hg co null -q
167 $ mkdir d3
168 $ echo local change > d3/f
169 $ hg add d3/f
170 $ hg ci -m 'local change to d3'
171 created new head
172 $ hg tracked --removeinclude d3 --force-delete-local-changes
173 comparing with ssh://user@dummy/master
174 searching for changes
175 looking for local changes to affected paths
176 The following changeset(s) or their ancestors have local changes not on the remote:
177 * (glob)
178 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
179 saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
180 deleting data/d3/f.i
181 $ hg id
182 000000000000
183 $ cd ..
184
185 Can remove last include, making repo empty
186 $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5
187 adding changesets
188 adding manifests
189 adding file changes
190 added 2 changesets with 1 changes to 1 files
191 new changesets *:* (glob)
192 updating to branch default
193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
194 $ cd narrow-empty
195 $ hg tracked --removeinclude d0
196 comparing with ssh://user@dummy/master
197 searching for changes
198 looking for local changes to affected paths
199 deleting data/d0/f.i
200 $ hg tracked
201 $ hg files
202 [1]
203 $ test -d d0
204 [1]
205 Do some work in the empty clone
206 $ hg diff --change .
207 $ hg branch foo
208 marked working directory as branch foo
209 (branches are permanent and global, did you want a bookmark?)
210 $ hg ci -m empty
211 $ hg pull -q
212 Can widen the empty clone
213 $ hg tracked --addinclude d0
214 comparing with ssh://user@dummy/master
215 searching for changes
216 no changes found
217 saved backup bundle to $TESTTMP/narrow-empty/.hg/strip-backup/*-widen.hg (glob)
218 adding changesets
219 adding manifests
220 adding file changes
221 added 3 changesets with 1 changes to 1 files
222 new changesets *:* (glob)
223 $ hg tracked
224 I path:d0
225 $ hg files
226 d0/f
227 $ find *
228 d0
229 d0/f
230 $ cd ..
231
232 TODO(martinvonz): test including e.g. d3/g and then removing it once
233 https://bitbucket.org/Google/narrowhg/issues/6 is fixed
234
235 $ hg clone --narrow ssh://user@dummy/master narrow --include d0 --include d3 --include d6 --include d9
236 requesting all changes
237 adding changesets
238 adding manifests
239 adding file changes
240 added 8 changesets with 4 changes to 4 files
241 new changesets *:* (glob)
242 updating to branch default
243 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
244 $ cd narrow
245 $ hg tracked
246 I path:d0
247 I path:d3
248 I path:d6
249 I path:d9
250 $ hg tracked --removeinclude d6
251 comparing with ssh://user@dummy/master
252 searching for changes
253 looking for local changes to affected paths
254 deleting data/d6/f.i
255 $ hg tracked
256 I path:d0
257 I path:d3
258 I path:d9
259 $ hg debugrebuildfncache
260 fncache already up to date
261 $ find *
262 d0
263 d0/f
264 d3
265 d3/f
266 d9
267 d9/f
268 $ hg verify -q
269 $ hg tracked --addexclude d3/f
270 comparing with ssh://user@dummy/master
271 searching for changes
272 looking for local changes to affected paths
273 deleting data/d3/f.i
274 $ hg tracked
275 I path:d0
276 I path:d3
277 I path:d9
278 X path:d3/f
279 $ hg debugrebuildfncache
280 fncache already up to date
281 $ find *
282 d0
283 d0/f
284 d9
285 d9/f
286 $ hg verify -q
287 $ hg tracked --addexclude d0
288 comparing with ssh://user@dummy/master
289 searching for changes
290 looking for local changes to affected paths
291 deleting data/d0/f.i
292 $ hg tracked
293 I path:d3
294 I path:d9
295 X path:d0
296 X path:d3/f
297 $ hg debugrebuildfncache
298 fncache already up to date
299 $ find *
300 d9
301 d9/f
302
303 Make a 15 of changes to d9 to test the path without --verbose
304 (Note: using regexes instead of "* (glob)" because if the test fails, it
305 produces more sensible diffs)
306 $ hg tracked
307 I path:d3
308 I path:d9
309 X path:d0
310 X path:d3/f
311 $ for x in `$TESTDIR/seq.py 1 15`
312 > do
313 > echo local change >> d9/f
314 > hg commit -m "change $x to d9/f"
315 > done
316 $ hg tracked --removeinclude d9
317 comparing with ssh://user@dummy/master
318 searching for changes
319 looking for local changes to affected paths
320 The following changeset(s) or their ancestors have local changes not on the remote:
321 ^[0-9a-f]{12}$ (re)
322 ^[0-9a-f]{12}$ (re)
323 ^[0-9a-f]{12}$ (re)
324 ^[0-9a-f]{12}$ (re)
325 ^[0-9a-f]{12}$ (re)
326 ^[0-9a-f]{12}$ (re)
327 ^[0-9a-f]{12}$ (re)
328 ^[0-9a-f]{12}$ (re)
329 ^[0-9a-f]{12}$ (re)
330 ^[0-9a-f]{12}$ (re)
331 ...and 5 more, use --verbose to list all
332 abort: local changes found
333 (use --force-delete-local-changes to ignore)
334 [255]
335 Now test it *with* verbose.
336 $ hg tracked --removeinclude d9 --verbose
337 comparing with ssh://user@dummy/master
338 searching for changes
339 looking for local changes to affected paths
340 The following changeset(s) or their ancestors have local changes not on the remote:
341 ^[0-9a-f]{12}$ (re)
342 ^[0-9a-f]{12}$ (re)
343 ^[0-9a-f]{12}$ (re)
344 ^[0-9a-f]{12}$ (re)
345 ^[0-9a-f]{12}$ (re)
346 ^[0-9a-f]{12}$ (re)
347 ^[0-9a-f]{12}$ (re)
348 ^[0-9a-f]{12}$ (re)
349 ^[0-9a-f]{12}$ (re)
350 ^[0-9a-f]{12}$ (re)
351 ^[0-9a-f]{12}$ (re)
352 ^[0-9a-f]{12}$ (re)
353 ^[0-9a-f]{12}$ (re)
354 ^[0-9a-f]{12}$ (re)
355 ^[0-9a-f]{12}$ (re)
356 abort: local changes found
357 (use --force-delete-local-changes to ignore)
358 [255]