##// END OF EJS Templates
bundlerepo: fix and improve getremotechanges...
Peter Arrenbrecht -
r14161:8a0fca92 default
parent child Browse files
Show More
@@ -494,10 +494,8 b' def transplant(ui, repo, *revs, **opts):'
494 494 and then resume where you left off by calling :hg:`transplant
495 495 --continue/-c`.
496 496 '''
497 def incwalk(repo, commmon, branches, match=util.always):
498 if not branches:
499 branches = None
500 for node in repo.changelog.findmissing(common, branches):
497 def incwalk(repo, csets, match=util.always):
498 for node in csets:
501 499 if match(node):
502 500 yield node
503 501
@@ -547,15 +545,16 b' def transplant(ui, repo, *revs, **opts):'
547 545 if m or a or r or d:
548 546 raise util.Abort(_('outstanding local changes'))
549 547
550 bundle = None
551 source = opts.get('source')
552 if source:
553 sourcerepo = ui.expandpath(source)
554 source = hg.repository(ui, sourcerepo)
555 source, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo,
556 source, force=True)
548 sourcerepo = opts.get('source')
549 if sourcerepo:
550 source = hg.repository(ui, ui.expandpath(sourcerepo))
551 branches = map(source.lookup, opts.get('branch', ()))
552 source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, source,
553 onlyheads=branches, force=True)
557 554 else:
558 555 source = repo
556 branches = map(source.lookup, opts.get('branch', ()))
557 cleanupfn = None
559 558
560 559 try:
561 560 if opts.get('continue'):
@@ -569,7 +568,6 b' def transplant(ui, repo, *revs, **opts):'
569 568 matchfn = lambda x: tf(x) and x not in prune
570 569 else:
571 570 matchfn = tf
572 branches = map(source.lookup, opts.get('branch', ()))
573 571 merges = map(source.lookup, opts.get('merge', ()))
574 572 revmap = {}
575 573 if revs:
@@ -577,8 +575,7 b' def transplant(ui, repo, *revs, **opts):'
577 575 revmap[int(r)] = source.lookup(r)
578 576 elif opts.get('all') or not merges:
579 577 if source != repo:
580 alltransplants = incwalk(source, common, branches,
581 match=matchfn)
578 alltransplants = incwalk(source, csets, match=matchfn)
582 579 else:
583 580 alltransplants = transplantwalk(source, p1, branches,
584 581 match=matchfn)
@@ -594,9 +591,8 b' def transplant(ui, repo, *revs, **opts):'
594 591
595 592 tp.apply(repo, source, revmap, merges, opts)
596 593 finally:
597 if bundle:
598 source.close()
599 os.unlink(bundle)
594 if cleanupfn:
595 cleanupfn()
600 596
601 597 def revsettransplanted(repo, subset, x):
602 598 """``transplanted(set)``
@@ -288,30 +288,48 b' def instance(ui, path, create):'
288 288 repopath, bundlename = parentpath, path
289 289 return bundlerepository(ui, repopath, bundlename)
290 290
291 def getremotechanges(ui, repo, other, revs=None, bundlename=None,
291 def getremotechanges(ui, repo, other, onlyheads=None, bundlename=None,
292 292 force=False):
293 tmp = discovery.findcommonincoming(repo, other, heads=revs, force=force)
293 '''obtains a bundle of changes incoming from other
294
295 "onlyheads" restricts the returned changes to those reachable from the
296 specified heads.
297 "bundlename", if given, stores the bundle to this file path permanently;
298 the returned "bundle" will be None.
299 "force" indicates whether to proceed on unrelated repos.
300
301 Returns a tuple (local, csets, cleanupfn):
302
303 "local" is a local repo from which to obtain the actual incoming changesets; it
304 is a bundlerepo for the obtained bundle when the original "other" is remote.
305 "csets" lists the incoming changeset node ids.
306 "cleanupfn" must be called without arguments when you're done processing the
307 changes; it closes both the original "other" and the one returned here.
308 '''
309 tmp = discovery.findcommonincoming(repo, other, heads=onlyheads, force=force)
294 310 common, incoming, rheads = tmp
295 311 if not incoming:
296 312 try:
297 313 os.unlink(bundlename)
298 314 except OSError:
299 315 pass
300 return other, None, None, None
316 return other, [], other.close
301 317
302 318 bundle = None
319 bundlerepo = None
320 localrepo = other
303 321 if bundlename or not other.local():
304 322 # create a bundle (uncompressed if other repo is not local)
305 323
306 if revs is None and other.capable('changegroupsubset'):
307 revs = rheads
324 if onlyheads is None and other.capable('changegroupsubset'):
325 onlyheads = rheads
308 326
309 327 if other.capable('getbundle'):
310 cg = other.getbundle('incoming', common=common, heads=revs)
311 elif revs is None:
328 cg = other.getbundle('incoming', common=common, heads=onlyheads)
329 elif onlyheads is None:
312 330 cg = other.changegroup(incoming, "incoming")
313 331 else:
314 cg = other.changegroupsubset(incoming, revs, 'incoming')
332 cg = other.changegroupsubset(incoming, onlyheads, 'incoming')
315 333 bundletype = other.local() and "HG10BZ" or "HG10UN"
316 334 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
317 335 # keep written bundle?
@@ -319,6 +337,18 b' def getremotechanges(ui, repo, other, re'
319 337 bundle = None
320 338 if not other.local():
321 339 # use the created uncompressed bundlerepo
322 other = bundlerepository(ui, repo.root, fname)
323 return (other, common, incoming, bundle)
340 localrepo = bundlerepo = bundlerepository(ui, repo.root, fname)
341 # this repo contains local and other now, so filter out local again
342 common = repo.heads()
343
344 csets = localrepo.changelog.findmissing(common, onlyheads)
324 345
346 def cleanup():
347 if bundlerepo:
348 bundlerepo.close()
349 if bundle:
350 os.unlink(bundle)
351 localrepo.close()
352
353 return (localrepo, csets, cleanup)
354
@@ -427,14 +427,13 b' def _incoming(displaychlist, subreporecu'
427 427
428 428 if revs:
429 429 revs = [other.lookup(rev) for rev in revs]
430 other, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo, other,
431 revs, opts["bundle"], opts["force"])
432 if not anyinc:
433 ui.status(_("no changes found\n"))
434 return subreporecurse()
430 other, chlist, cleanupfn = bundlerepo.getremotechanges(ui, repo, other,
431 revs, opts["bundle"], opts["force"])
432 try:
433 if not chlist:
434 ui.status(_("no changes found\n"))
435 return subreporecurse()
435 436
436 try:
437 chlist = other.changelog.findmissing(common, revs)
438 437 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
439 438
440 439 # XXX once graphlog extension makes it into core,
@@ -443,10 +442,7 b' def _incoming(displaychlist, subreporecu'
443 442
444 443 displayer.close()
445 444 finally:
446 if hasattr(other, 'close'):
447 other.close()
448 if bundle:
449 os.unlink(bundle)
445 cleanupfn()
450 446 subreporecurse()
451 447 return 0 # exit code is zero since we found incoming changes
452 448
@@ -70,6 +70,24 b' clone via pull'
70 70 adding bar
71 71 $ cd ..
72 72
73 incoming via HTTP
74
75 $ hg clone http://localhost:$HGPORT1/ --rev 0 partial
76 adding changesets
77 adding manifests
78 adding file changes
79 added 1 changesets with 4 changes to 4 files
80 updating to branch default
81 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
82 $ cd partial
83 $ touch LOCAL
84 $ hg ci -qAm LOCAL
85 $ hg incoming http://localhost:$HGPORT1/ --template '{desc}\n'
86 comparing with http://localhost:$HGPORT1/
87 searching for changes
88 2
89 $ cd ..
90
73 91 pull
74 92
75 93 $ cd copy-pull
General Comments 0
You need to be logged in to leave comments. Login now