##// 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 and then resume where you left off by calling :hg:`transplant
494 and then resume where you left off by calling :hg:`transplant
495 --continue/-c`.
495 --continue/-c`.
496 '''
496 '''
497 def incwalk(repo, commmon, branches, match=util.always):
497 def incwalk(repo, csets, match=util.always):
498 if not branches:
498 for node in csets:
499 branches = None
500 for node in repo.changelog.findmissing(common, branches):
501 if match(node):
499 if match(node):
502 yield node
500 yield node
503
501
@@ -547,15 +545,16 b' def transplant(ui, repo, *revs, **opts):'
547 if m or a or r or d:
545 if m or a or r or d:
548 raise util.Abort(_('outstanding local changes'))
546 raise util.Abort(_('outstanding local changes'))
549
547
550 bundle = None
548 sourcerepo = opts.get('source')
551 source = opts.get('source')
549 if sourcerepo:
552 if source:
550 source = hg.repository(ui, ui.expandpath(sourcerepo))
553 sourcerepo = ui.expandpath(source)
551 branches = map(source.lookup, opts.get('branch', ()))
554 source = hg.repository(ui, sourcerepo)
552 source, csets, cleanupfn = bundlerepo.getremotechanges(ui, repo, source,
555 source, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo,
553 onlyheads=branches, force=True)
556 source, force=True)
557 else:
554 else:
558 source = repo
555 source = repo
556 branches = map(source.lookup, opts.get('branch', ()))
557 cleanupfn = None
559
558
560 try:
559 try:
561 if opts.get('continue'):
560 if opts.get('continue'):
@@ -569,7 +568,6 b' def transplant(ui, repo, *revs, **opts):'
569 matchfn = lambda x: tf(x) and x not in prune
568 matchfn = lambda x: tf(x) and x not in prune
570 else:
569 else:
571 matchfn = tf
570 matchfn = tf
572 branches = map(source.lookup, opts.get('branch', ()))
573 merges = map(source.lookup, opts.get('merge', ()))
571 merges = map(source.lookup, opts.get('merge', ()))
574 revmap = {}
572 revmap = {}
575 if revs:
573 if revs:
@@ -577,8 +575,7 b' def transplant(ui, repo, *revs, **opts):'
577 revmap[int(r)] = source.lookup(r)
575 revmap[int(r)] = source.lookup(r)
578 elif opts.get('all') or not merges:
576 elif opts.get('all') or not merges:
579 if source != repo:
577 if source != repo:
580 alltransplants = incwalk(source, common, branches,
578 alltransplants = incwalk(source, csets, match=matchfn)
581 match=matchfn)
582 else:
579 else:
583 alltransplants = transplantwalk(source, p1, branches,
580 alltransplants = transplantwalk(source, p1, branches,
584 match=matchfn)
581 match=matchfn)
@@ -594,9 +591,8 b' def transplant(ui, repo, *revs, **opts):'
594
591
595 tp.apply(repo, source, revmap, merges, opts)
592 tp.apply(repo, source, revmap, merges, opts)
596 finally:
593 finally:
597 if bundle:
594 if cleanupfn:
598 source.close()
595 cleanupfn()
599 os.unlink(bundle)
600
596
601 def revsettransplanted(repo, subset, x):
597 def revsettransplanted(repo, subset, x):
602 """``transplanted(set)``
598 """``transplanted(set)``
@@ -288,30 +288,48 b' def instance(ui, path, create):'
288 repopath, bundlename = parentpath, path
288 repopath, bundlename = parentpath, path
289 return bundlerepository(ui, repopath, bundlename)
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 force=False):
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 common, incoming, rheads = tmp
310 common, incoming, rheads = tmp
295 if not incoming:
311 if not incoming:
296 try:
312 try:
297 os.unlink(bundlename)
313 os.unlink(bundlename)
298 except OSError:
314 except OSError:
299 pass
315 pass
300 return other, None, None, None
316 return other, [], other.close
301
317
302 bundle = None
318 bundle = None
319 bundlerepo = None
320 localrepo = other
303 if bundlename or not other.local():
321 if bundlename or not other.local():
304 # create a bundle (uncompressed if other repo is not local)
322 # create a bundle (uncompressed if other repo is not local)
305
323
306 if revs is None and other.capable('changegroupsubset'):
324 if onlyheads is None and other.capable('changegroupsubset'):
307 revs = rheads
325 onlyheads = rheads
308
326
309 if other.capable('getbundle'):
327 if other.capable('getbundle'):
310 cg = other.getbundle('incoming', common=common, heads=revs)
328 cg = other.getbundle('incoming', common=common, heads=onlyheads)
311 elif revs is None:
329 elif onlyheads is None:
312 cg = other.changegroup(incoming, "incoming")
330 cg = other.changegroup(incoming, "incoming")
313 else:
331 else:
314 cg = other.changegroupsubset(incoming, revs, 'incoming')
332 cg = other.changegroupsubset(incoming, onlyheads, 'incoming')
315 bundletype = other.local() and "HG10BZ" or "HG10UN"
333 bundletype = other.local() and "HG10BZ" or "HG10UN"
316 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
334 fname = bundle = changegroup.writebundle(cg, bundlename, bundletype)
317 # keep written bundle?
335 # keep written bundle?
@@ -319,6 +337,18 b' def getremotechanges(ui, repo, other, re'
319 bundle = None
337 bundle = None
320 if not other.local():
338 if not other.local():
321 # use the created uncompressed bundlerepo
339 # use the created uncompressed bundlerepo
322 other = bundlerepository(ui, repo.root, fname)
340 localrepo = bundlerepo = bundlerepository(ui, repo.root, fname)
323 return (other, common, incoming, bundle)
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 if revs:
428 if revs:
429 revs = [other.lookup(rev) for rev in revs]
429 revs = [other.lookup(rev) for rev in revs]
430 other, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo, other,
430 other, chlist, cleanupfn = bundlerepo.getremotechanges(ui, repo, other,
431 revs, opts["bundle"], opts["force"])
431 revs, opts["bundle"], opts["force"])
432 if not anyinc:
432 try:
433 ui.status(_("no changes found\n"))
433 if not chlist:
434 return subreporecurse()
434 ui.status(_("no changes found\n"))
435 return subreporecurse()
435
436
436 try:
437 chlist = other.changelog.findmissing(common, revs)
438 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
437 displayer = cmdutil.show_changeset(ui, other, opts, buffered)
439
438
440 # XXX once graphlog extension makes it into core,
439 # XXX once graphlog extension makes it into core,
@@ -443,10 +442,7 b' def _incoming(displaychlist, subreporecu'
443
442
444 displayer.close()
443 displayer.close()
445 finally:
444 finally:
446 if hasattr(other, 'close'):
445 cleanupfn()
447 other.close()
448 if bundle:
449 os.unlink(bundle)
450 subreporecurse()
446 subreporecurse()
451 return 0 # exit code is zero since we found incoming changes
447 return 0 # exit code is zero since we found incoming changes
452
448
@@ -70,6 +70,24 b' clone via pull'
70 adding bar
70 adding bar
71 $ cd ..
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 pull
91 pull
74
92
75 $ cd copy-pull
93 $ cd copy-pull
General Comments 0
You need to be logged in to leave comments. Login now