##// END OF EJS Templates
pull: introduce a pulloperation object...
Pierre-Yves David -
r20472:b97a453b default
parent child Browse files
Show More
@@ -373,10 +373,23 b' def _pushbookmark(pushop):'
373 else:
373 else:
374 ui.warn(_('updating bookmark %s failed!\n') % b)
374 ui.warn(_('updating bookmark %s failed!\n') % b)
375
375
376 class pulloperation(object):
377 """A object that represent a single pull operation
378
379 It purpose is to carry push related state and very common operation.
380
381 A new should be created at the begining of each push and discarded
382 afterward.
383 """
384
385 def __init__(self, repo):
386 # repo we pull from
387 self.repo = repo
376
388
377 def pull(repo, remote, heads=None, force=False):
389 def pull(repo, remote, heads=None, force=False):
390 pullop = pulloperation(repo)
378 if remote.local():
391 if remote.local():
379 missing = set(remote.requirements) - repo.supported
392 missing = set(remote.requirements) - pullop.repo.supported
380 if missing:
393 if missing:
381 msg = _("required features are not"
394 msg = _("required features are not"
382 " supported in the destination:"
395 " supported in the destination:"
@@ -387,18 +400,18 b' def pull(repo, remote, heads=None, force'
387 # rollback call
400 # rollback call
388 tr = None
401 tr = None
389 trname = 'pull\n' + util.hidepassword(remote.url())
402 trname = 'pull\n' + util.hidepassword(remote.url())
390 lock = repo.lock()
403 lock = pullop.repo.lock()
391 try:
404 try:
392 tmp = discovery.findcommonincoming(repo.unfiltered(), remote,
405 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(), remote,
393 heads=heads, force=force)
406 heads=heads, force=force)
394 common, fetch, rheads = tmp
407 common, fetch, rheads = tmp
395 if not fetch:
408 if not fetch:
396 repo.ui.status(_("no changes found\n"))
409 pullop.repo.ui.status(_("no changes found\n"))
397 result = 0
410 result = 0
398 else:
411 else:
399 tr = repo.transaction(trname)
412 tr = pullop.repo.transaction(trname)
400 if heads is None and list(common) == [nullid]:
413 if heads is None and list(common) == [nullid]:
401 repo.ui.status(_("requesting all changes\n"))
414 pullop.repo.ui.status(_("requesting all changes\n"))
402 elif heads is None and remote.capable('changegroupsubset'):
415 elif heads is None and remote.capable('changegroupsubset'):
403 # issue1320, avoid a race if remote changed after discovery
416 # issue1320, avoid a race if remote changed after discovery
404 heads = rheads
417 heads = rheads
@@ -415,7 +428,7 b' def pull(repo, remote, heads=None, force'
415 "changegroupsubset."))
428 "changegroupsubset."))
416 else:
429 else:
417 cg = remote.changegroupsubset(fetch, heads, 'pull')
430 cg = remote.changegroupsubset(fetch, heads, 'pull')
418 result = repo.addchangegroup(cg, 'pull', remote.url())
431 result = pullop.repo.addchangegroup(cg, 'pull', remote.url())
419
432
420 # compute target subset
433 # compute target subset
421 if heads is None:
434 if heads is None:
@@ -432,21 +445,21 b' def pull(repo, remote, heads=None, force'
432 publishing = bool(remotephases.get('publishing', False))
445 publishing = bool(remotephases.get('publishing', False))
433 if remotephases and not publishing:
446 if remotephases and not publishing:
434 # remote is new and unpublishing
447 # remote is new and unpublishing
435 pheads, _dr = phases.analyzeremotephases(repo, subset,
448 pheads, _dr = phases.analyzeremotephases(pullop.repo, subset,
436 remotephases)
449 remotephases)
437 phases.advanceboundary(repo, phases.public, pheads)
450 phases.advanceboundary(pullop.repo, phases.public, pheads)
438 phases.advanceboundary(repo, phases.draft, subset)
451 phases.advanceboundary(pullop.repo, phases.draft, subset)
439 else:
452 else:
440 # Remote is old or publishing all common changesets
453 # Remote is old or publishing all common changesets
441 # should be seen as public
454 # should be seen as public
442 phases.advanceboundary(repo, phases.public, subset)
455 phases.advanceboundary(pullop.repo, phases.public, subset)
443
456
444 def gettransaction():
457 def gettransaction():
445 if tr is None:
458 if tr is None:
446 return repo.transaction(trname)
459 return pullop.repo.transaction(trname)
447 return tr
460 return tr
448
461
449 obstr = obsolete.syncpull(repo, remote, gettransaction)
462 obstr = obsolete.syncpull(pullop.repo, remote, gettransaction)
450 if obstr is not None:
463 if obstr is not None:
451 tr = obstr
464 tr = obstr
452
465
General Comments 0
You need to be logged in to leave comments. Login now