##// 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 391 self.heads = heads
392 392 # do we force pull?
393 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 415 def pull(repo, remote, heads=None, force=False):
396 416 pullop = pulloperation(repo, remote, heads, force)
@@ -402,10 +422,6 b' def pull(repo, remote, heads=None, force'
402 422 " %s") % (', '.join(sorted(missing)))
403 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 425 lock = pullop.repo.lock()
410 426 try:
411 427 tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
@@ -417,7 +433,10 b' def pull(repo, remote, heads=None, force'
417 433 pullop.repo.ui.status(_("no changes found\n"))
418 434 result = 0
419 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 440 if pullop.heads is None and list(common) == [nullid]:
422 441 pullop.repo.ui.status(_("requesting all changes\n"))
423 442 elif (pullop.heads is None
@@ -465,20 +484,11 b' def pull(repo, remote, heads=None, force'
465 484 # should be seen as public
466 485 phases.advanceboundary(pullop.repo, phases.public, subset)
467 486
468 def gettransaction():
469 if tr is None:
470 return pullop.repo.transaction(trname)
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()
487 _pullobsolete(pullop.repo, pullop.remote,
488 pullop.gettransaction)
489 pullop.closetransaction()
479 490 finally:
480 if tr is not None:
481 tr.release()
491 pullop.releasetransaction()
482 492 lock.release()
483 493
484 494 return result
General Comments 0
You need to be logged in to leave comments. Login now