Show More
@@ -1,440 +1,440 b'' | |||
|
1 | 1 | # hg.py - repository classes for mercurial |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # Copyright 2006 Vadim Gelfer <vadim.gelfer@gmail.com> |
|
5 | 5 | # |
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 7 | # GNU General Public License version 2 or any later version. |
|
8 | 8 | |
|
9 | 9 | from i18n import _ |
|
10 | 10 | from lock import release |
|
11 | 11 | import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo |
|
12 | 12 | import lock, util, extensions, error, encoding, node |
|
13 | 13 | import merge as mergemod |
|
14 | 14 | import verify as verifymod |
|
15 | 15 | import errno, os, shutil |
|
16 | 16 | |
|
17 | 17 | def _local(path): |
|
18 | 18 | path = util.expandpath(util.drop_scheme('file', path)) |
|
19 | 19 | return (os.path.isfile(path) and bundlerepo or localrepo) |
|
20 | 20 | |
|
21 | 21 | def addbranchrevs(lrepo, repo, branches, revs): |
|
22 | 22 | hashbranch, branches = branches |
|
23 | 23 | if not hashbranch and not branches: |
|
24 | 24 | return revs or None, revs and revs[0] or None |
|
25 | 25 | revs = revs and list(revs) or [] |
|
26 | 26 | if not repo.capable('branchmap'): |
|
27 | 27 | if branches: |
|
28 | 28 | raise util.Abort(_("remote branch lookup not supported")) |
|
29 | 29 | revs.append(hashbranch) |
|
30 | 30 | return revs, revs[0] |
|
31 | 31 | branchmap = repo.branchmap() |
|
32 | 32 | |
|
33 | 33 | def primary(butf8): |
|
34 | 34 | if butf8 == '.': |
|
35 | 35 | if not lrepo or not lrepo.local(): |
|
36 | 36 | raise util.Abort(_("dirstate branch not accessible")) |
|
37 | 37 | butf8 = lrepo.dirstate.branch() |
|
38 | 38 | if butf8 in branchmap: |
|
39 | 39 | revs.extend(node.hex(r) for r in reversed(branchmap[butf8])) |
|
40 | 40 | return True |
|
41 | 41 | else: |
|
42 | 42 | return False |
|
43 | 43 | |
|
44 | 44 | for branch in branches: |
|
45 | 45 | butf8 = encoding.fromlocal(branch) |
|
46 | 46 | if not primary(butf8): |
|
47 | 47 | raise error.RepoLookupError(_("unknown branch '%s'") % branch) |
|
48 | 48 | if hashbranch: |
|
49 | 49 | butf8 = encoding.fromlocal(hashbranch) |
|
50 | 50 | if not primary(butf8): |
|
51 | 51 | revs.append(hashbranch) |
|
52 | 52 | return revs, revs[0] |
|
53 | 53 | |
|
54 | 54 | def parseurl(url, branches=None): |
|
55 | 55 | '''parse url#branch, returning (url, (branch, branches))''' |
|
56 | 56 | |
|
57 | 57 | if '#' not in url: |
|
58 | 58 | return url, (None, branches or []) |
|
59 | 59 | url, branch = url.split('#', 1) |
|
60 | 60 | return url, (branch, branches or []) |
|
61 | 61 | |
|
62 | 62 | schemes = { |
|
63 | 63 | 'bundle': bundlerepo, |
|
64 | 64 | 'file': _local, |
|
65 | 65 | 'http': httprepo, |
|
66 | 66 | 'https': httprepo, |
|
67 | 67 | 'ssh': sshrepo, |
|
68 | 68 | 'static-http': statichttprepo, |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | def _lookup(path): |
|
72 | 72 | scheme = 'file' |
|
73 | 73 | if path: |
|
74 | 74 | c = path.find(':') |
|
75 | 75 | if c > 0: |
|
76 | 76 | scheme = path[:c] |
|
77 | 77 | thing = schemes.get(scheme) or schemes['file'] |
|
78 | 78 | try: |
|
79 | 79 | return thing(path) |
|
80 | 80 | except TypeError: |
|
81 | 81 | return thing |
|
82 | 82 | |
|
83 | 83 | def islocal(repo): |
|
84 | 84 | '''return true if repo or path is local''' |
|
85 | 85 | if isinstance(repo, str): |
|
86 | 86 | try: |
|
87 | 87 | return _lookup(repo).islocal(repo) |
|
88 | 88 | except AttributeError: |
|
89 | 89 | return False |
|
90 | 90 | return repo.local() |
|
91 | 91 | |
|
92 | 92 | def repository(ui, path='', create=False): |
|
93 | 93 | """return a repository object for the specified path""" |
|
94 | 94 | repo = _lookup(path).instance(ui, path, create) |
|
95 | 95 | ui = getattr(repo, "ui", ui) |
|
96 | 96 | for name, module in extensions.extensions(): |
|
97 | 97 | hook = getattr(module, 'reposetup', None) |
|
98 | 98 | if hook: |
|
99 | 99 | hook(ui, repo) |
|
100 | 100 | return repo |
|
101 | 101 | |
|
102 | 102 | def defaultdest(source): |
|
103 | 103 | '''return default destination of clone if none is given''' |
|
104 | 104 | return os.path.basename(os.path.normpath(source)) |
|
105 | 105 | |
|
106 | 106 | def localpath(path): |
|
107 | 107 | if path.startswith('file://localhost/'): |
|
108 | 108 | return path[16:] |
|
109 | 109 | if path.startswith('file://'): |
|
110 | 110 | return path[7:] |
|
111 | 111 | if path.startswith('file:'): |
|
112 | 112 | return path[5:] |
|
113 | 113 | return path |
|
114 | 114 | |
|
115 | 115 | def share(ui, source, dest=None, update=True): |
|
116 | 116 | '''create a shared repository''' |
|
117 | 117 | |
|
118 | 118 | if not islocal(source): |
|
119 | 119 | raise util.Abort(_('can only share local repositories')) |
|
120 | 120 | |
|
121 | 121 | if not dest: |
|
122 | 122 | dest = defaultdest(source) |
|
123 | 123 | else: |
|
124 | 124 | dest = ui.expandpath(dest) |
|
125 | 125 | |
|
126 | 126 | if isinstance(source, str): |
|
127 | 127 | origsource = ui.expandpath(source) |
|
128 | 128 | source, branches = parseurl(origsource) |
|
129 | 129 | srcrepo = repository(ui, source) |
|
130 | 130 | rev, checkout = addbranchrevs(srcrepo, srcrepo, branches, None) |
|
131 | 131 | else: |
|
132 | 132 | srcrepo = source |
|
133 | 133 | origsource = source = srcrepo.url() |
|
134 | 134 | checkout = None |
|
135 | 135 | |
|
136 | 136 | sharedpath = srcrepo.sharedpath # if our source is already sharing |
|
137 | 137 | |
|
138 | 138 | root = os.path.realpath(dest) |
|
139 | 139 | roothg = os.path.join(root, '.hg') |
|
140 | 140 | |
|
141 | 141 | if os.path.exists(roothg): |
|
142 | 142 | raise util.Abort(_('destination already exists')) |
|
143 | 143 | |
|
144 | 144 | if not os.path.isdir(root): |
|
145 | 145 | os.mkdir(root) |
|
146 | 146 | os.mkdir(roothg) |
|
147 | 147 | |
|
148 | 148 | requirements = '' |
|
149 | 149 | try: |
|
150 | 150 | requirements = srcrepo.opener('requires').read() |
|
151 | 151 | except IOError, inst: |
|
152 | 152 | if inst.errno != errno.ENOENT: |
|
153 | 153 | raise |
|
154 | 154 | |
|
155 | 155 | requirements += 'shared\n' |
|
156 | 156 | file(os.path.join(roothg, 'requires'), 'w').write(requirements) |
|
157 | 157 | file(os.path.join(roothg, 'sharedpath'), 'w').write(sharedpath) |
|
158 | 158 | |
|
159 | 159 | default = srcrepo.ui.config('paths', 'default') |
|
160 | 160 | if default: |
|
161 | 161 | f = file(os.path.join(roothg, 'hgrc'), 'w') |
|
162 | 162 | f.write('[paths]\ndefault = %s\n' % default) |
|
163 | 163 | f.close() |
|
164 | 164 | |
|
165 | 165 | r = repository(ui, root) |
|
166 | 166 | |
|
167 | 167 | if update: |
|
168 | 168 | r.ui.status(_("updating working directory\n")) |
|
169 | 169 | if update is not True: |
|
170 | 170 | checkout = update |
|
171 | 171 | for test in (checkout, 'default', 'tip'): |
|
172 | 172 | if test is None: |
|
173 | 173 | continue |
|
174 | 174 | try: |
|
175 | 175 | uprev = r.lookup(test) |
|
176 | 176 | break |
|
177 | 177 | except error.RepoLookupError: |
|
178 | 178 | continue |
|
179 | 179 | _update(r, uprev) |
|
180 | 180 | |
|
181 | 181 | def clone(ui, source, dest=None, pull=False, rev=None, update=True, |
|
182 | 182 | stream=False, branch=None): |
|
183 | 183 | """Make a copy of an existing repository. |
|
184 | 184 | |
|
185 | 185 | Create a copy of an existing repository in a new directory. The |
|
186 | 186 | source and destination are URLs, as passed to the repository |
|
187 | 187 | function. Returns a pair of repository objects, the source and |
|
188 | 188 | newly created destination. |
|
189 | 189 | |
|
190 | 190 | The location of the source is added to the new repository's |
|
191 | 191 | .hg/hgrc file, as the default to be used for future pulls and |
|
192 | 192 | pushes. |
|
193 | 193 | |
|
194 | 194 | If an exception is raised, the partly cloned/updated destination |
|
195 | 195 | repository will be deleted. |
|
196 | 196 | |
|
197 | 197 | Arguments: |
|
198 | 198 | |
|
199 | 199 | source: repository object or URL |
|
200 | 200 | |
|
201 | 201 | dest: URL of destination repository to create (defaults to base |
|
202 | 202 | name of source repository) |
|
203 | 203 | |
|
204 | 204 | pull: always pull from source repository, even in local case |
|
205 | 205 | |
|
206 | 206 | stream: stream raw data uncompressed from repository (fast over |
|
207 | 207 | LAN, slow over WAN) |
|
208 | 208 | |
|
209 | 209 | rev: revision to clone up to (implies pull=True) |
|
210 | 210 | |
|
211 | 211 | update: update working directory after clone completes, if |
|
212 | 212 | destination is local repository (True means update to default rev, |
|
213 | 213 | anything else is treated as a revision) |
|
214 | 214 | |
|
215 | 215 | branch: branches to clone |
|
216 | 216 | """ |
|
217 | 217 | |
|
218 | 218 | if isinstance(source, str): |
|
219 | 219 | origsource = ui.expandpath(source) |
|
220 | 220 | source, branch = parseurl(origsource, branch) |
|
221 | 221 | src_repo = repository(ui, source) |
|
222 | 222 | else: |
|
223 | 223 | src_repo = source |
|
224 | branch = (None, []) | |
|
224 | branch = (None, branch or []) | |
|
225 | 225 | origsource = source = src_repo.url() |
|
226 | 226 | rev, checkout = addbranchrevs(src_repo, src_repo, branch, rev) |
|
227 | 227 | |
|
228 | 228 | if dest is None: |
|
229 | 229 | dest = defaultdest(source) |
|
230 | 230 | ui.status(_("destination directory: %s\n") % dest) |
|
231 | 231 | else: |
|
232 | 232 | dest = ui.expandpath(dest) |
|
233 | 233 | |
|
234 | 234 | dest = localpath(dest) |
|
235 | 235 | source = localpath(source) |
|
236 | 236 | |
|
237 | 237 | if os.path.exists(dest): |
|
238 | 238 | if not os.path.isdir(dest): |
|
239 | 239 | raise util.Abort(_("destination '%s' already exists") % dest) |
|
240 | 240 | elif os.listdir(dest): |
|
241 | 241 | raise util.Abort(_("destination '%s' is not empty") % dest) |
|
242 | 242 | |
|
243 | 243 | class DirCleanup(object): |
|
244 | 244 | def __init__(self, dir_): |
|
245 | 245 | self.rmtree = shutil.rmtree |
|
246 | 246 | self.dir_ = dir_ |
|
247 | 247 | def close(self): |
|
248 | 248 | self.dir_ = None |
|
249 | 249 | def cleanup(self): |
|
250 | 250 | if self.dir_: |
|
251 | 251 | self.rmtree(self.dir_, True) |
|
252 | 252 | |
|
253 | 253 | src_lock = dest_lock = dir_cleanup = None |
|
254 | 254 | try: |
|
255 | 255 | if islocal(dest): |
|
256 | 256 | dir_cleanup = DirCleanup(dest) |
|
257 | 257 | |
|
258 | 258 | abspath = origsource |
|
259 | 259 | copy = False |
|
260 | 260 | if src_repo.cancopy() and islocal(dest): |
|
261 | 261 | abspath = os.path.abspath(util.drop_scheme('file', origsource)) |
|
262 | 262 | copy = not pull and not rev |
|
263 | 263 | |
|
264 | 264 | if copy: |
|
265 | 265 | try: |
|
266 | 266 | # we use a lock here because if we race with commit, we |
|
267 | 267 | # can end up with extra data in the cloned revlogs that's |
|
268 | 268 | # not pointed to by changesets, thus causing verify to |
|
269 | 269 | # fail |
|
270 | 270 | src_lock = src_repo.lock(wait=False) |
|
271 | 271 | except error.LockError: |
|
272 | 272 | copy = False |
|
273 | 273 | |
|
274 | 274 | if copy: |
|
275 | 275 | src_repo.hook('preoutgoing', throw=True, source='clone') |
|
276 | 276 | hgdir = os.path.realpath(os.path.join(dest, ".hg")) |
|
277 | 277 | if not os.path.exists(dest): |
|
278 | 278 | os.mkdir(dest) |
|
279 | 279 | else: |
|
280 | 280 | # only clean up directories we create ourselves |
|
281 | 281 | dir_cleanup.dir_ = hgdir |
|
282 | 282 | try: |
|
283 | 283 | dest_path = hgdir |
|
284 | 284 | os.mkdir(dest_path) |
|
285 | 285 | except OSError, inst: |
|
286 | 286 | if inst.errno == errno.EEXIST: |
|
287 | 287 | dir_cleanup.close() |
|
288 | 288 | raise util.Abort(_("destination '%s' already exists") |
|
289 | 289 | % dest) |
|
290 | 290 | raise |
|
291 | 291 | |
|
292 | 292 | hardlink = None |
|
293 | 293 | num = 0 |
|
294 | 294 | for f in src_repo.store.copylist(): |
|
295 | 295 | src = os.path.join(src_repo.sharedpath, f) |
|
296 | 296 | dst = os.path.join(dest_path, f) |
|
297 | 297 | dstbase = os.path.dirname(dst) |
|
298 | 298 | if dstbase and not os.path.exists(dstbase): |
|
299 | 299 | os.mkdir(dstbase) |
|
300 | 300 | if os.path.exists(src): |
|
301 | 301 | if dst.endswith('data'): |
|
302 | 302 | # lock to avoid premature writing to the target |
|
303 | 303 | dest_lock = lock.lock(os.path.join(dstbase, "lock")) |
|
304 | 304 | hardlink, n = util.copyfiles(src, dst, hardlink) |
|
305 | 305 | num += n |
|
306 | 306 | if hardlink: |
|
307 | 307 | ui.debug("linked %d files\n" % num) |
|
308 | 308 | else: |
|
309 | 309 | ui.debug("copied %d files\n" % num) |
|
310 | 310 | |
|
311 | 311 | # we need to re-init the repo after manually copying the data |
|
312 | 312 | # into it |
|
313 | 313 | dest_repo = repository(ui, dest) |
|
314 | 314 | src_repo.hook('outgoing', source='clone', node='0'*40) |
|
315 | 315 | else: |
|
316 | 316 | try: |
|
317 | 317 | dest_repo = repository(ui, dest, create=True) |
|
318 | 318 | except OSError, inst: |
|
319 | 319 | if inst.errno == errno.EEXIST: |
|
320 | 320 | dir_cleanup.close() |
|
321 | 321 | raise util.Abort(_("destination '%s' already exists") |
|
322 | 322 | % dest) |
|
323 | 323 | raise |
|
324 | 324 | |
|
325 | 325 | revs = None |
|
326 | 326 | if rev: |
|
327 | 327 | if 'lookup' not in src_repo.capabilities: |
|
328 | 328 | raise util.Abort(_("src repository does not support " |
|
329 | 329 | "revision lookup and so doesn't " |
|
330 | 330 | "support clone by revision")) |
|
331 | 331 | revs = [src_repo.lookup(r) for r in rev] |
|
332 | 332 | checkout = revs[0] |
|
333 | 333 | if dest_repo.local(): |
|
334 | 334 | dest_repo.clone(src_repo, heads=revs, stream=stream) |
|
335 | 335 | elif src_repo.local(): |
|
336 | 336 | src_repo.push(dest_repo, revs=revs) |
|
337 | 337 | else: |
|
338 | 338 | raise util.Abort(_("clone from remote to remote not supported")) |
|
339 | 339 | |
|
340 | 340 | if dir_cleanup: |
|
341 | 341 | dir_cleanup.close() |
|
342 | 342 | |
|
343 | 343 | if dest_repo.local(): |
|
344 | 344 | fp = dest_repo.opener("hgrc", "w", text=True) |
|
345 | 345 | fp.write("[paths]\n") |
|
346 | 346 | fp.write("default = %s\n" % abspath) |
|
347 | 347 | fp.close() |
|
348 | 348 | |
|
349 | 349 | dest_repo.ui.setconfig('paths', 'default', abspath) |
|
350 | 350 | |
|
351 | 351 | if update: |
|
352 | 352 | if update is not True: |
|
353 | 353 | checkout = update |
|
354 | 354 | if src_repo.local(): |
|
355 | 355 | checkout = src_repo.lookup(update) |
|
356 | 356 | for test in (checkout, 'default', 'tip'): |
|
357 | 357 | if test is None: |
|
358 | 358 | continue |
|
359 | 359 | try: |
|
360 | 360 | uprev = dest_repo.lookup(test) |
|
361 | 361 | break |
|
362 | 362 | except error.RepoLookupError: |
|
363 | 363 | continue |
|
364 | 364 | bn = dest_repo[uprev].branch() |
|
365 | 365 | dest_repo.ui.status(_("updating to branch %s\n") |
|
366 | 366 | % encoding.tolocal(bn)) |
|
367 | 367 | _update(dest_repo, uprev) |
|
368 | 368 | |
|
369 | 369 | return src_repo, dest_repo |
|
370 | 370 | finally: |
|
371 | 371 | release(src_lock, dest_lock) |
|
372 | 372 | if dir_cleanup is not None: |
|
373 | 373 | dir_cleanup.cleanup() |
|
374 | 374 | |
|
375 | 375 | def _showstats(repo, stats): |
|
376 | 376 | repo.ui.status(_("%d files updated, %d files merged, " |
|
377 | 377 | "%d files removed, %d files unresolved\n") % stats) |
|
378 | 378 | |
|
379 | 379 | def update(repo, node): |
|
380 | 380 | """update the working directory to node, merging linear changes""" |
|
381 | 381 | stats = mergemod.update(repo, node, False, False, None) |
|
382 | 382 | _showstats(repo, stats) |
|
383 | 383 | if stats[3]: |
|
384 | 384 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges\n")) |
|
385 | 385 | return stats[3] > 0 |
|
386 | 386 | |
|
387 | 387 | # naming conflict in clone() |
|
388 | 388 | _update = update |
|
389 | 389 | |
|
390 | 390 | def clean(repo, node, show_stats=True): |
|
391 | 391 | """forcibly switch the working directory to node, clobbering changes""" |
|
392 | 392 | stats = mergemod.update(repo, node, False, True, None) |
|
393 | 393 | if show_stats: |
|
394 | 394 | _showstats(repo, stats) |
|
395 | 395 | return stats[3] > 0 |
|
396 | 396 | |
|
397 | 397 | def merge(repo, node, force=None, remind=True): |
|
398 | 398 | """branch merge with node, resolving changes""" |
|
399 | 399 | stats = mergemod.update(repo, node, True, force, False) |
|
400 | 400 | _showstats(repo, stats) |
|
401 | 401 | if stats[3]: |
|
402 | 402 | repo.ui.status(_("use 'hg resolve' to retry unresolved file merges " |
|
403 | 403 | "or 'hg update -C' to abandon\n")) |
|
404 | 404 | elif remind: |
|
405 | 405 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
406 | 406 | return stats[3] > 0 |
|
407 | 407 | |
|
408 | 408 | def revert(repo, node, choose): |
|
409 | 409 | """revert changes to revision in node without updating dirstate""" |
|
410 | 410 | return mergemod.update(repo, node, False, True, choose)[3] > 0 |
|
411 | 411 | |
|
412 | 412 | def verify(repo): |
|
413 | 413 | """verify the consistency of a repository""" |
|
414 | 414 | return verifymod.verify(repo) |
|
415 | 415 | |
|
416 | 416 | def remoteui(src, opts): |
|
417 | 417 | 'build a remote ui from ui or repo and opts' |
|
418 | 418 | if hasattr(src, 'baseui'): # looks like a repository |
|
419 | 419 | dst = src.baseui.copy() # drop repo-specific config |
|
420 | 420 | src = src.ui # copy target options from repo |
|
421 | 421 | else: # assume it's a global ui object |
|
422 | 422 | dst = src.copy() # keep all global options |
|
423 | 423 | |
|
424 | 424 | # copy ssh-specific options |
|
425 | 425 | for o in 'ssh', 'remotecmd': |
|
426 | 426 | v = opts.get(o) or src.config('ui', o) |
|
427 | 427 | if v: |
|
428 | 428 | dst.setconfig("ui", o, v) |
|
429 | 429 | |
|
430 | 430 | # copy bundle-specific options |
|
431 | 431 | r = src.config('bundle', 'mainreporoot') |
|
432 | 432 | if r: |
|
433 | 433 | dst.setconfig('bundle', 'mainreporoot', r) |
|
434 | 434 | |
|
435 | 435 | # copy auth and http_proxy section settings |
|
436 | 436 | for sect in ('auth', 'http_proxy'): |
|
437 | 437 | for key, val in src.configitems(sect): |
|
438 | 438 | dst.setconfig(sect, key, val) |
|
439 | 439 | |
|
440 | 440 | return dst |
@@ -1,433 +1,443 b'' | |||
|
1 | 1 | Prepare repo a: |
|
2 | 2 | |
|
3 | 3 | $ mkdir a |
|
4 | 4 | $ cd a |
|
5 | 5 | $ hg init |
|
6 | 6 | $ echo a > a |
|
7 | 7 | $ hg add a |
|
8 | 8 | $ hg commit -m test |
|
9 | 9 | $ echo first line > b |
|
10 | 10 | $ hg add b |
|
11 | 11 | |
|
12 | 12 | Create a non-inlined filelog: |
|
13 | 13 | |
|
14 | 14 | $ python -c 'for x in range(10000): print x' >> data1 |
|
15 | 15 | $ for j in 0 1 2 3 4 5 6 7 8 9; do |
|
16 | 16 | > cat data1 >> b |
|
17 | 17 | > hg commit -m test |
|
18 | 18 | > done |
|
19 | 19 | |
|
20 | 20 | List files in store/data (should show a 'b.d'): |
|
21 | 21 | |
|
22 | 22 | $ for i in .hg/store/data/*; do |
|
23 | 23 | > echo $i |
|
24 | 24 | > done |
|
25 | 25 | .hg/store/data/a.i |
|
26 | 26 | .hg/store/data/b.d |
|
27 | 27 | .hg/store/data/b.i |
|
28 | 28 | |
|
29 | 29 | Default operation: |
|
30 | 30 | |
|
31 | 31 | $ hg clone . ../b |
|
32 | 32 | updating to branch default |
|
33 | 33 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
34 | 34 | $ cd ../b |
|
35 | 35 | $ cat a |
|
36 | 36 | a |
|
37 | 37 | $ hg verify |
|
38 | 38 | checking changesets |
|
39 | 39 | checking manifests |
|
40 | 40 | crosschecking files in changesets and manifests |
|
41 | 41 | checking files |
|
42 | 42 | 2 files, 11 changesets, 11 total revisions |
|
43 | 43 | |
|
44 | 44 | No update, with debug option: |
|
45 | 45 | |
|
46 | 46 | $ hg --debug clone -U . ../c |
|
47 | 47 | linked 8 files |
|
48 | 48 | $ cd ../c |
|
49 | 49 | $ cat a 2>/dev/null || echo "a not present" |
|
50 | 50 | a not present |
|
51 | 51 | $ hg verify |
|
52 | 52 | checking changesets |
|
53 | 53 | checking manifests |
|
54 | 54 | crosschecking files in changesets and manifests |
|
55 | 55 | checking files |
|
56 | 56 | 2 files, 11 changesets, 11 total revisions |
|
57 | 57 | |
|
58 | 58 | Default destination: |
|
59 | 59 | |
|
60 | 60 | $ mkdir ../d |
|
61 | 61 | $ cd ../d |
|
62 | 62 | $ hg clone ../a |
|
63 | 63 | destination directory: a |
|
64 | 64 | updating to branch default |
|
65 | 65 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
66 | 66 | $ cd a |
|
67 | 67 | $ hg cat a |
|
68 | 68 | a |
|
69 | 69 | $ cd ../.. |
|
70 | 70 | |
|
71 | 71 | Check that we drop the 'file:' from the path before writing the .hgrc: |
|
72 | 72 | |
|
73 | 73 | $ hg clone file:a e |
|
74 | 74 | updating to branch default |
|
75 | 75 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
76 | 76 | $ grep 'file:' e/.hg/hgrc |
|
77 | 77 | |
|
78 | 78 | Check that path aliases are expanded: |
|
79 | 79 | |
|
80 | 80 | $ hg clone -q -U --config 'paths.foobar=a#0' foobar f |
|
81 | 81 | $ hg -R f showconfig paths.default |
|
82 | 82 | .*/a#0 |
|
83 | 83 | |
|
84 | 84 | Use --pull: |
|
85 | 85 | |
|
86 | 86 | $ hg clone --pull a g |
|
87 | 87 | requesting all changes |
|
88 | 88 | adding changesets |
|
89 | 89 | adding manifests |
|
90 | 90 | adding file changes |
|
91 | 91 | added 11 changesets with 11 changes to 2 files |
|
92 | 92 | updating to branch default |
|
93 | 93 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
94 | 94 | $ hg -R g verify |
|
95 | 95 | checking changesets |
|
96 | 96 | checking manifests |
|
97 | 97 | crosschecking files in changesets and manifests |
|
98 | 98 | checking files |
|
99 | 99 | 2 files, 11 changesets, 11 total revisions |
|
100 | 100 | |
|
101 | 101 | Clone to '.': |
|
102 | 102 | |
|
103 | 103 | $ mkdir h |
|
104 | 104 | $ cd h |
|
105 | 105 | $ hg clone ../a . |
|
106 | 106 | updating to branch default |
|
107 | 107 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
108 | 108 | $ cd .. |
|
109 | 109 | |
|
110 | 110 | |
|
111 | 111 | *** Tests for option -u *** |
|
112 | 112 | |
|
113 | 113 | Adding some more history to repo a: |
|
114 | 114 | |
|
115 | 115 | $ cd a |
|
116 | 116 | $ hg tag ref1 |
|
117 | 117 | $ echo the quick brown fox >a |
|
118 | 118 | $ hg ci -m "hacked default" |
|
119 | 119 | $ hg up ref1 |
|
120 | 120 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
121 | 121 | $ hg branch stable |
|
122 | 122 | marked working directory as branch stable |
|
123 | 123 | $ echo some text >a |
|
124 | 124 | $ hg ci -m "starting branch stable" |
|
125 | 125 | $ hg tag ref2 |
|
126 | 126 | $ echo some more text >a |
|
127 | 127 | $ hg ci -m "another change for branch stable" |
|
128 | 128 | $ hg up ref2 |
|
129 | 129 | 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
130 | 130 | $ hg parents |
|
131 | 131 | changeset: 13:e8ece76546a6 |
|
132 | 132 | branch: stable |
|
133 | 133 | tag: ref2 |
|
134 | 134 | parent: 10:a7949464abda |
|
135 | 135 | user: test |
|
136 | 136 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
137 | 137 | summary: starting branch stable |
|
138 | 138 | |
|
139 | 139 | |
|
140 | 140 | Repo a has two heads: |
|
141 | 141 | |
|
142 | 142 | $ hg heads |
|
143 | 143 | changeset: 15:0aae7cf88f0d |
|
144 | 144 | branch: stable |
|
145 | 145 | tag: tip |
|
146 | 146 | user: test |
|
147 | 147 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
148 | 148 | summary: another change for branch stable |
|
149 | 149 | |
|
150 | 150 | changeset: 12:f21241060d6a |
|
151 | 151 | user: test |
|
152 | 152 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
153 | 153 | summary: hacked default |
|
154 | 154 | |
|
155 | 155 | |
|
156 | 156 | $ cd .. |
|
157 | 157 | |
|
158 | 158 | |
|
159 | 159 | Testing --noupdate with --updaterev (must abort): |
|
160 | 160 | |
|
161 | 161 | $ hg clone --noupdate --updaterev 1 a ua |
|
162 | 162 | abort: cannot specify both --noupdate and --updaterev |
|
163 | 163 | |
|
164 | 164 | |
|
165 | 165 | Testing clone -u: |
|
166 | 166 | |
|
167 | 167 | $ hg clone -u . a ua |
|
168 | 168 | updating to branch stable |
|
169 | 169 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
170 | 170 | |
|
171 | 171 | Repo ua has both heads: |
|
172 | 172 | |
|
173 | 173 | $ hg -R ua heads |
|
174 | 174 | changeset: 15:0aae7cf88f0d |
|
175 | 175 | branch: stable |
|
176 | 176 | tag: tip |
|
177 | 177 | user: test |
|
178 | 178 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
179 | 179 | summary: another change for branch stable |
|
180 | 180 | |
|
181 | 181 | changeset: 12:f21241060d6a |
|
182 | 182 | user: test |
|
183 | 183 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
184 | 184 | summary: hacked default |
|
185 | 185 | |
|
186 | 186 | |
|
187 | 187 | Same revision checked out in repo a and ua: |
|
188 | 188 | |
|
189 | 189 | $ hg -R a parents --template "{node|short}\n" |
|
190 | 190 | e8ece76546a6 |
|
191 | 191 | $ hg -R ua parents --template "{node|short}\n" |
|
192 | 192 | e8ece76546a6 |
|
193 | 193 | |
|
194 | 194 | $ rm -r ua |
|
195 | 195 | |
|
196 | 196 | |
|
197 | 197 | Testing clone --pull -u: |
|
198 | 198 | |
|
199 | 199 | $ hg clone --pull -u . a ua |
|
200 | 200 | requesting all changes |
|
201 | 201 | adding changesets |
|
202 | 202 | adding manifests |
|
203 | 203 | adding file changes |
|
204 | 204 | added 16 changesets with 16 changes to 3 files (+1 heads) |
|
205 | 205 | updating to branch stable |
|
206 | 206 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
207 | 207 | |
|
208 | 208 | Repo ua has both heads: |
|
209 | 209 | |
|
210 | 210 | $ hg -R ua heads |
|
211 | 211 | changeset: 15:0aae7cf88f0d |
|
212 | 212 | branch: stable |
|
213 | 213 | tag: tip |
|
214 | 214 | user: test |
|
215 | 215 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
216 | 216 | summary: another change for branch stable |
|
217 | 217 | |
|
218 | 218 | changeset: 12:f21241060d6a |
|
219 | 219 | user: test |
|
220 | 220 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
221 | 221 | summary: hacked default |
|
222 | 222 | |
|
223 | 223 | |
|
224 | 224 | Same revision checked out in repo a and ua: |
|
225 | 225 | |
|
226 | 226 | $ hg -R a parents --template "{node|short}\n" |
|
227 | 227 | e8ece76546a6 |
|
228 | 228 | $ hg -R ua parents --template "{node|short}\n" |
|
229 | 229 | e8ece76546a6 |
|
230 | 230 | |
|
231 | 231 | $ rm -r ua |
|
232 | 232 | |
|
233 | 233 | |
|
234 | 234 | Testing clone -u <branch>: |
|
235 | 235 | |
|
236 | 236 | $ hg clone -u stable a ua |
|
237 | 237 | updating to branch stable |
|
238 | 238 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
239 | 239 | |
|
240 | 240 | Repo ua has both heads: |
|
241 | 241 | |
|
242 | 242 | $ hg -R ua heads |
|
243 | 243 | changeset: 15:0aae7cf88f0d |
|
244 | 244 | branch: stable |
|
245 | 245 | tag: tip |
|
246 | 246 | user: test |
|
247 | 247 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
248 | 248 | summary: another change for branch stable |
|
249 | 249 | |
|
250 | 250 | changeset: 12:f21241060d6a |
|
251 | 251 | user: test |
|
252 | 252 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
253 | 253 | summary: hacked default |
|
254 | 254 | |
|
255 | 255 | |
|
256 | 256 | Branch 'stable' is checked out: |
|
257 | 257 | |
|
258 | 258 | $ hg -R ua parents |
|
259 | 259 | changeset: 15:0aae7cf88f0d |
|
260 | 260 | branch: stable |
|
261 | 261 | tag: tip |
|
262 | 262 | user: test |
|
263 | 263 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
264 | 264 | summary: another change for branch stable |
|
265 | 265 | |
|
266 | 266 | |
|
267 | 267 | $ rm -r ua |
|
268 | 268 | |
|
269 | 269 | |
|
270 | 270 | Testing default checkout: |
|
271 | 271 | |
|
272 | 272 | $ hg clone a ua |
|
273 | 273 | updating to branch default |
|
274 | 274 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
275 | 275 | |
|
276 | 276 | Repo ua has both heads: |
|
277 | 277 | |
|
278 | 278 | $ hg -R ua heads |
|
279 | 279 | changeset: 15:0aae7cf88f0d |
|
280 | 280 | branch: stable |
|
281 | 281 | tag: tip |
|
282 | 282 | user: test |
|
283 | 283 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
284 | 284 | summary: another change for branch stable |
|
285 | 285 | |
|
286 | 286 | changeset: 12:f21241060d6a |
|
287 | 287 | user: test |
|
288 | 288 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
289 | 289 | summary: hacked default |
|
290 | 290 | |
|
291 | 291 | |
|
292 | 292 | Branch 'default' is checked out: |
|
293 | 293 | |
|
294 | 294 | $ hg -R ua parents |
|
295 | 295 | changeset: 12:f21241060d6a |
|
296 | 296 | user: test |
|
297 | 297 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
298 | 298 | summary: hacked default |
|
299 | 299 | |
|
300 | 300 | |
|
301 | 301 | $ rm -r ua |
|
302 | 302 | |
|
303 | 303 | |
|
304 | 304 | Testing #<branch>: |
|
305 | 305 | |
|
306 | 306 | $ hg clone -u . a#stable ua |
|
307 | 307 | requesting all changes |
|
308 | 308 | adding changesets |
|
309 | 309 | adding manifests |
|
310 | 310 | adding file changes |
|
311 | 311 | added 14 changesets with 14 changes to 3 files |
|
312 | 312 | updating to branch stable |
|
313 | 313 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
314 | 314 | |
|
315 | 315 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
316 | 316 | |
|
317 | 317 | $ hg -R ua heads |
|
318 | 318 | changeset: 13:0aae7cf88f0d |
|
319 | 319 | branch: stable |
|
320 | 320 | tag: tip |
|
321 | 321 | user: test |
|
322 | 322 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
323 | 323 | summary: another change for branch stable |
|
324 | 324 | |
|
325 | 325 | changeset: 10:a7949464abda |
|
326 | 326 | user: test |
|
327 | 327 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
328 | 328 | summary: test |
|
329 | 329 | |
|
330 | 330 | |
|
331 | 331 | Same revision checked out in repo a and ua: |
|
332 | 332 | |
|
333 | 333 | $ hg -R a parents --template "{node|short}\n" |
|
334 | 334 | e8ece76546a6 |
|
335 | 335 | $ hg -R ua parents --template "{node|short}\n" |
|
336 | 336 | e8ece76546a6 |
|
337 | 337 | |
|
338 | 338 | $ rm -r ua |
|
339 | 339 | |
|
340 | 340 | |
|
341 | 341 | Testing -u -r <branch>: |
|
342 | 342 | |
|
343 | 343 | $ hg clone -u . -r stable a ua |
|
344 | 344 | requesting all changes |
|
345 | 345 | adding changesets |
|
346 | 346 | adding manifests |
|
347 | 347 | adding file changes |
|
348 | 348 | added 14 changesets with 14 changes to 3 files |
|
349 | 349 | updating to branch stable |
|
350 | 350 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
351 | 351 | |
|
352 | 352 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
353 | 353 | |
|
354 | 354 | $ hg -R ua heads |
|
355 | 355 | changeset: 13:0aae7cf88f0d |
|
356 | 356 | branch: stable |
|
357 | 357 | tag: tip |
|
358 | 358 | user: test |
|
359 | 359 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
360 | 360 | summary: another change for branch stable |
|
361 | 361 | |
|
362 | 362 | changeset: 10:a7949464abda |
|
363 | 363 | user: test |
|
364 | 364 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
365 | 365 | summary: test |
|
366 | 366 | |
|
367 | 367 | |
|
368 | 368 | Same revision checked out in repo a and ua: |
|
369 | 369 | |
|
370 | 370 | $ hg -R a parents --template "{node|short}\n" |
|
371 | 371 | e8ece76546a6 |
|
372 | 372 | $ hg -R ua parents --template "{node|short}\n" |
|
373 | 373 | e8ece76546a6 |
|
374 | 374 | |
|
375 | 375 | $ rm -r ua |
|
376 | 376 | |
|
377 | 377 | |
|
378 | 378 | Testing -r <branch>: |
|
379 | 379 | |
|
380 | 380 | $ hg clone -r stable a ua |
|
381 | 381 | requesting all changes |
|
382 | 382 | adding changesets |
|
383 | 383 | adding manifests |
|
384 | 384 | adding file changes |
|
385 | 385 | added 14 changesets with 14 changes to 3 files |
|
386 | 386 | updating to branch stable |
|
387 | 387 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
388 | 388 | |
|
389 | 389 | Repo ua has branch 'stable' and 'default' (was changed in fd511e9eeea6): |
|
390 | 390 | |
|
391 | 391 | $ hg -R ua heads |
|
392 | 392 | changeset: 13:0aae7cf88f0d |
|
393 | 393 | branch: stable |
|
394 | 394 | tag: tip |
|
395 | 395 | user: test |
|
396 | 396 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
397 | 397 | summary: another change for branch stable |
|
398 | 398 | |
|
399 | 399 | changeset: 10:a7949464abda |
|
400 | 400 | user: test |
|
401 | 401 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
402 | 402 | summary: test |
|
403 | 403 | |
|
404 | 404 | |
|
405 | 405 | Branch 'stable' is checked out: |
|
406 | 406 | |
|
407 | 407 | $ hg -R ua parents |
|
408 | 408 | changeset: 13:0aae7cf88f0d |
|
409 | 409 | branch: stable |
|
410 | 410 | tag: tip |
|
411 | 411 | user: test |
|
412 | 412 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
413 | 413 | summary: another change for branch stable |
|
414 | 414 | |
|
415 | 415 | |
|
416 | 416 | $ rm -r ua |
|
417 | 417 | |
|
418 | 418 | |
|
419 | 419 | Testing issue2267: |
|
420 | 420 | |
|
421 | 421 | $ cat <<EOF > simpleclone.py |
|
422 | 422 | > from mercurial import ui, hg |
|
423 | 423 | > myui = ui.ui() |
|
424 | 424 | > repo = hg.repository(myui, 'a') |
|
425 | 425 | > hg.clone(myui, repo, dest="ua") |
|
426 | 426 | > EOF |
|
427 | 427 | |
|
428 | 428 | $ python simpleclone.py |
|
429 | 429 | updating to branch default |
|
430 | 430 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
431 | 431 | |
|
432 | 432 | $ rm -r ua |
|
433 | 433 | |
|
434 | cat <<EOF > branchclone.py | |
|
435 | from mercurial import ui, hg | |
|
436 | myui = ui.ui() | |
|
437 | repo = hg.repository(myui, 'a') | |
|
438 | hg.clone(myui, repo, dest="ua", branch=["stable",]) | |
|
439 | EOF | |
|
440 | ||
|
441 | python branchclone.py | |
|
442 | rm -r ua | |
|
443 |
General Comments 0
You need to be logged in to leave comments.
Login now