##// END OF EJS Templates
pull: allow to specify multiple sources...
marmoute -
r47498:68538348 default
parent child Browse files
Show More
@@ -0,0 +1,315 b''
1 ====================================================
2 Test push/pull from multiple source at the same time
3 ====================================================
4
5
6 Setup
7 =====
8
9 main repository
10 ---------------
11
12 $ . $RUNTESTDIR/testlib/common.sh
13 $ hg init main-repo
14 $ cd main-repo
15 $ mkcommit A
16 $ mkcommit B
17 $ mkcommit C
18 $ mkcommit D
19 $ mkcommit E
20 $ hg up 'desc(B)'
21 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
22 $ mkcommit F
23 created new head
24 $ mkcommit G
25 $ hg up 'desc(C)'
26 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
27 $ mkcommit H
28 created new head
29 $ hg up null --quiet
30 $ hg log -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
31 o H 7
32 |
33 | o E 4
34 | |
35 | o D 3
36 |/
37 o C 2
38 |
39 | o G 6
40 | |
41 | o F 5
42 |/
43 o B 1
44 |
45 o A 0
46
47 $ cd ..
48
49 Various other repositories
50 --------------------------
51
52 $ hg clone main-repo branch-E --rev 4 -U
53 adding changesets
54 adding manifests
55 adding file changes
56 added 5 changesets with 5 changes to 5 files
57 new changesets 4a2df7238c3b:a603bfb5a83e
58 $ hg clone main-repo branch-G --rev 6 -U
59 adding changesets
60 adding manifests
61 adding file changes
62 added 4 changesets with 4 changes to 4 files
63 new changesets 4a2df7238c3b:c521a06b234b
64 $ hg clone main-repo branch-H --rev 7 -U
65 adding changesets
66 adding manifests
67 adding file changes
68 added 4 changesets with 4 changes to 4 files
69 new changesets 4a2df7238c3b:40faebb2ec45
70
71 Test simple bare operation
72 ==========================
73
74 $ hg clone main-repo test-repo-bare --rev 0 -U
75 adding changesets
76 adding manifests
77 adding file changes
78 added 1 changesets with 1 changes to 1 files
79 new changesets 4a2df7238c3b
80
81 $ hg pull -R test-repo-bare ./branch-E ./branch-G ./branch-H
82 pulling from ./branch-E
83 searching for changes
84 adding changesets
85 adding manifests
86 adding file changes
87 added 4 changesets with 4 changes to 4 files
88 new changesets 27547f69f254:a603bfb5a83e
89 (run 'hg update' to get a working copy)
90 pulling from ./branch-G
91 searching for changes
92 adding changesets
93 adding manifests
94 adding file changes
95 added 2 changesets with 2 changes to 2 files (+1 heads)
96 new changesets 2f3a4c5c1417:c521a06b234b
97 (run 'hg heads' to see heads, 'hg merge' to merge)
98 pulling from ./branch-H
99 searching for changes
100 adding changesets
101 adding manifests
102 adding file changes
103 added 1 changesets with 1 changes to 1 files (+1 heads)
104 new changesets 40faebb2ec45
105 (run 'hg heads .' to see heads, 'hg merge' to merge)
106 $ hg log -R test-repo-bare -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
107 o H 7
108 |
109 | o E 4
110 | |
111 | o D 3
112 |/
113 o C 2
114 |
115 | o G 6
116 | |
117 | o F 5
118 |/
119 o B 1
120 |
121 o A 0
122
123
124 Test operation with a target
125 ============================
126
127 $ hg clone main-repo test-repo-rev --rev 0 -U
128 adding changesets
129 adding manifests
130 adding file changes
131 added 1 changesets with 1 changes to 1 files
132 new changesets 4a2df7238c3b
133
134 pulling an explicite revision
135
136 $ node_b=`hg log -R main-repo --rev 'desc(B)' -T '{node}'`
137 $ hg pull -R test-repo-rev ./branch-E ./branch-G ./branch-H --rev $node_b
138 pulling from ./branch-E
139 searching for changes
140 adding changesets
141 adding manifests
142 adding file changes
143 added 1 changesets with 1 changes to 1 files
144 new changesets 27547f69f254
145 (run 'hg update' to get a working copy)
146 pulling from ./branch-G
147 no changes found
148 pulling from ./branch-H
149 no changes found
150 $ hg log -R test-repo-rev -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
151 o B 1
152 |
153 o A 0
154
155
156 pulling a branch head, the branch head resolve to different revision on the
157 different repositories.
158
159 $ hg pull -R test-repo-rev ./branch-E ./branch-G ./branch-H --rev default
160 pulling from ./branch-E
161 searching for changes
162 adding changesets
163 adding manifests
164 adding file changes
165 added 3 changesets with 3 changes to 3 files
166 new changesets f838bfaca5c7:a603bfb5a83e
167 (run 'hg update' to get a working copy)
168 pulling from ./branch-G
169 searching for changes
170 adding changesets
171 adding manifests
172 adding file changes
173 added 2 changesets with 2 changes to 2 files (+1 heads)
174 new changesets 2f3a4c5c1417:c521a06b234b
175 (run 'hg heads' to see heads, 'hg merge' to merge)
176 pulling from ./branch-H
177 searching for changes
178 adding changesets
179 adding manifests
180 adding file changes
181 added 1 changesets with 1 changes to 1 files (+1 heads)
182 new changesets 40faebb2ec45
183 (run 'hg heads .' to see heads, 'hg merge' to merge)
184 $ hg log -R test-repo-rev -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
185 o H 7
186 |
187 | o E 4
188 | |
189 | o D 3
190 |/
191 o C 2
192 |
193 | o G 6
194 | |
195 | o F 5
196 |/
197 o B 1
198 |
199 o A 0
200
201
202
203 Test with --update
204 ==================
205
206 update without conflicts
207 ------------------------
208
209 $ hg clone main-repo test-repo-update --rev 0
210 adding changesets
211 adding manifests
212 adding file changes
213 added 1 changesets with 1 changes to 1 files
214 new changesets 4a2df7238c3b
215 updating to branch default
216 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
217
218 We update for each pull, so the first on get into a branch independant from the
219 other and stay there. This is the expected behavior.
220
221 $ hg log -R test-repo-update -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
222 @ A 0
223
224 $ hg pull -R test-repo-update ./branch-E ./branch-G ./branch-H --update
225 pulling from ./branch-E
226 searching for changes
227 adding changesets
228 adding manifests
229 adding file changes
230 added 4 changesets with 4 changes to 4 files
231 new changesets 27547f69f254:a603bfb5a83e
232 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
233 pulling from ./branch-G
234 searching for changes
235 adding changesets
236 adding manifests
237 adding file changes
238 added 2 changesets with 2 changes to 2 files (+1 heads)
239 new changesets 2f3a4c5c1417:c521a06b234b
240 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
241 updated to "a603bfb5a83e: E"
242 1 other heads for branch "default"
243 pulling from ./branch-H
244 searching for changes
245 adding changesets
246 adding manifests
247 adding file changes
248 added 1 changesets with 1 changes to 1 files (+1 heads)
249 new changesets 40faebb2ec45
250 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
251 updated to "a603bfb5a83e: E"
252 2 other heads for branch "default"
253 $ hg log -R test-repo-update -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
254 o H 7
255 |
256 | @ E 4
257 | |
258 | o D 3
259 |/
260 o C 2
261 |
262 | o G 6
263 | |
264 | o F 5
265 |/
266 o B 1
267 |
268 o A 0
269
270
271 update with conflicts
272 ---------------------
273
274 $ hg clone main-repo test-repo-conflict --rev 0
275 adding changesets
276 adding manifests
277 adding file changes
278 added 1 changesets with 1 changes to 1 files
279 new changesets 4a2df7238c3b
280 updating to branch default
281 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
282
283 The update has conflict and interrupt the pull.
284
285 $ echo this-will-conflict > test-repo-conflict/D
286 $ hg add -R test-repo-conflict test-repo-conflict/D
287 $ hg log -R test-repo-conflict -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
288 @ A 0
289
290 $ hg pull -R test-repo-conflict ./branch-E ./branch-G ./branch-H --update
291 pulling from ./branch-E
292 searching for changes
293 adding changesets
294 adding manifests
295 adding file changes
296 added 4 changesets with 4 changes to 4 files
297 new changesets 27547f69f254:a603bfb5a83e
298 merging D
299 warning: conflicts while merging D! (edit, then use 'hg resolve --mark')
300 3 files updated, 0 files merged, 0 files removed, 1 files unresolved
301 use 'hg resolve' to retry unresolved file merges
302 [1]
303 $ hg -R test-repo-conflict resolve -l
304 U D
305 $ hg log -R test-repo-conflict -T '{desc} {rev}\n' --rev 'sort(all(), "topo")' -G
306 @ E 4
307 |
308 o D 3
309 |
310 o C 2
311 |
312 o B 1
313 |
314 % A 0
315
@@ -0,0 +1,7 b''
1 mkcommit() {
2 name="$1"
3 shift
4 echo "$name" > "$name"
5 hg add "$name"
6 hg ci -m "$name" "$@"
7 }
@@ -5323,11 +5323,11 b' def postincoming(ui, repo, modheads, opt'
5323 ),
5323 ),
5324 ]
5324 ]
5325 + remoteopts,
5325 + remoteopts,
5326 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'),
5326 _(b'[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]...'),
5327 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5327 helpcategory=command.CATEGORY_REMOTE_REPO_MANAGEMENT,
5328 helpbasic=True,
5328 helpbasic=True,
5329 )
5329 )
5330 def pull(ui, repo, source=b"default", **opts):
5330 def pull(ui, repo, *sources, **opts):
5331 """pull changes from the specified source
5331 """pull changes from the specified source
5332
5332
5333 Pull changes from a remote repository to a local one.
5333 Pull changes from a remote repository to a local one.
@@ -5351,6 +5351,10 b' def pull(ui, repo, source=b"default", **'
5351 If SOURCE is omitted, the 'default' path will be used.
5351 If SOURCE is omitted, the 'default' path will be used.
5352 See :hg:`help urls` for more information.
5352 See :hg:`help urls` for more information.
5353
5353
5354 If multiple sources are specified, they will be pulled sequentially as if
5355 the command was run multiple time. If --update is specify and the command
5356 will stop at the first failed --update.
5357
5354 Specifying bookmark as ``.`` is equivalent to specifying the active
5358 Specifying bookmark as ``.`` is equivalent to specifying the active
5355 bookmark's name.
5359 bookmark's name.
5356
5360
@@ -5365,7 +5369,9 b' def pull(ui, repo, source=b"default", **'
5365 hint = _(b'use hg pull followed by hg update DEST')
5369 hint = _(b'use hg pull followed by hg update DEST')
5366 raise error.InputError(msg, hint=hint)
5370 raise error.InputError(msg, hint=hint)
5367
5371
5368 if True:
5372 if not sources:
5373 sources = [b'default']
5374 for source in sources:
5369 source, branches = hg.parseurl(
5375 source, branches = hg.parseurl(
5370 ui.expandpath(source), opts.get(b'branch')
5376 ui.expandpath(source), opts.get(b'branch')
5371 )
5377 )
@@ -5463,6 +5469,9 b' def pull(ui, repo, source=b"default", **'
5463
5469
5464 finally:
5470 finally:
5465 other.close()
5471 other.close()
5472 # skip the remaining pull source if they are some conflict.
5473 if update_conflict:
5474 break
5466 if update_conflict:
5475 if update_conflict:
5467 return 1
5476 return 1
5468 else:
5477 else:
General Comments 0
You need to be logged in to leave comments. Login now