##// END OF EJS Templates
pull: move transaction logic into the pull object...
Pierre-Yves David -
r20477:2607a21b default
parent child Browse files
Show More
@@ -391,6 +391,26 b' class pulloperation(object):'
391 self.heads = heads
391 self.heads = heads
392 # do we force pull?
392 # do we force pull?
393 self.force = force
393 self.force = force
394 # the name the pull transaction
395 self._trname = 'pull\n' + util.hidepassword(remote.url())
396 # hold the transaction once created
397 self._tr = None
398
399 def gettransaction(self):
400 """get appropriate pull transaction, creating it if needed"""
401 if self._tr is None:
402 self._tr = self.repo.transaction(self._trname)
403 return self._tr
404
405 def closetransaction(self):
406 """close transaction if created"""
407 if self._tr is not None:
408 self._tr.close()
409
410 def releasetransaction(self):
411 """release transaction if created"""
412 if self._tr is not None:
413 self._tr.release()
394
414
395 def pull(repo, remote, heads=None, force=False):
415 def pull(repo, remote, heads=None, force=False):
396 pullop = pulloperation(repo, remote, heads, force)
416 pullop = pulloperation(repo, remote, heads, force)
@@ -402,10 +422,6 b' def pull(repo, remote, heads=None, force'
402 " %s") % (', '.join(sorted(missing)))
422 " %s") % (', '.join(sorted(missing)))
403 raise util.Abort(msg)
423 raise util.Abort(msg)
404
424
405 # don't open transaction for nothing or you break future useful
406 # rollback call
407 tr = None
408 trname = 'pull\n' + util.hidepassword(pullop.remote.url())
409 lock = pullop.repo.lock()
425 lock = pullop.repo.lock()
410 try:
426 try:
411 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
427 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
@@ -417,7 +433,10 b' def pull(repo, remote, heads=None, force'
417 pullop.repo.ui.status(_("no changes found\n"))
433 pullop.repo.ui.status(_("no changes found\n"))
418 result = 0
434 result = 0
419 else:
435 else:
420 tr = pullop.repo.transaction(trname)
436 # We delay the open of the transaction as late as possible so we
437 # don't open transaction for nothing or you break future useful
438 # rollback call
439 pullop.gettransaction()
421 if pullop.heads is None and list(common) == [nullid]:
440 if pullop.heads is None and list(common) == [nullid]:
422 pullop.repo.ui.status(_("requesting all changes\n"))
441 pullop.repo.ui.status(_("requesting all changes\n"))
423 elif (pullop.heads is None
442 elif (pullop.heads is None
@@ -465,20 +484,11 b' def pull(repo, remote, heads=None, force'
465 # should be seen as public
484 # should be seen as public
466 phases.advanceboundary(pullop.repo, phases.public, subset)
485 phases.advanceboundary(pullop.repo, phases.public, subset)
467
486
468 def gettransaction():
487 _pullobsolete(pullop.repo, pullop.remote,
469 if tr is None:
488 pullop.gettransaction)
470 return pullop.repo.transaction(trname)
489 pullop.closetransaction()
471 return tr
472
473 obstr = _pullobsolete(pullop.repo, pullop.remote, gettransaction)
474 if obstr is not None:
475 tr = obstr
476
477 if tr is not None:
478 tr.close()
479 finally:
490 finally:
480 if tr is not None:
491 pullop.releasetransaction()
481 tr.release()
482 lock.release()
492 lock.release()
483
493
484 return result
494 return result
General Comments 0
You need to be logged in to leave comments. Login now