##// END OF EJS Templates
cat: record the current behavior of wildcard matches in subrepos...
Yuya Nishihara -
r35166:27196b7f stable
parent child Browse files
Show More
@@ -1,169 +1,169
1 1 Subrepositories let you nest external repositories or projects into a
2 2 parent Mercurial repository, and make commands operate on them as a
3 3 group.
4 4
5 5 Mercurial currently supports Mercurial, Git, and Subversion
6 6 subrepositories.
7 7
8 8 Subrepositories are made of three components:
9 9
10 10 1. Nested repository checkouts. They can appear anywhere in the
11 11 parent working directory.
12 12
13 13 2. Nested repository references. They are defined in ``.hgsub``, which
14 14 should be placed in the root of working directory, and
15 15 tell where the subrepository checkouts come from. Mercurial
16 16 subrepositories are referenced like::
17 17
18 18 path/to/nested = https://example.com/nested/repo/path
19 19
20 20 Git and Subversion subrepos are also supported::
21 21
22 22 path/to/nested = [git]git://example.com/nested/repo/path
23 23 path/to/nested = [svn]https://example.com/nested/trunk/path
24 24
25 25 where ``path/to/nested`` is the checkout location relatively to the
26 26 parent Mercurial root, and ``https://example.com/nested/repo/path``
27 27 is the source repository path. The source can also reference a
28 28 filesystem path.
29 29
30 30 Note that ``.hgsub`` does not exist by default in Mercurial
31 31 repositories, you have to create and add it to the parent
32 32 repository before using subrepositories.
33 33
34 34 3. Nested repository states. They are defined in ``.hgsubstate``, which
35 35 is placed in the root of working directory, and
36 36 capture whatever information is required to restore the
37 37 subrepositories to the state they were committed in a parent
38 38 repository changeset. Mercurial automatically record the nested
39 39 repositories states when committing in the parent repository.
40 40
41 41 .. note::
42 42
43 43 The ``.hgsubstate`` file should not be edited manually.
44 44
45 45
46 46 Adding a Subrepository
47 47 ======================
48 48
49 49 If ``.hgsub`` does not exist, create it and add it to the parent
50 50 repository. Clone or checkout the external projects where you want it
51 51 to live in the parent repository. Edit ``.hgsub`` and add the
52 52 subrepository entry as described above. At this point, the
53 53 subrepository is tracked and the next commit will record its state in
54 54 ``.hgsubstate`` and bind it to the committed changeset.
55 55
56 56 Synchronizing a Subrepository
57 57 =============================
58 58
59 59 Subrepos do not automatically track the latest changeset of their
60 60 sources. Instead, they are updated to the changeset that corresponds
61 61 with the changeset checked out in the top-level changeset. This is so
62 62 developers always get a consistent set of compatible code and
63 63 libraries when they update.
64 64
65 65 Thus, updating subrepos is a manual process. Simply check out target
66 66 subrepo at the desired revision, test in the top-level repo, then
67 67 commit in the parent repository to record the new combination.
68 68
69 69 Deleting a Subrepository
70 70 ========================
71 71
72 72 To remove a subrepository from the parent repository, delete its
73 73 reference from ``.hgsub``, then remove its files.
74 74
75 75 Interaction with Mercurial Commands
76 76 ===================================
77 77
78 78 :add: add does not recurse in subrepos unless -S/--subrepos is
79 79 specified. However, if you specify the full path of a file in a
80 80 subrepo, it will be added even without -S/--subrepos specified.
81 81 Subversion subrepositories are currently silently
82 82 ignored.
83 83
84 84 :addremove: addremove does not recurse into subrepos unless
85 85 -S/--subrepos is specified. However, if you specify the full
86 86 path of a directory in a subrepo, addremove will be performed on
87 87 it even without -S/--subrepos being specified. Git and
88 88 Subversion subrepositories will print a warning and continue.
89 89
90 90 :archive: archive does not recurse in subrepositories unless
91 91 -S/--subrepos is specified.
92 92
93 :cat: cat currently only handles exact file matches in subrepos.
93 :cat: Git subrepositories only support exact file matches.
94 94 Subversion subrepositories are currently ignored.
95 95
96 96 :commit: commit creates a consistent snapshot of the state of the
97 97 entire project and its subrepositories. If any subrepositories
98 98 have been modified, Mercurial will abort. Mercurial can be made
99 99 to instead commit all modified subrepositories by specifying
100 100 -S/--subrepos, or setting "ui.commitsubrepos=True" in a
101 101 configuration file (see :hg:`help config`). After there are no
102 102 longer any modified subrepositories, it records their state and
103 103 finally commits it in the parent repository. The --addremove
104 104 option also honors the -S/--subrepos option. However, Git and
105 105 Subversion subrepositories will print a warning and abort.
106 106
107 107 :diff: diff does not recurse in subrepos unless -S/--subrepos is
108 108 specified. Changes are displayed as usual, on the subrepositories
109 109 elements. Subversion subrepositories are currently silently ignored.
110 110
111 111 :files: files does not recurse into subrepos unless -S/--subrepos is
112 112 specified. However, if you specify the full path of a file or
113 113 directory in a subrepo, it will be displayed even without
114 114 -S/--subrepos being specified. Git and Subversion subrepositories
115 115 are currently silently ignored.
116 116
117 117 :forget: forget currently only handles exact file matches in subrepos.
118 118 Git and Subversion subrepositories are currently silently ignored.
119 119
120 120 :incoming: incoming does not recurse in subrepos unless -S/--subrepos
121 121 is specified. Git and Subversion subrepositories are currently
122 122 silently ignored.
123 123
124 124 :outgoing: outgoing does not recurse in subrepos unless -S/--subrepos
125 125 is specified. Git and Subversion subrepositories are currently
126 126 silently ignored.
127 127
128 128 :pull: pull is not recursive since it is not clear what to pull prior
129 129 to running :hg:`update`. Listing and retrieving all
130 130 subrepositories changes referenced by the parent repository pulled
131 131 changesets is expensive at best, impossible in the Subversion
132 132 case.
133 133
134 134 :push: Mercurial will automatically push all subrepositories first
135 135 when the parent repository is being pushed. This ensures new
136 136 subrepository changes are available when referenced by top-level
137 137 repositories. Push is a no-op for Subversion subrepositories.
138 138
139 139 :serve: serve does not recurse into subrepositories unless
140 140 -S/--subrepos is specified. Git and Subversion subrepositories
141 141 are currently silently ignored.
142 142
143 143 :status: status does not recurse into subrepositories unless
144 144 -S/--subrepos is specified. Subrepository changes are displayed as
145 145 regular Mercurial changes on the subrepository
146 146 elements. Subversion subrepositories are currently silently
147 147 ignored.
148 148
149 149 :remove: remove does not recurse into subrepositories unless
150 150 -S/--subrepos is specified. However, if you specify a file or
151 151 directory path in a subrepo, it will be removed even without
152 152 -S/--subrepos. Git and Subversion subrepositories are currently
153 153 silently ignored.
154 154
155 155 :update: update restores the subrepos in the state they were
156 156 originally committed in target changeset. If the recorded
157 157 changeset is not available in the current subrepository, Mercurial
158 158 will pull it in first before updating. This means that updating
159 159 can require network access when using subrepositories.
160 160
161 161 Remapping Subrepositories Sources
162 162 =================================
163 163
164 164 A subrepository source location may change during a project life,
165 165 invalidating references stored in the parent repository history. To
166 166 fix this, rewriting rules can be defined in parent repository ``hgrc``
167 167 file or in Mercurial configuration. See the ``[subpaths]`` section in
168 168 hgrc(5) for more details.
169 169
@@ -1,1931 +1,1943
1 1 Let commit recurse into subrepos by default to match pre-2.0 behavior:
2 2
3 3 $ echo "[ui]" >> $HGRCPATH
4 4 $ echo "commitsubrepos = Yes" >> $HGRCPATH
5 5
6 6 $ hg init t
7 7 $ cd t
8 8
9 9 first revision, no sub
10 10
11 11 $ echo a > a
12 12 $ hg ci -Am0
13 13 adding a
14 14
15 15 add first sub
16 16
17 17 $ echo s = s > .hgsub
18 18 $ hg add .hgsub
19 19 $ hg init s
20 20 $ echo a > s/a
21 21
22 22 Issue2232: committing a subrepo without .hgsub
23 23
24 24 $ hg ci -mbad s
25 25 abort: can't commit subrepos without .hgsub
26 26 [255]
27 27
28 28 $ hg -R s add s/a
29 29 $ hg files -S
30 30 .hgsub
31 31 a
32 32 s/a (glob)
33 33
34 34 $ hg -R s ci -Ams0
35 35 $ hg sum
36 36 parent: 0:f7b1eb17ad24 tip
37 37 0
38 38 branch: default
39 39 commit: 1 added, 1 subrepos
40 40 update: (current)
41 41 phases: 1 draft
42 42 $ hg ci -m1
43 43
44 44 test handling .hgsubstate "added" explicitly.
45 45
46 46 $ hg parents --template '{node}\n{files}\n'
47 47 7cf8cfea66e410e8e3336508dfeec07b3192de51
48 48 .hgsub .hgsubstate
49 49 $ hg rollback -q
50 50 $ hg add .hgsubstate
51 51 $ hg ci -m1
52 52 $ hg parents --template '{node}\n{files}\n'
53 53 7cf8cfea66e410e8e3336508dfeec07b3192de51
54 54 .hgsub .hgsubstate
55 55
56 56 Subrepopath which overlaps with filepath, does not change warnings in remove()
57 57
58 58 $ mkdir snot
59 59 $ touch snot/file
60 60 $ hg remove -S snot/file
61 61 not removing snot/file: file is untracked (glob)
62 62 [1]
63 63 $ hg cat snot/filenot
64 64 snot/filenot: no such file in rev 7cf8cfea66e4 (glob)
65 65 [1]
66 66 $ rm -r snot
67 67
68 68 Revert subrepo and test subrepo fileset keyword:
69 69
70 70 $ echo b > s/a
71 71 $ hg revert --dry-run "set:subrepo('glob:s*')"
72 72 reverting subrepo s
73 73 reverting s/a (glob)
74 74 $ cat s/a
75 75 b
76 76 $ hg revert "set:subrepo('glob:s*')"
77 77 reverting subrepo s
78 78 reverting s/a (glob)
79 79 $ cat s/a
80 80 a
81 81 $ rm s/a.orig
82 82
83 83 Revert subrepo with no backup. The "reverting s/a" line is gone since
84 84 we're really running 'hg update' in the subrepo:
85 85
86 86 $ echo b > s/a
87 87 $ hg revert --no-backup s
88 88 reverting subrepo s
89 89
90 90 Issue2022: update -C
91 91
92 92 $ echo b > s/a
93 93 $ hg sum
94 94 parent: 1:7cf8cfea66e4 tip
95 95 1
96 96 branch: default
97 97 commit: 1 subrepos
98 98 update: (current)
99 99 phases: 2 draft
100 100 $ hg co -C 1
101 101 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 102 $ hg sum
103 103 parent: 1:7cf8cfea66e4 tip
104 104 1
105 105 branch: default
106 106 commit: (clean)
107 107 update: (current)
108 108 phases: 2 draft
109 109
110 110 commands that require a clean repo should respect subrepos
111 111
112 112 $ echo b >> s/a
113 113 $ hg backout tip
114 114 abort: uncommitted changes in subrepository "s"
115 115 [255]
116 116 $ hg revert -C -R s s/a
117 117
118 118 add sub sub
119 119
120 120 $ echo ss = ss > s/.hgsub
121 121 $ hg init s/ss
122 122 $ echo a > s/ss/a
123 123 $ hg -R s add s/.hgsub
124 124 $ hg -R s/ss add s/ss/a
125 125 $ hg sum
126 126 parent: 1:7cf8cfea66e4 tip
127 127 1
128 128 branch: default
129 129 commit: 1 subrepos
130 130 update: (current)
131 131 phases: 2 draft
132 132 $ hg ci -m2
133 133 committing subrepository s
134 134 committing subrepository s/ss (glob)
135 135 $ hg sum
136 136 parent: 2:df30734270ae tip
137 137 2
138 138 branch: default
139 139 commit: (clean)
140 140 update: (current)
141 141 phases: 3 draft
142 142
143 143 test handling .hgsubstate "modified" explicitly.
144 144
145 145 $ hg parents --template '{node}\n{files}\n'
146 146 df30734270ae757feb35e643b7018e818e78a9aa
147 147 .hgsubstate
148 148 $ hg rollback -q
149 149 $ hg status -A .hgsubstate
150 150 M .hgsubstate
151 151 $ hg ci -m2
152 152 $ hg parents --template '{node}\n{files}\n'
153 153 df30734270ae757feb35e643b7018e818e78a9aa
154 154 .hgsubstate
155 155
156 156 bump sub rev (and check it is ignored by ui.commitsubrepos)
157 157
158 158 $ echo b > s/a
159 159 $ hg -R s ci -ms1
160 160 $ hg --config ui.commitsubrepos=no ci -m3
161 161
162 162 leave sub dirty (and check ui.commitsubrepos=no aborts the commit)
163 163
164 164 $ echo c > s/a
165 165 $ hg --config ui.commitsubrepos=no ci -m4
166 166 abort: uncommitted changes in subrepository "s"
167 167 (use --subrepos for recursive commit)
168 168 [255]
169 169 $ hg id
170 170 f6affe3fbfaa+ tip
171 171 $ hg -R s ci -mc
172 172 $ hg id
173 173 f6affe3fbfaa+ tip
174 174 $ echo d > s/a
175 175 $ hg ci -m4
176 176 committing subrepository s
177 177 $ hg tip -R s
178 178 changeset: 4:02dcf1d70411
179 179 tag: tip
180 180 user: test
181 181 date: Thu Jan 01 00:00:00 1970 +0000
182 182 summary: 4
183 183
184 184
185 185 check caching
186 186
187 187 $ hg co 0
188 188 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
189 189 $ hg debugsub
190 190
191 191 restore
192 192
193 193 $ hg co
194 194 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
195 195 $ hg debugsub
196 196 path s
197 197 source s
198 198 revision 02dcf1d704118aee3ee306ccfa1910850d5b05ef
199 199
200 200 new branch for merge tests
201 201
202 202 $ hg co 1
203 203 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
204 204 $ echo t = t >> .hgsub
205 205 $ hg init t
206 206 $ echo t > t/t
207 207 $ hg -R t add t
208 208 adding t/t (glob)
209 209
210 210 5
211 211
212 212 $ hg ci -m5 # add sub
213 213 committing subrepository t
214 214 created new head
215 215 $ echo t2 > t/t
216 216
217 217 6
218 218
219 219 $ hg st -R s
220 220 $ hg ci -m6 # change sub
221 221 committing subrepository t
222 222 $ hg debugsub
223 223 path s
224 224 source s
225 225 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
226 226 path t
227 227 source t
228 228 revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad
229 229 $ echo t3 > t/t
230 230
231 231 7
232 232
233 233 $ hg ci -m7 # change sub again for conflict test
234 234 committing subrepository t
235 235 $ hg rm .hgsub
236 236
237 237 8
238 238
239 239 $ hg ci -m8 # remove sub
240 240
241 241 test handling .hgsubstate "removed" explicitly.
242 242
243 243 $ hg parents --template '{node}\n{files}\n'
244 244 96615c1dad2dc8e3796d7332c77ce69156f7b78e
245 245 .hgsub .hgsubstate
246 246 $ hg rollback -q
247 247 $ hg remove .hgsubstate
248 248 $ hg ci -m8
249 249 $ hg parents --template '{node}\n{files}\n'
250 250 96615c1dad2dc8e3796d7332c77ce69156f7b78e
251 251 .hgsub .hgsubstate
252 252
253 253 merge tests
254 254
255 255 $ hg co -C 3
256 256 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
257 257 $ hg merge 5 # test adding
258 258 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
259 259 (branch merge, don't forget to commit)
260 260 $ hg debugsub
261 261 path s
262 262 source s
263 263 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
264 264 path t
265 265 source t
266 266 revision 60ca1237c19474e7a3978b0dc1ca4e6f36d51382
267 267 $ hg ci -m9
268 268 created new head
269 269 $ hg merge 6 --debug # test change
270 270 searching for copies back to rev 2
271 271 resolving manifests
272 272 branchmerge: True, force: False, partial: False
273 273 ancestor: 1f14a2e2d3ec, local: f0d2028bf86d+, remote: 1831e14459c4
274 274 starting 4 threads for background file closing (?)
275 275 .hgsubstate: versions differ -> m (premerge)
276 276 subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
277 277 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg
278 278 getting subrepo t
279 279 resolving manifests
280 280 branchmerge: False, force: False, partial: False
281 281 ancestor: 60ca1237c194, local: 60ca1237c194+, remote: 6747d179aa9a
282 282 t: remote is newer -> g
283 283 getting t
284 284 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
285 285 (branch merge, don't forget to commit)
286 286 $ hg debugsub
287 287 path s
288 288 source s
289 289 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
290 290 path t
291 291 source t
292 292 revision 6747d179aa9a688023c4b0cad32e4c92bb7f34ad
293 293 $ echo conflict > t/t
294 294 $ hg ci -m10
295 295 committing subrepository t
296 296 $ HGMERGE=internal:merge hg merge --debug 7 # test conflict
297 297 searching for copies back to rev 2
298 298 resolving manifests
299 299 branchmerge: True, force: False, partial: False
300 300 ancestor: 1831e14459c4, local: e45c8b14af55+, remote: f94576341bcf
301 301 starting 4 threads for background file closing (?)
302 302 .hgsubstate: versions differ -> m (premerge)
303 303 subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4
304 304 subrepo t: both sides changed
305 305 subrepository t diverged (local revision: 20a0db6fbf6c, remote revision: 7af322bc1198)
306 306 starting 4 threads for background file closing (?)
307 307 (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
308 308 merging subrepository "t"
309 309 searching for copies back to rev 2
310 310 resolving manifests
311 311 branchmerge: True, force: False, partial: False
312 312 ancestor: 6747d179aa9a, local: 20a0db6fbf6c+, remote: 7af322bc1198
313 313 preserving t for resolve of t
314 314 starting 4 threads for background file closing (?)
315 315 t: versions differ -> m (premerge)
316 316 picked tool ':merge' for t (binary False symlink False changedelete False)
317 317 merging t
318 318 my t@20a0db6fbf6c+ other t@7af322bc1198 ancestor t@6747d179aa9a
319 319 t: versions differ -> m (merge)
320 320 picked tool ':merge' for t (binary False symlink False changedelete False)
321 321 my t@20a0db6fbf6c+ other t@7af322bc1198 ancestor t@6747d179aa9a
322 322 warning: conflicts while merging t! (edit, then use 'hg resolve --mark')
323 323 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
324 324 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
325 325 subrepo t: merge with t:7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4:hg
326 326 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
327 327 (branch merge, don't forget to commit)
328 328
329 329 should conflict
330 330
331 331 $ cat t/t
332 332 <<<<<<< local: 20a0db6fbf6c - test: 10
333 333 conflict
334 334 =======
335 335 t3
336 336 >>>>>>> other: 7af322bc1198 - test: 7
337 337
338 338 11: remove subrepo t
339 339
340 340 $ hg co -C 5
341 341 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
342 342 $ hg revert -r 4 .hgsub # remove t
343 343 $ hg ci -m11
344 344 created new head
345 345 $ hg debugsub
346 346 path s
347 347 source s
348 348 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
349 349
350 350 local removed, remote changed, keep changed
351 351
352 352 $ hg merge 6
353 353 remote [merge rev] changed subrepository t which local [working copy] removed
354 354 use (c)hanged version or (d)elete? c
355 355 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
356 356 (branch merge, don't forget to commit)
357 357 BROKEN: should include subrepo t
358 358 $ hg debugsub
359 359 path s
360 360 source s
361 361 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
362 362 $ cat .hgsubstate
363 363 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
364 364 6747d179aa9a688023c4b0cad32e4c92bb7f34ad t
365 365 $ hg ci -m 'local removed, remote changed, keep changed'
366 366 BROKEN: should include subrepo t
367 367 $ hg debugsub
368 368 path s
369 369 source s
370 370 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
371 371 BROKEN: should include subrepo t
372 372 $ cat .hgsubstate
373 373 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
374 374 $ cat t/t
375 375 t2
376 376
377 377 local removed, remote changed, keep removed
378 378
379 379 $ hg co -C 11
380 380 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
381 381 $ hg merge --config ui.interactive=true 6 <<EOF
382 382 > d
383 383 > EOF
384 384 remote [merge rev] changed subrepository t which local [working copy] removed
385 385 use (c)hanged version or (d)elete? d
386 386 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
387 387 (branch merge, don't forget to commit)
388 388 $ hg debugsub
389 389 path s
390 390 source s
391 391 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
392 392 $ cat .hgsubstate
393 393 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
394 394 $ hg ci -m 'local removed, remote changed, keep removed'
395 395 created new head
396 396 $ hg debugsub
397 397 path s
398 398 source s
399 399 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
400 400 $ cat .hgsubstate
401 401 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
402 402
403 403 local changed, remote removed, keep changed
404 404
405 405 $ hg co -C 6
406 406 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
407 407 $ hg merge 11
408 408 local [working copy] changed subrepository t which remote [merge rev] removed
409 409 use (c)hanged version or (d)elete? c
410 410 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
411 411 (branch merge, don't forget to commit)
412 412 BROKEN: should include subrepo t
413 413 $ hg debugsub
414 414 path s
415 415 source s
416 416 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
417 417 BROKEN: should include subrepo t
418 418 $ cat .hgsubstate
419 419 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
420 420 $ hg ci -m 'local changed, remote removed, keep changed'
421 421 created new head
422 422 BROKEN: should include subrepo t
423 423 $ hg debugsub
424 424 path s
425 425 source s
426 426 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
427 427 BROKEN: should include subrepo t
428 428 $ cat .hgsubstate
429 429 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
430 430 $ cat t/t
431 431 t2
432 432
433 433 local changed, remote removed, keep removed
434 434
435 435 $ hg co -C 6
436 436 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
437 437 $ hg merge --config ui.interactive=true 11 <<EOF
438 438 > d
439 439 > EOF
440 440 local [working copy] changed subrepository t which remote [merge rev] removed
441 441 use (c)hanged version or (d)elete? d
442 442 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
443 443 (branch merge, don't forget to commit)
444 444 $ hg debugsub
445 445 path s
446 446 source s
447 447 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
448 448 $ cat .hgsubstate
449 449 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
450 450 $ hg ci -m 'local changed, remote removed, keep removed'
451 451 created new head
452 452 $ hg debugsub
453 453 path s
454 454 source s
455 455 revision e4ece1bf43360ddc8f6a96432201a37b7cd27ae4
456 456 $ cat .hgsubstate
457 457 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
458 458
459 459 clean up to avoid having to fix up the tests below
460 460
461 461 $ hg co -C 10
462 462 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
463 463 $ cat >> $HGRCPATH <<EOF
464 464 > [extensions]
465 465 > strip=
466 466 > EOF
467 467 $ hg strip -r 11:15
468 468 saved backup bundle to $TESTTMP/t/.hg/strip-backup/*-backup.hg (glob)
469 469
470 470 clone
471 471
472 472 $ cd ..
473 473 $ hg clone t tc
474 474 updating to branch default
475 475 cloning subrepo s from $TESTTMP/t/s
476 476 cloning subrepo s/ss from $TESTTMP/t/s/ss (glob)
477 477 cloning subrepo t from $TESTTMP/t/t
478 478 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
479 479 $ cd tc
480 480 $ hg debugsub
481 481 path s
482 482 source s
483 483 revision fc627a69481fcbe5f1135069e8a3881c023e4cf5
484 484 path t
485 485 source t
486 486 revision 20a0db6fbf6c3d2836e6519a642ae929bfc67c0e
487 487 $ cd ..
488 488
489 489 clone with subrepo disabled (update should fail)
490 490
491 491 $ hg clone t -U tc2 --config subrepos.allowed=false
492 492 $ hg update -R tc2 --config subrepos.allowed=false
493 493 abort: subrepos not enabled
494 494 (see 'hg help config.subrepos' for details)
495 495 [255]
496 496 $ ls tc2
497 497 a
498 498
499 499 $ hg clone t tc3 --config subrepos.allowed=false
500 500 updating to branch default
501 501 abort: subrepos not enabled
502 502 (see 'hg help config.subrepos' for details)
503 503 [255]
504 504 $ ls tc3
505 505 a
506 506
507 507 And again with just the hg type disabled
508 508
509 509 $ hg clone t -U tc4 --config subrepos.hg:allowed=false
510 510 $ hg update -R tc4 --config subrepos.hg:allowed=false
511 511 abort: hg subrepos not allowed
512 512 (see 'hg help config.subrepos' for details)
513 513 [255]
514 514 $ ls tc4
515 515 a
516 516
517 517 $ hg clone t tc5 --config subrepos.hg:allowed=false
518 518 updating to branch default
519 519 abort: hg subrepos not allowed
520 520 (see 'hg help config.subrepos' for details)
521 521 [255]
522 522 $ ls tc5
523 523 a
524 524
525 525 push
526 526
527 527 $ cd tc
528 528 $ echo bah > t/t
529 529 $ hg ci -m11
530 530 committing subrepository t
531 531 $ hg push
532 532 pushing to $TESTTMP/t (glob)
533 533 no changes made to subrepo s/ss since last push to $TESTTMP/t/s/ss (glob)
534 534 no changes made to subrepo s since last push to $TESTTMP/t/s
535 535 pushing subrepo t to $TESTTMP/t/t
536 536 searching for changes
537 537 adding changesets
538 538 adding manifests
539 539 adding file changes
540 540 added 1 changesets with 1 changes to 1 files
541 541 searching for changes
542 542 adding changesets
543 543 adding manifests
544 544 adding file changes
545 545 added 1 changesets with 1 changes to 1 files
546 546
547 547 push -f
548 548
549 549 $ echo bah > s/a
550 550 $ hg ci -m12
551 551 committing subrepository s
552 552 $ hg push
553 553 pushing to $TESTTMP/t (glob)
554 554 no changes made to subrepo s/ss since last push to $TESTTMP/t/s/ss (glob)
555 555 pushing subrepo s to $TESTTMP/t/s
556 556 searching for changes
557 557 abort: push creates new remote head 12a213df6fa9! (in subrepository "s")
558 558 (merge or see 'hg help push' for details about pushing new heads)
559 559 [255]
560 560 $ hg push -f
561 561 pushing to $TESTTMP/t (glob)
562 562 pushing subrepo s/ss to $TESTTMP/t/s/ss (glob)
563 563 searching for changes
564 564 no changes found
565 565 pushing subrepo s to $TESTTMP/t/s
566 566 searching for changes
567 567 adding changesets
568 568 adding manifests
569 569 adding file changes
570 570 added 1 changesets with 1 changes to 1 files (+1 heads)
571 571 pushing subrepo t to $TESTTMP/t/t
572 572 searching for changes
573 573 no changes found
574 574 searching for changes
575 575 adding changesets
576 576 adding manifests
577 577 adding file changes
578 578 added 1 changesets with 1 changes to 1 files
579 579
580 580 check that unmodified subrepos are not pushed
581 581
582 582 $ hg clone . ../tcc
583 583 updating to branch default
584 584 cloning subrepo s from $TESTTMP/tc/s
585 585 cloning subrepo s/ss from $TESTTMP/tc/s/ss (glob)
586 586 cloning subrepo t from $TESTTMP/tc/t
587 587 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
588 588
589 589 the subrepos on the new clone have nothing to push to its source
590 590
591 591 $ hg push -R ../tcc .
592 592 pushing to .
593 593 no changes made to subrepo s/ss since last push to s/ss (glob)
594 594 no changes made to subrepo s since last push to s
595 595 no changes made to subrepo t since last push to t
596 596 searching for changes
597 597 no changes found
598 598 [1]
599 599
600 600 the subrepos on the source do not have a clean store versus the clone target
601 601 because they were never explicitly pushed to the source
602 602
603 603 $ hg push ../tcc
604 604 pushing to ../tcc
605 605 pushing subrepo s/ss to ../tcc/s/ss (glob)
606 606 searching for changes
607 607 no changes found
608 608 pushing subrepo s to ../tcc/s
609 609 searching for changes
610 610 no changes found
611 611 pushing subrepo t to ../tcc/t
612 612 searching for changes
613 613 no changes found
614 614 searching for changes
615 615 no changes found
616 616 [1]
617 617
618 618 after push their stores become clean
619 619
620 620 $ hg push ../tcc
621 621 pushing to ../tcc
622 622 no changes made to subrepo s/ss since last push to ../tcc/s/ss (glob)
623 623 no changes made to subrepo s since last push to ../tcc/s
624 624 no changes made to subrepo t since last push to ../tcc/t
625 625 searching for changes
626 626 no changes found
627 627 [1]
628 628
629 629 updating a subrepo to a different revision or changing
630 630 its working directory does not make its store dirty
631 631
632 632 $ hg -R s update '.^'
633 633 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
634 634 $ hg push
635 635 pushing to $TESTTMP/t (glob)
636 636 no changes made to subrepo s/ss since last push to $TESTTMP/t/s/ss (glob)
637 637 no changes made to subrepo s since last push to $TESTTMP/t/s
638 638 no changes made to subrepo t since last push to $TESTTMP/t/t
639 639 searching for changes
640 640 no changes found
641 641 [1]
642 642 $ echo foo >> s/a
643 643 $ hg push
644 644 pushing to $TESTTMP/t (glob)
645 645 no changes made to subrepo s/ss since last push to $TESTTMP/t/s/ss (glob)
646 646 no changes made to subrepo s since last push to $TESTTMP/t/s
647 647 no changes made to subrepo t since last push to $TESTTMP/t/t
648 648 searching for changes
649 649 no changes found
650 650 [1]
651 651 $ hg -R s update -C tip
652 652 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
653 653
654 654 committing into a subrepo makes its store (but not its parent's store) dirty
655 655
656 656 $ echo foo >> s/ss/a
657 657 $ hg -R s/ss commit -m 'test dirty store detection'
658 658
659 659 $ hg out -S -r `hg log -r tip -T "{node|short}"`
660 660 comparing with $TESTTMP/t (glob)
661 661 searching for changes
662 662 no changes found
663 663 comparing with $TESTTMP/t/s
664 664 searching for changes
665 665 no changes found
666 666 comparing with $TESTTMP/t/s/ss
667 667 searching for changes
668 668 changeset: 1:79ea5566a333
669 669 tag: tip
670 670 user: test
671 671 date: Thu Jan 01 00:00:00 1970 +0000
672 672 summary: test dirty store detection
673 673
674 674 comparing with $TESTTMP/t/t
675 675 searching for changes
676 676 no changes found
677 677
678 678 $ hg push
679 679 pushing to $TESTTMP/t (glob)
680 680 pushing subrepo s/ss to $TESTTMP/t/s/ss (glob)
681 681 searching for changes
682 682 adding changesets
683 683 adding manifests
684 684 adding file changes
685 685 added 1 changesets with 1 changes to 1 files
686 686 no changes made to subrepo s since last push to $TESTTMP/t/s
687 687 no changes made to subrepo t since last push to $TESTTMP/t/t
688 688 searching for changes
689 689 no changes found
690 690 [1]
691 691
692 692 a subrepo store may be clean versus one repo but not versus another
693 693
694 694 $ hg push
695 695 pushing to $TESTTMP/t (glob)
696 696 no changes made to subrepo s/ss since last push to $TESTTMP/t/s/ss (glob)
697 697 no changes made to subrepo s since last push to $TESTTMP/t/s
698 698 no changes made to subrepo t since last push to $TESTTMP/t/t
699 699 searching for changes
700 700 no changes found
701 701 [1]
702 702 $ hg push ../tcc
703 703 pushing to ../tcc
704 704 pushing subrepo s/ss to ../tcc/s/ss (glob)
705 705 searching for changes
706 706 adding changesets
707 707 adding manifests
708 708 adding file changes
709 709 added 1 changesets with 1 changes to 1 files
710 710 no changes made to subrepo s since last push to ../tcc/s
711 711 no changes made to subrepo t since last push to ../tcc/t
712 712 searching for changes
713 713 no changes found
714 714 [1]
715 715
716 716 update
717 717
718 718 $ cd ../t
719 719 $ hg up -C # discard our earlier merge
720 720 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
721 721 updated to "c373c8102e68: 12"
722 722 2 other heads for branch "default"
723 723 $ echo blah > t/t
724 724 $ hg ci -m13
725 725 committing subrepository t
726 726
727 727 backout calls revert internally with minimal opts, which should not raise
728 728 KeyError
729 729
730 730 $ hg backout ".^" --no-commit
731 731 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
732 732 changeset c373c8102e68 backed out, don't forget to commit.
733 733
734 734 $ hg up -C # discard changes
735 735 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
736 736 updated to "925c17564ef8: 13"
737 737 2 other heads for branch "default"
738 738
739 739 pull
740 740
741 741 $ cd ../tc
742 742 $ hg pull
743 743 pulling from $TESTTMP/t (glob)
744 744 searching for changes
745 745 adding changesets
746 746 adding manifests
747 747 adding file changes
748 748 added 1 changesets with 1 changes to 1 files
749 749 new changesets 925c17564ef8
750 750 (run 'hg update' to get a working copy)
751 751
752 752 should pull t
753 753
754 754 $ hg incoming -S -r `hg log -r tip -T "{node|short}"`
755 755 comparing with $TESTTMP/t (glob)
756 756 no changes found
757 757 comparing with $TESTTMP/t/s
758 758 searching for changes
759 759 no changes found
760 760 comparing with $TESTTMP/t/s/ss
761 761 searching for changes
762 762 no changes found
763 763 comparing with $TESTTMP/t/t
764 764 searching for changes
765 765 changeset: 5:52c0adc0515a
766 766 tag: tip
767 767 user: test
768 768 date: Thu Jan 01 00:00:00 1970 +0000
769 769 summary: 13
770 770
771 771
772 772 $ hg up
773 773 pulling subrepo t from $TESTTMP/t/t
774 774 searching for changes
775 775 adding changesets
776 776 adding manifests
777 777 adding file changes
778 778 added 1 changesets with 1 changes to 1 files
779 779 new changesets 52c0adc0515a
780 780 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
781 781 updated to "925c17564ef8: 13"
782 782 2 other heads for branch "default"
783 783 $ cat t/t
784 784 blah
785 785
786 786 bogus subrepo path aborts
787 787
788 788 $ echo 'bogus=[boguspath' >> .hgsub
789 789 $ hg ci -m 'bogus subrepo path'
790 790 abort: missing ] in subrepository source
791 791 [255]
792 792
793 793 Issue1986: merge aborts when trying to merge a subrepo that
794 794 shouldn't need merging
795 795
796 796 # subrepo layout
797 797 #
798 798 # o 5 br
799 799 # /|
800 800 # o | 4 default
801 801 # | |
802 802 # | o 3 br
803 803 # |/|
804 804 # o | 2 default
805 805 # | |
806 806 # | o 1 br
807 807 # |/
808 808 # o 0 default
809 809
810 810 $ cd ..
811 811 $ rm -rf sub
812 812 $ hg init main
813 813 $ cd main
814 814 $ hg init s
815 815 $ cd s
816 816 $ echo a > a
817 817 $ hg ci -Am1
818 818 adding a
819 819 $ hg branch br
820 820 marked working directory as branch br
821 821 (branches are permanent and global, did you want a bookmark?)
822 822 $ echo a >> a
823 823 $ hg ci -m1
824 824 $ hg up default
825 825 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
826 826 $ echo b > b
827 827 $ hg ci -Am1
828 828 adding b
829 829 $ hg up br
830 830 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
831 831 $ hg merge tip
832 832 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
833 833 (branch merge, don't forget to commit)
834 834 $ hg ci -m1
835 835 $ hg up 2
836 836 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
837 837 $ echo c > c
838 838 $ hg ci -Am1
839 839 adding c
840 840 $ hg up 3
841 841 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
842 842 $ hg merge 4
843 843 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
844 844 (branch merge, don't forget to commit)
845 845 $ hg ci -m1
846 846
847 847 # main repo layout:
848 848 #
849 849 # * <-- try to merge default into br again
850 850 # .`|
851 851 # . o 5 br --> substate = 5
852 852 # . |
853 853 # o | 4 default --> substate = 4
854 854 # | |
855 855 # | o 3 br --> substate = 2
856 856 # |/|
857 857 # o | 2 default --> substate = 2
858 858 # | |
859 859 # | o 1 br --> substate = 3
860 860 # |/
861 861 # o 0 default --> substate = 2
862 862
863 863 $ cd ..
864 864 $ echo 's = s' > .hgsub
865 865 $ hg -R s up 2
866 866 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
867 867 $ hg ci -Am1
868 868 adding .hgsub
869 869 $ hg branch br
870 870 marked working directory as branch br
871 871 (branches are permanent and global, did you want a bookmark?)
872 872 $ echo b > b
873 873 $ hg -R s up 3
874 874 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
875 875 $ hg ci -Am1
876 876 adding b
877 877 $ hg up default
878 878 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
879 879 $ echo c > c
880 880 $ hg ci -Am1
881 881 adding c
882 882 $ hg up 1
883 883 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
884 884 $ hg merge 2
885 885 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
886 886 (branch merge, don't forget to commit)
887 887 $ hg ci -m1
888 888 $ hg up 2
889 889 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
890 890 $ hg -R s up 4
891 891 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
892 892 $ echo d > d
893 893 $ hg ci -Am1
894 894 adding d
895 895 $ hg up 3
896 896 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
897 897 $ hg -R s up 5
898 898 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
899 899 $ echo e > e
900 900 $ hg ci -Am1
901 901 adding e
902 902
903 903 $ hg up 5
904 904 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
905 905 $ hg merge 4 # try to merge default into br again
906 906 subrepository s diverged (local revision: f8f13b33206e, remote revision: a3f9062a4f88)
907 907 (M)erge, keep (l)ocal [working copy] or keep (r)emote [merge rev]? m
908 908 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
909 909 (branch merge, don't forget to commit)
910 910 $ cd ..
911 911
912 912 test subrepo delete from .hgsubstate
913 913
914 914 $ hg init testdelete
915 915 $ mkdir testdelete/nested testdelete/nested2
916 916 $ hg init testdelete/nested
917 917 $ hg init testdelete/nested2
918 918 $ echo test > testdelete/nested/foo
919 919 $ echo test > testdelete/nested2/foo
920 920 $ hg -R testdelete/nested add
921 921 adding testdelete/nested/foo (glob)
922 922 $ hg -R testdelete/nested2 add
923 923 adding testdelete/nested2/foo (glob)
924 924 $ hg -R testdelete/nested ci -m test
925 925 $ hg -R testdelete/nested2 ci -m test
926 926 $ echo nested = nested > testdelete/.hgsub
927 927 $ echo nested2 = nested2 >> testdelete/.hgsub
928 928 $ hg -R testdelete add
929 929 adding testdelete/.hgsub (glob)
930 930 $ hg -R testdelete ci -m "nested 1 & 2 added"
931 931 $ echo nested = nested > testdelete/.hgsub
932 932 $ hg -R testdelete ci -m "nested 2 deleted"
933 933 $ cat testdelete/.hgsubstate
934 934 bdf5c9a3103743d900b12ae0db3ffdcfd7b0d878 nested
935 935 $ hg -R testdelete remove testdelete/.hgsub
936 936 $ hg -R testdelete ci -m ".hgsub deleted"
937 937 $ cat testdelete/.hgsubstate
938 938 bdf5c9a3103743d900b12ae0db3ffdcfd7b0d878 nested
939 939
940 940 test repository cloning
941 941
942 942 $ mkdir mercurial mercurial2
943 943 $ hg init nested_absolute
944 944 $ echo test > nested_absolute/foo
945 945 $ hg -R nested_absolute add
946 946 adding nested_absolute/foo (glob)
947 947 $ hg -R nested_absolute ci -mtest
948 948 $ cd mercurial
949 949 $ hg init nested_relative
950 950 $ echo test2 > nested_relative/foo2
951 951 $ hg -R nested_relative add
952 952 adding nested_relative/foo2 (glob)
953 953 $ hg -R nested_relative ci -mtest2
954 954 $ hg init main
955 955 $ echo "nested_relative = ../nested_relative" > main/.hgsub
956 956 $ echo "nested_absolute = `pwd`/nested_absolute" >> main/.hgsub
957 957 $ hg -R main add
958 958 adding main/.hgsub (glob)
959 959 $ hg -R main ci -m "add subrepos"
960 960 $ cd ..
961 961 $ hg clone mercurial/main mercurial2/main
962 962 updating to branch default
963 963 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
964 964 $ cat mercurial2/main/nested_absolute/.hg/hgrc \
965 965 > mercurial2/main/nested_relative/.hg/hgrc
966 966 [paths]
967 967 default = $TESTTMP/mercurial/nested_absolute
968 968 [paths]
969 969 default = $TESTTMP/mercurial/nested_relative
970 970 $ rm -rf mercurial mercurial2
971 971
972 972 Issue1977: multirepo push should fail if subrepo push fails
973 973
974 974 $ hg init repo
975 975 $ hg init repo/s
976 976 $ echo a > repo/s/a
977 977 $ hg -R repo/s ci -Am0
978 978 adding a
979 979 $ echo s = s > repo/.hgsub
980 980 $ hg -R repo ci -Am1
981 981 adding .hgsub
982 982 $ hg clone repo repo2
983 983 updating to branch default
984 984 cloning subrepo s from $TESTTMP/repo/s
985 985 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
986 986 $ hg -q -R repo2 pull -u
987 987 $ echo 1 > repo2/s/a
988 988 $ hg -R repo2/s ci -m2
989 989 $ hg -q -R repo2/s push
990 990 $ hg -R repo2/s up -C 0
991 991 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
992 992 $ echo 2 > repo2/s/b
993 993 $ hg -R repo2/s ci -m3 -A
994 994 adding b
995 995 created new head
996 996 $ hg -R repo2 ci -m3
997 997 $ hg -q -R repo2 push
998 998 abort: push creates new remote head cc505f09a8b2! (in subrepository "s")
999 999 (merge or see 'hg help push' for details about pushing new heads)
1000 1000 [255]
1001 1001 $ hg -R repo update
1002 1002 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1003 1003
1004 1004 test if untracked file is not overwritten
1005 1005
1006 1006 (this also tests that updated .hgsubstate is treated as "modified",
1007 1007 when 'merge.update()' is aborted before 'merge.recordupdates()', even
1008 1008 if none of mode, size and timestamp of it isn't changed on the
1009 1009 filesystem (see also issue4583))
1010 1010
1011 1011 $ echo issue3276_ok > repo/s/b
1012 1012 $ hg -R repo2 push -f -q
1013 1013 $ touch -t 200001010000 repo/.hgsubstate
1014 1014
1015 1015 $ cat >> repo/.hg/hgrc <<EOF
1016 1016 > [fakedirstatewritetime]
1017 1017 > # emulate invoking dirstate.write() via repo.status()
1018 1018 > # at 2000-01-01 00:00
1019 1019 > fakenow = 200001010000
1020 1020 >
1021 1021 > [extensions]
1022 1022 > fakedirstatewritetime = $TESTDIR/fakedirstatewritetime.py
1023 1023 > EOF
1024 1024 $ hg -R repo update
1025 1025 b: untracked file differs
1026 1026 abort: untracked files in working directory differ from files in requested revision (in subrepository "s")
1027 1027 [255]
1028 1028 $ cat >> repo/.hg/hgrc <<EOF
1029 1029 > [extensions]
1030 1030 > fakedirstatewritetime = !
1031 1031 > EOF
1032 1032
1033 1033 $ cat repo/s/b
1034 1034 issue3276_ok
1035 1035 $ rm repo/s/b
1036 1036 $ touch -t 200001010000 repo/.hgsubstate
1037 1037 $ hg -R repo revert --all
1038 1038 reverting repo/.hgsubstate (glob)
1039 1039 reverting subrepo s
1040 1040 $ hg -R repo update
1041 1041 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1042 1042 $ cat repo/s/b
1043 1043 2
1044 1044 $ rm -rf repo2 repo
1045 1045
1046 1046
1047 1047 Issue1852 subrepos with relative paths always push/pull relative to default
1048 1048
1049 1049 Prepare a repo with subrepo
1050 1050
1051 1051 $ hg init issue1852a
1052 1052 $ cd issue1852a
1053 1053 $ hg init sub/repo
1054 1054 $ echo test > sub/repo/foo
1055 1055 $ hg -R sub/repo add sub/repo/foo
1056 1056 $ echo sub/repo = sub/repo > .hgsub
1057 1057 $ hg add .hgsub
1058 1058 $ hg ci -mtest
1059 1059 committing subrepository sub/repo (glob)
1060 1060 $ echo test >> sub/repo/foo
1061 1061 $ hg ci -mtest
1062 1062 committing subrepository sub/repo (glob)
1063 1063 $ hg cat sub/repo/foo
1064 1064 test
1065 1065 test
1066 1066 $ hg cat sub/repo/foo -Tjson | sed 's|\\\\|/|g'
1067 1067 [
1068 1068 {
1069 1069 "abspath": "foo",
1070 1070 "data": "test\ntest\n",
1071 1071 "path": "sub/repo/foo"
1072 1072 }
1073 1073 ]
1074
1075 non-exact match:
1076
1077 $ hg cat -T '{path}\n' 'glob:**'
1078 .hgsub
1079 .hgsubstate
1080 sub/repo/foo (glob)
1081 $ hg cat -T '{path}\n' 're:^sub'
1082 sub/repo/foo (glob)
1083
1084 missing subrepos in working directory:
1085
1074 1086 $ mkdir -p tmp/sub/repo
1075 1087 $ hg cat -r 0 --output tmp/%p_p sub/repo/foo
1076 1088 $ cat tmp/sub/repo/foo_p
1077 1089 test
1078 1090 $ mv sub/repo sub_
1079 1091 $ hg cat sub/repo/baz
1080 1092 skipping missing subrepository: sub/repo
1081 1093 [1]
1082 1094 $ rm -rf sub/repo
1083 1095 $ mv sub_ sub/repo
1084 1096 $ cd ..
1085 1097
1086 1098 Create repo without default path, pull top repo, and see what happens on update
1087 1099
1088 1100 $ hg init issue1852b
1089 1101 $ hg -R issue1852b pull issue1852a
1090 1102 pulling from issue1852a
1091 1103 requesting all changes
1092 1104 adding changesets
1093 1105 adding manifests
1094 1106 adding file changes
1095 1107 added 2 changesets with 3 changes to 2 files
1096 1108 new changesets 19487b456929:be5eb94e7215
1097 1109 (run 'hg update' to get a working copy)
1098 1110 $ hg -R issue1852b update
1099 1111 abort: default path for subrepository not found (in subrepository "sub/repo") (glob)
1100 1112 [255]
1101 1113
1102 1114 Ensure a full traceback, not just the SubrepoAbort part
1103 1115
1104 1116 $ hg -R issue1852b update --traceback 2>&1 | grep 'raise error\.Abort'
1105 1117 raise error.Abort(_("default path for subrepository not found"))
1106 1118
1107 1119 Pull -u now doesn't help
1108 1120
1109 1121 $ hg -R issue1852b pull -u issue1852a
1110 1122 pulling from issue1852a
1111 1123 searching for changes
1112 1124 no changes found
1113 1125
1114 1126 Try the same, but with pull -u
1115 1127
1116 1128 $ hg init issue1852c
1117 1129 $ hg -R issue1852c pull -r0 -u issue1852a
1118 1130 pulling from issue1852a
1119 1131 adding changesets
1120 1132 adding manifests
1121 1133 adding file changes
1122 1134 added 1 changesets with 2 changes to 2 files
1123 1135 new changesets 19487b456929
1124 1136 cloning subrepo sub/repo from issue1852a/sub/repo (glob)
1125 1137 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1126 1138
1127 1139 Try to push from the other side
1128 1140
1129 1141 $ hg -R issue1852a push `pwd`/issue1852c
1130 1142 pushing to $TESTTMP/issue1852c (glob)
1131 1143 pushing subrepo sub/repo to $TESTTMP/issue1852c/sub/repo (glob)
1132 1144 searching for changes
1133 1145 no changes found
1134 1146 searching for changes
1135 1147 adding changesets
1136 1148 adding manifests
1137 1149 adding file changes
1138 1150 added 1 changesets with 1 changes to 1 files
1139 1151
1140 1152 Incoming and outgoing should not use the default path:
1141 1153
1142 1154 $ hg clone -q issue1852a issue1852d
1143 1155 $ hg -R issue1852d outgoing --subrepos issue1852c
1144 1156 comparing with issue1852c
1145 1157 searching for changes
1146 1158 no changes found
1147 1159 comparing with issue1852c/sub/repo
1148 1160 searching for changes
1149 1161 no changes found
1150 1162 [1]
1151 1163 $ hg -R issue1852d incoming --subrepos issue1852c
1152 1164 comparing with issue1852c
1153 1165 searching for changes
1154 1166 no changes found
1155 1167 comparing with issue1852c/sub/repo
1156 1168 searching for changes
1157 1169 no changes found
1158 1170 [1]
1159 1171
1160 1172 Check that merge of a new subrepo doesn't write the uncommitted state to
1161 1173 .hgsubstate (issue4622)
1162 1174
1163 1175 $ hg init issue1852a/addedsub
1164 1176 $ echo zzz > issue1852a/addedsub/zz.txt
1165 1177 $ hg -R issue1852a/addedsub ci -Aqm "initial ZZ"
1166 1178
1167 1179 $ hg clone issue1852a/addedsub issue1852d/addedsub
1168 1180 updating to branch default
1169 1181 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1170 1182
1171 1183 $ echo def > issue1852a/sub/repo/foo
1172 1184 $ hg -R issue1852a ci -SAm 'tweaked subrepo'
1173 1185 adding tmp/sub/repo/foo_p
1174 1186 committing subrepository sub/repo (glob)
1175 1187
1176 1188 $ echo 'addedsub = addedsub' >> issue1852d/.hgsub
1177 1189 $ echo xyz > issue1852d/sub/repo/foo
1178 1190 $ hg -R issue1852d pull -u
1179 1191 pulling from $TESTTMP/issue1852a (glob)
1180 1192 searching for changes
1181 1193 adding changesets
1182 1194 adding manifests
1183 1195 adding file changes
1184 1196 added 1 changesets with 2 changes to 2 files
1185 1197 new changesets c82b79fdcc5b
1186 1198 subrepository sub/repo diverged (local revision: f42d5c7504a8, remote revision: 46cd4aac504c)
1187 1199 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1188 1200 pulling subrepo sub/repo from $TESTTMP/issue1852a/sub/repo (glob)
1189 1201 searching for changes
1190 1202 adding changesets
1191 1203 adding manifests
1192 1204 adding file changes
1193 1205 added 1 changesets with 1 changes to 1 files
1194 1206 new changesets 46cd4aac504c
1195 1207 subrepository sources for sub/repo differ (glob)
1196 1208 use (l)ocal source (f42d5c7504a8) or (r)emote source (46cd4aac504c)? l
1197 1209 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1198 1210 $ cat issue1852d/.hgsubstate
1199 1211 f42d5c7504a811dda50f5cf3e5e16c3330b87172 sub/repo
1200 1212
1201 1213 Check status of files when none of them belong to the first
1202 1214 subrepository:
1203 1215
1204 1216 $ hg init subrepo-status
1205 1217 $ cd subrepo-status
1206 1218 $ hg init subrepo-1
1207 1219 $ hg init subrepo-2
1208 1220 $ cd subrepo-2
1209 1221 $ touch file
1210 1222 $ hg add file
1211 1223 $ cd ..
1212 1224 $ echo subrepo-1 = subrepo-1 > .hgsub
1213 1225 $ echo subrepo-2 = subrepo-2 >> .hgsub
1214 1226 $ hg add .hgsub
1215 1227 $ hg ci -m 'Added subrepos'
1216 1228 committing subrepository subrepo-2
1217 1229 $ hg st subrepo-2/file
1218 1230
1219 1231 Check that share works with subrepo
1220 1232 $ hg --config extensions.share= share . ../shared
1221 1233 updating working directory
1222 1234 sharing subrepo subrepo-1 from $TESTTMP/subrepo-status/subrepo-1
1223 1235 sharing subrepo subrepo-2 from $TESTTMP/subrepo-status/subrepo-2
1224 1236 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1225 1237 $ find ../shared/* | sort
1226 1238 ../shared/subrepo-1
1227 1239 ../shared/subrepo-1/.hg
1228 1240 ../shared/subrepo-1/.hg/cache
1229 1241 ../shared/subrepo-1/.hg/cache/storehash
1230 1242 ../shared/subrepo-1/.hg/cache/storehash/* (glob)
1231 1243 ../shared/subrepo-1/.hg/hgrc
1232 1244 ../shared/subrepo-1/.hg/requires
1233 1245 ../shared/subrepo-1/.hg/sharedpath
1234 1246 ../shared/subrepo-2
1235 1247 ../shared/subrepo-2/.hg
1236 1248 ../shared/subrepo-2/.hg/branch
1237 1249 ../shared/subrepo-2/.hg/cache
1238 1250 ../shared/subrepo-2/.hg/cache/checkisexec (execbit !)
1239 1251 ../shared/subrepo-2/.hg/cache/checklink (symlink !)
1240 1252 ../shared/subrepo-2/.hg/cache/checklink-target (symlink !)
1241 1253 ../shared/subrepo-2/.hg/cache/storehash
1242 1254 ../shared/subrepo-2/.hg/cache/storehash/* (glob)
1243 1255 ../shared/subrepo-2/.hg/dirstate
1244 1256 ../shared/subrepo-2/.hg/hgrc
1245 1257 ../shared/subrepo-2/.hg/requires
1246 1258 ../shared/subrepo-2/.hg/sharedpath
1247 1259 ../shared/subrepo-2/file
1248 1260 $ hg -R ../shared in
1249 1261 abort: repository default not found!
1250 1262 [255]
1251 1263 $ hg -R ../shared/subrepo-2 showconfig paths
1252 1264 paths.default=$TESTTMP/subrepo-status/subrepo-2
1253 1265 $ hg -R ../shared/subrepo-1 sum --remote
1254 1266 parent: -1:000000000000 tip (empty repository)
1255 1267 branch: default
1256 1268 commit: (clean)
1257 1269 update: (current)
1258 1270 remote: (synced)
1259 1271
1260 1272 Check hg update --clean
1261 1273 $ cd $TESTTMP/t
1262 1274 $ rm -r t/t.orig
1263 1275 $ hg status -S --all
1264 1276 C .hgsub
1265 1277 C .hgsubstate
1266 1278 C a
1267 1279 C s/.hgsub
1268 1280 C s/.hgsubstate
1269 1281 C s/a
1270 1282 C s/ss/a
1271 1283 C t/t
1272 1284 $ echo c1 > s/a
1273 1285 $ cd s
1274 1286 $ echo c1 > b
1275 1287 $ echo c1 > c
1276 1288 $ hg add b
1277 1289 $ cd ..
1278 1290 $ hg status -S
1279 1291 M s/a
1280 1292 A s/b
1281 1293 ? s/c
1282 1294 $ hg update -C
1283 1295 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1284 1296 updated to "925c17564ef8: 13"
1285 1297 2 other heads for branch "default"
1286 1298 $ hg status -S
1287 1299 ? s/b
1288 1300 ? s/c
1289 1301
1290 1302 Sticky subrepositories, no changes
1291 1303 $ cd $TESTTMP/t
1292 1304 $ hg id
1293 1305 925c17564ef8 tip
1294 1306 $ hg -R s id
1295 1307 12a213df6fa9 tip
1296 1308 $ hg -R t id
1297 1309 52c0adc0515a tip
1298 1310 $ hg update 11
1299 1311 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1300 1312 $ hg id
1301 1313 365661e5936a
1302 1314 $ hg -R s id
1303 1315 fc627a69481f
1304 1316 $ hg -R t id
1305 1317 e95bcfa18a35
1306 1318
1307 1319 Sticky subrepositories, file changes
1308 1320 $ touch s/f1
1309 1321 $ touch t/f1
1310 1322 $ hg add -S s/f1
1311 1323 $ hg add -S t/f1
1312 1324 $ hg id
1313 1325 365661e5936a+
1314 1326 $ hg -R s id
1315 1327 fc627a69481f+
1316 1328 $ hg -R t id
1317 1329 e95bcfa18a35+
1318 1330 $ hg update tip
1319 1331 subrepository s diverged (local revision: fc627a69481f, remote revision: 12a213df6fa9)
1320 1332 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1321 1333 subrepository sources for s differ
1322 1334 use (l)ocal source (fc627a69481f) or (r)emote source (12a213df6fa9)? l
1323 1335 subrepository t diverged (local revision: e95bcfa18a35, remote revision: 52c0adc0515a)
1324 1336 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1325 1337 subrepository sources for t differ
1326 1338 use (l)ocal source (e95bcfa18a35) or (r)emote source (52c0adc0515a)? l
1327 1339 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1328 1340 $ hg id
1329 1341 925c17564ef8+ tip
1330 1342 $ hg -R s id
1331 1343 fc627a69481f+
1332 1344 $ hg -R t id
1333 1345 e95bcfa18a35+
1334 1346 $ hg update --clean tip
1335 1347 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1336 1348
1337 1349 Sticky subrepository, revision updates
1338 1350 $ hg id
1339 1351 925c17564ef8 tip
1340 1352 $ hg -R s id
1341 1353 12a213df6fa9 tip
1342 1354 $ hg -R t id
1343 1355 52c0adc0515a tip
1344 1356 $ cd s
1345 1357 $ hg update -r -2
1346 1358 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1347 1359 $ cd ../t
1348 1360 $ hg update -r 2
1349 1361 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1350 1362 $ cd ..
1351 1363 $ hg update 10
1352 1364 subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
1353 1365 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1354 1366 subrepository t diverged (local revision: 52c0adc0515a, remote revision: 20a0db6fbf6c)
1355 1367 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1356 1368 subrepository sources for t differ (in checked out version)
1357 1369 use (l)ocal source (7af322bc1198) or (r)emote source (20a0db6fbf6c)? l
1358 1370 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1359 1371 $ hg id
1360 1372 e45c8b14af55+
1361 1373 $ hg -R s id
1362 1374 02dcf1d70411
1363 1375 $ hg -R t id
1364 1376 7af322bc1198
1365 1377
1366 1378 Sticky subrepository, file changes and revision updates
1367 1379 $ touch s/f1
1368 1380 $ touch t/f1
1369 1381 $ hg add -S s/f1
1370 1382 $ hg add -S t/f1
1371 1383 $ hg id
1372 1384 e45c8b14af55+
1373 1385 $ hg -R s id
1374 1386 02dcf1d70411+
1375 1387 $ hg -R t id
1376 1388 7af322bc1198+
1377 1389 $ hg update tip
1378 1390 subrepository s diverged (local revision: 12a213df6fa9, remote revision: 12a213df6fa9)
1379 1391 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1380 1392 subrepository sources for s differ
1381 1393 use (l)ocal source (02dcf1d70411) or (r)emote source (12a213df6fa9)? l
1382 1394 subrepository t diverged (local revision: 52c0adc0515a, remote revision: 52c0adc0515a)
1383 1395 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1384 1396 subrepository sources for t differ
1385 1397 use (l)ocal source (7af322bc1198) or (r)emote source (52c0adc0515a)? l
1386 1398 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1387 1399 $ hg id
1388 1400 925c17564ef8+ tip
1389 1401 $ hg -R s id
1390 1402 02dcf1d70411+
1391 1403 $ hg -R t id
1392 1404 7af322bc1198+
1393 1405
1394 1406 Sticky repository, update --clean
1395 1407 $ hg update --clean tip
1396 1408 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1397 1409 $ hg id
1398 1410 925c17564ef8 tip
1399 1411 $ hg -R s id
1400 1412 12a213df6fa9 tip
1401 1413 $ hg -R t id
1402 1414 52c0adc0515a tip
1403 1415
1404 1416 Test subrepo already at intended revision:
1405 1417 $ cd s
1406 1418 $ hg update fc627a69481f
1407 1419 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1408 1420 $ cd ..
1409 1421 $ hg update 11
1410 1422 subrepository s diverged (local revision: 12a213df6fa9, remote revision: fc627a69481f)
1411 1423 (M)erge, keep (l)ocal [working copy] or keep (r)emote [destination]? m
1412 1424 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1413 1425 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1414 1426 $ hg id -n
1415 1427 11+
1416 1428 $ hg -R s id
1417 1429 fc627a69481f
1418 1430 $ hg -R t id
1419 1431 e95bcfa18a35
1420 1432
1421 1433 Test that removing .hgsubstate doesn't break anything:
1422 1434
1423 1435 $ hg rm -f .hgsubstate
1424 1436 $ hg ci -mrm
1425 1437 nothing changed
1426 1438 [1]
1427 1439 $ hg log -vr tip
1428 1440 changeset: 13:925c17564ef8
1429 1441 tag: tip
1430 1442 user: test
1431 1443 date: Thu Jan 01 00:00:00 1970 +0000
1432 1444 files: .hgsubstate
1433 1445 description:
1434 1446 13
1435 1447
1436 1448
1437 1449
1438 1450 Test that removing .hgsub removes .hgsubstate:
1439 1451
1440 1452 $ hg rm .hgsub
1441 1453 $ hg ci -mrm2
1442 1454 created new head
1443 1455 $ hg log -vr tip
1444 1456 changeset: 14:2400bccd50af
1445 1457 tag: tip
1446 1458 parent: 11:365661e5936a
1447 1459 user: test
1448 1460 date: Thu Jan 01 00:00:00 1970 +0000
1449 1461 files: .hgsub .hgsubstate
1450 1462 description:
1451 1463 rm2
1452 1464
1453 1465
1454 1466 Test issue3153: diff -S with deleted subrepos
1455 1467
1456 1468 $ hg diff --nodates -S -c .
1457 1469 diff -r 365661e5936a -r 2400bccd50af .hgsub
1458 1470 --- a/.hgsub
1459 1471 +++ /dev/null
1460 1472 @@ -1,2 +0,0 @@
1461 1473 -s = s
1462 1474 -t = t
1463 1475 diff -r 365661e5936a -r 2400bccd50af .hgsubstate
1464 1476 --- a/.hgsubstate
1465 1477 +++ /dev/null
1466 1478 @@ -1,2 +0,0 @@
1467 1479 -fc627a69481fcbe5f1135069e8a3881c023e4cf5 s
1468 1480 -e95bcfa18a358dc4936da981ebf4147b4cad1362 t
1469 1481
1470 1482 Test behavior of add for explicit path in subrepo:
1471 1483 $ cd ..
1472 1484 $ hg init explicit
1473 1485 $ cd explicit
1474 1486 $ echo s = s > .hgsub
1475 1487 $ hg add .hgsub
1476 1488 $ hg init s
1477 1489 $ hg ci -m0
1478 1490 Adding with an explicit path in a subrepo adds the file
1479 1491 $ echo c1 > f1
1480 1492 $ echo c2 > s/f2
1481 1493 $ hg st -S
1482 1494 ? f1
1483 1495 ? s/f2
1484 1496 $ hg add s/f2
1485 1497 $ hg st -S
1486 1498 A s/f2
1487 1499 ? f1
1488 1500 $ hg ci -R s -m0
1489 1501 $ hg ci -Am1
1490 1502 adding f1
1491 1503 Adding with an explicit path in a subrepo with -S has the same behavior
1492 1504 $ echo c3 > f3
1493 1505 $ echo c4 > s/f4
1494 1506 $ hg st -S
1495 1507 ? f3
1496 1508 ? s/f4
1497 1509 $ hg add -S s/f4
1498 1510 $ hg st -S
1499 1511 A s/f4
1500 1512 ? f3
1501 1513 $ hg ci -R s -m1
1502 1514 $ hg ci -Ama2
1503 1515 adding f3
1504 1516 Adding without a path or pattern silently ignores subrepos
1505 1517 $ echo c5 > f5
1506 1518 $ echo c6 > s/f6
1507 1519 $ echo c7 > s/f7
1508 1520 $ hg st -S
1509 1521 ? f5
1510 1522 ? s/f6
1511 1523 ? s/f7
1512 1524 $ hg add
1513 1525 adding f5
1514 1526 $ hg st -S
1515 1527 A f5
1516 1528 ? s/f6
1517 1529 ? s/f7
1518 1530 $ hg ci -R s -Am2
1519 1531 adding f6
1520 1532 adding f7
1521 1533 $ hg ci -m3
1522 1534 Adding without a path or pattern with -S also adds files in subrepos
1523 1535 $ echo c8 > f8
1524 1536 $ echo c9 > s/f9
1525 1537 $ echo c10 > s/f10
1526 1538 $ hg st -S
1527 1539 ? f8
1528 1540 ? s/f10
1529 1541 ? s/f9
1530 1542 $ hg add -S
1531 1543 adding f8
1532 1544 adding s/f10 (glob)
1533 1545 adding s/f9 (glob)
1534 1546 $ hg st -S
1535 1547 A f8
1536 1548 A s/f10
1537 1549 A s/f9
1538 1550 $ hg ci -R s -m3
1539 1551 $ hg ci -m4
1540 1552 Adding with a pattern silently ignores subrepos
1541 1553 $ echo c11 > fm11
1542 1554 $ echo c12 > fn12
1543 1555 $ echo c13 > s/fm13
1544 1556 $ echo c14 > s/fn14
1545 1557 $ hg st -S
1546 1558 ? fm11
1547 1559 ? fn12
1548 1560 ? s/fm13
1549 1561 ? s/fn14
1550 1562 $ hg add 'glob:**fm*'
1551 1563 adding fm11
1552 1564 $ hg st -S
1553 1565 A fm11
1554 1566 ? fn12
1555 1567 ? s/fm13
1556 1568 ? s/fn14
1557 1569 $ hg ci -R s -Am4
1558 1570 adding fm13
1559 1571 adding fn14
1560 1572 $ hg ci -Am5
1561 1573 adding fn12
1562 1574 Adding with a pattern with -S also adds matches in subrepos
1563 1575 $ echo c15 > fm15
1564 1576 $ echo c16 > fn16
1565 1577 $ echo c17 > s/fm17
1566 1578 $ echo c18 > s/fn18
1567 1579 $ hg st -S
1568 1580 ? fm15
1569 1581 ? fn16
1570 1582 ? s/fm17
1571 1583 ? s/fn18
1572 1584 $ hg add -S 'glob:**fm*'
1573 1585 adding fm15
1574 1586 adding s/fm17 (glob)
1575 1587 $ hg st -S
1576 1588 A fm15
1577 1589 A s/fm17
1578 1590 ? fn16
1579 1591 ? s/fn18
1580 1592 $ hg ci -R s -Am5
1581 1593 adding fn18
1582 1594 $ hg ci -Am6
1583 1595 adding fn16
1584 1596
1585 1597 Test behavior of forget for explicit path in subrepo:
1586 1598 Forgetting an explicit path in a subrepo untracks the file
1587 1599 $ echo c19 > s/f19
1588 1600 $ hg add s/f19
1589 1601 $ hg st -S
1590 1602 A s/f19
1591 1603 $ hg forget s/f19
1592 1604 $ hg st -S
1593 1605 ? s/f19
1594 1606 $ rm s/f19
1595 1607 $ cd ..
1596 1608
1597 1609 Courtesy phases synchronisation to publishing server does not block the push
1598 1610 (issue3781)
1599 1611
1600 1612 $ cp -R main issue3781
1601 1613 $ cp -R main issue3781-dest
1602 1614 $ cd issue3781-dest/s
1603 1615 $ hg phase tip # show we have draft changeset
1604 1616 5: draft
1605 1617 $ chmod a-w .hg/store/phaseroots # prevent phase push
1606 1618 $ cd ../../issue3781
1607 1619 $ cat >> .hg/hgrc << EOF
1608 1620 > [paths]
1609 1621 > default=../issue3781-dest/
1610 1622 > EOF
1611 1623 $ hg push --config devel.legacy.exchange=bundle1
1612 1624 pushing to $TESTTMP/issue3781-dest (glob)
1613 1625 pushing subrepo s to $TESTTMP/issue3781-dest/s
1614 1626 searching for changes
1615 1627 no changes found
1616 1628 searching for changes
1617 1629 no changes found
1618 1630 [1]
1619 1631 # clean the push cache
1620 1632 $ rm s/.hg/cache/storehash/*
1621 1633 $ hg push # bundle2+
1622 1634 pushing to $TESTTMP/issue3781-dest (glob)
1623 1635 pushing subrepo s to $TESTTMP/issue3781-dest/s
1624 1636 searching for changes
1625 1637 no changes found
1626 1638 searching for changes
1627 1639 no changes found
1628 1640 [1]
1629 1641 $ cd ..
1630 1642
1631 1643 Test phase choice for newly created commit with "phases.subrepochecks"
1632 1644 configuration
1633 1645
1634 1646 $ cd t
1635 1647 $ hg update -q -r 12
1636 1648
1637 1649 $ cat >> s/ss/.hg/hgrc <<EOF
1638 1650 > [phases]
1639 1651 > new-commit = secret
1640 1652 > EOF
1641 1653 $ cat >> s/.hg/hgrc <<EOF
1642 1654 > [phases]
1643 1655 > new-commit = draft
1644 1656 > EOF
1645 1657 $ echo phasecheck1 >> s/ss/a
1646 1658 $ hg -R s commit -S --config phases.checksubrepos=abort -m phasecheck1
1647 1659 committing subrepository ss
1648 1660 transaction abort!
1649 1661 rollback completed
1650 1662 abort: can't commit in draft phase conflicting secret from subrepository ss
1651 1663 [255]
1652 1664 $ echo phasecheck2 >> s/ss/a
1653 1665 $ hg -R s commit -S --config phases.checksubrepos=ignore -m phasecheck2
1654 1666 committing subrepository ss
1655 1667 $ hg -R s/ss phase tip
1656 1668 3: secret
1657 1669 $ hg -R s phase tip
1658 1670 6: draft
1659 1671 $ echo phasecheck3 >> s/ss/a
1660 1672 $ hg -R s commit -S -m phasecheck3
1661 1673 committing subrepository ss
1662 1674 warning: changes are committed in secret phase from subrepository ss
1663 1675 $ hg -R s/ss phase tip
1664 1676 4: secret
1665 1677 $ hg -R s phase tip
1666 1678 7: secret
1667 1679
1668 1680 $ cat >> t/.hg/hgrc <<EOF
1669 1681 > [phases]
1670 1682 > new-commit = draft
1671 1683 > EOF
1672 1684 $ cat >> .hg/hgrc <<EOF
1673 1685 > [phases]
1674 1686 > new-commit = public
1675 1687 > EOF
1676 1688 $ echo phasecheck4 >> s/ss/a
1677 1689 $ echo phasecheck4 >> t/t
1678 1690 $ hg commit -S -m phasecheck4
1679 1691 committing subrepository s
1680 1692 committing subrepository s/ss (glob)
1681 1693 warning: changes are committed in secret phase from subrepository ss
1682 1694 committing subrepository t
1683 1695 warning: changes are committed in secret phase from subrepository s
1684 1696 created new head
1685 1697 $ hg -R s/ss phase tip
1686 1698 5: secret
1687 1699 $ hg -R s phase tip
1688 1700 8: secret
1689 1701 $ hg -R t phase tip
1690 1702 6: draft
1691 1703 $ hg phase tip
1692 1704 15: secret
1693 1705
1694 1706 $ cd ..
1695 1707
1696 1708
1697 1709 Test that commit --secret works on both repo and subrepo (issue4182)
1698 1710
1699 1711 $ cd main
1700 1712 $ echo secret >> b
1701 1713 $ echo secret >> s/b
1702 1714 $ hg commit --secret --subrepo -m "secret"
1703 1715 committing subrepository s
1704 1716 $ hg phase -r .
1705 1717 6: secret
1706 1718 $ cd s
1707 1719 $ hg phase -r .
1708 1720 6: secret
1709 1721 $ cd ../../
1710 1722
1711 1723 Test "subrepos" template keyword
1712 1724
1713 1725 $ cd t
1714 1726 $ hg update -q 15
1715 1727 $ cat > .hgsub <<EOF
1716 1728 > s = s
1717 1729 > EOF
1718 1730 $ hg commit -m "16"
1719 1731 warning: changes are committed in secret phase from subrepository s
1720 1732
1721 1733 (addition of ".hgsub" itself)
1722 1734
1723 1735 $ hg diff --nodates -c 1 .hgsubstate
1724 1736 diff -r f7b1eb17ad24 -r 7cf8cfea66e4 .hgsubstate
1725 1737 --- /dev/null
1726 1738 +++ b/.hgsubstate
1727 1739 @@ -0,0 +1,1 @@
1728 1740 +e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
1729 1741 $ hg log -r 1 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1730 1742 f7b1eb17ad24 000000000000
1731 1743 s
1732 1744
1733 1745 (modification of existing entry)
1734 1746
1735 1747 $ hg diff --nodates -c 2 .hgsubstate
1736 1748 diff -r 7cf8cfea66e4 -r df30734270ae .hgsubstate
1737 1749 --- a/.hgsubstate
1738 1750 +++ b/.hgsubstate
1739 1751 @@ -1,1 +1,1 @@
1740 1752 -e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
1741 1753 +dc73e2e6d2675eb2e41e33c205f4bdab4ea5111d s
1742 1754 $ hg log -r 2 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1743 1755 7cf8cfea66e4 000000000000
1744 1756 s
1745 1757
1746 1758 (addition of entry)
1747 1759
1748 1760 $ hg diff --nodates -c 5 .hgsubstate
1749 1761 diff -r 7cf8cfea66e4 -r 1f14a2e2d3ec .hgsubstate
1750 1762 --- a/.hgsubstate
1751 1763 +++ b/.hgsubstate
1752 1764 @@ -1,1 +1,2 @@
1753 1765 e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
1754 1766 +60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t
1755 1767 $ hg log -r 5 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1756 1768 7cf8cfea66e4 000000000000
1757 1769 t
1758 1770
1759 1771 (removal of existing entry)
1760 1772
1761 1773 $ hg diff --nodates -c 16 .hgsubstate
1762 1774 diff -r 8bec38d2bd0b -r f2f70bc3d3c9 .hgsubstate
1763 1775 --- a/.hgsubstate
1764 1776 +++ b/.hgsubstate
1765 1777 @@ -1,2 +1,1 @@
1766 1778 0731af8ca9423976d3743119d0865097c07bdc1b s
1767 1779 -e202dc79b04c88a636ea8913d9182a1346d9b3dc t
1768 1780 $ hg log -r 16 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1769 1781 8bec38d2bd0b 000000000000
1770 1782 t
1771 1783
1772 1784 (merging)
1773 1785
1774 1786 $ hg diff --nodates -c 9 .hgsubstate
1775 1787 diff -r f6affe3fbfaa -r f0d2028bf86d .hgsubstate
1776 1788 --- a/.hgsubstate
1777 1789 +++ b/.hgsubstate
1778 1790 @@ -1,1 +1,2 @@
1779 1791 fc627a69481fcbe5f1135069e8a3881c023e4cf5 s
1780 1792 +60ca1237c19474e7a3978b0dc1ca4e6f36d51382 t
1781 1793 $ hg log -r 9 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1782 1794 f6affe3fbfaa 1f14a2e2d3ec
1783 1795 t
1784 1796
1785 1797 (removal of ".hgsub" itself)
1786 1798
1787 1799 $ hg diff --nodates -c 8 .hgsubstate
1788 1800 diff -r f94576341bcf -r 96615c1dad2d .hgsubstate
1789 1801 --- a/.hgsubstate
1790 1802 +++ /dev/null
1791 1803 @@ -1,2 +0,0 @@
1792 1804 -e4ece1bf43360ddc8f6a96432201a37b7cd27ae4 s
1793 1805 -7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4 t
1794 1806 $ hg log -r 8 --template "{p1node|short} {p2node|short}\n{subrepos % '{subrepo}\n'}"
1795 1807 f94576341bcf 000000000000
1796 1808
1797 1809 Test that '[paths]' is configured correctly at subrepo creation
1798 1810
1799 1811 $ cd $TESTTMP/tc
1800 1812 $ cat > .hgsub <<EOF
1801 1813 > # to clear bogus subrepo path 'bogus=[boguspath'
1802 1814 > s = s
1803 1815 > t = t
1804 1816 > EOF
1805 1817 $ hg update -q --clean null
1806 1818 $ rm -rf s t
1807 1819 $ cat >> .hg/hgrc <<EOF
1808 1820 > [paths]
1809 1821 > default-push = /foo/bar
1810 1822 > EOF
1811 1823 $ hg update -q
1812 1824 $ cat s/.hg/hgrc
1813 1825 [paths]
1814 1826 default = $TESTTMP/t/s
1815 1827 default-push = /foo/bar/s
1816 1828 $ cat s/ss/.hg/hgrc
1817 1829 [paths]
1818 1830 default = $TESTTMP/t/s/ss
1819 1831 default-push = /foo/bar/s/ss
1820 1832 $ cat t/.hg/hgrc
1821 1833 [paths]
1822 1834 default = $TESTTMP/t/t
1823 1835 default-push = /foo/bar/t
1824 1836
1825 1837 $ cd $TESTTMP/t
1826 1838 $ hg up -qC 0
1827 1839 $ echo 'bar' > bar.txt
1828 1840 $ hg ci -Am 'branch before subrepo add'
1829 1841 adding bar.txt
1830 1842 created new head
1831 1843 $ hg merge -r "first(subrepo('s'))"
1832 1844 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1833 1845 (branch merge, don't forget to commit)
1834 1846 $ hg status -S -X '.hgsub*'
1835 1847 A s/a
1836 1848 ? s/b
1837 1849 ? s/c
1838 1850 ? s/f1
1839 1851 $ hg status -S --rev 'p2()'
1840 1852 A bar.txt
1841 1853 ? s/b
1842 1854 ? s/c
1843 1855 ? s/f1
1844 1856 $ hg diff -S -X '.hgsub*' --nodates
1845 1857 diff -r 000000000000 s/a
1846 1858 --- /dev/null
1847 1859 +++ b/s/a
1848 1860 @@ -0,0 +1,1 @@
1849 1861 +a
1850 1862 $ hg diff -S --rev 'p2()' --nodates
1851 1863 diff -r 7cf8cfea66e4 bar.txt
1852 1864 --- /dev/null
1853 1865 +++ b/bar.txt
1854 1866 @@ -0,0 +1,1 @@
1855 1867 +bar
1856 1868
1857 1869 $ cd ..
1858 1870
1859 1871 test for ssh exploit 2017-07-25
1860 1872
1861 1873 $ cat >> $HGRCPATH << EOF
1862 1874 > [ui]
1863 1875 > ssh = sh -c "read l; read l; read l"
1864 1876 > EOF
1865 1877
1866 1878 $ hg init malicious-proxycommand
1867 1879 $ cd malicious-proxycommand
1868 1880 $ echo 's = [hg]ssh://-oProxyCommand=touch${IFS}owned/path' > .hgsub
1869 1881 $ hg init s
1870 1882 $ cd s
1871 1883 $ echo init > init
1872 1884 $ hg add
1873 1885 adding init
1874 1886 $ hg commit -m init
1875 1887 $ cd ..
1876 1888 $ hg add .hgsub
1877 1889 $ hg ci -m 'add subrepo'
1878 1890 $ cd ..
1879 1891 $ hg clone malicious-proxycommand malicious-proxycommand-clone
1880 1892 updating to branch default
1881 1893 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' (in subrepository "s")
1882 1894 [255]
1883 1895
1884 1896 also check that a percent encoded '-' (%2D) doesn't work
1885 1897
1886 1898 $ cd malicious-proxycommand
1887 1899 $ echo 's = [hg]ssh://%2DoProxyCommand=touch${IFS}owned/path' > .hgsub
1888 1900 $ hg ci -m 'change url to percent encoded'
1889 1901 $ cd ..
1890 1902 $ rm -r malicious-proxycommand-clone
1891 1903 $ hg clone malicious-proxycommand malicious-proxycommand-clone
1892 1904 updating to branch default
1893 1905 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch${IFS}owned/path' (in subrepository "s")
1894 1906 [255]
1895 1907
1896 1908 also check for a pipe
1897 1909
1898 1910 $ cd malicious-proxycommand
1899 1911 $ echo 's = [hg]ssh://fakehost|touch${IFS}owned/path' > .hgsub
1900 1912 $ hg ci -m 'change url to pipe'
1901 1913 $ cd ..
1902 1914 $ rm -r malicious-proxycommand-clone
1903 1915 $ hg clone malicious-proxycommand malicious-proxycommand-clone
1904 1916 updating to branch default
1905 1917 abort: no suitable response from remote hg!
1906 1918 [255]
1907 1919 $ [ ! -f owned ] || echo 'you got owned'
1908 1920
1909 1921 also check that a percent encoded '|' (%7C) doesn't work
1910 1922
1911 1923 $ cd malicious-proxycommand
1912 1924 $ echo 's = [hg]ssh://fakehost%7Ctouch%20owned/path' > .hgsub
1913 1925 $ hg ci -m 'change url to percent encoded pipe'
1914 1926 $ cd ..
1915 1927 $ rm -r malicious-proxycommand-clone
1916 1928 $ hg clone malicious-proxycommand malicious-proxycommand-clone
1917 1929 updating to branch default
1918 1930 abort: no suitable response from remote hg!
1919 1931 [255]
1920 1932 $ [ ! -f owned ] || echo 'you got owned'
1921 1933
1922 1934 and bad usernames:
1923 1935 $ cd malicious-proxycommand
1924 1936 $ echo 's = [hg]ssh://-oProxyCommand=touch owned@example.com/path' > .hgsub
1925 1937 $ hg ci -m 'owned username'
1926 1938 $ cd ..
1927 1939 $ rm -r malicious-proxycommand-clone
1928 1940 $ hg clone malicious-proxycommand malicious-proxycommand-clone
1929 1941 updating to branch default
1930 1942 abort: potentially unsafe url: 'ssh://-oProxyCommand=touch owned@example.com/path' (in subrepository "s")
1931 1943 [255]
General Comments 0
You need to be logged in to leave comments. Login now