##// END OF EJS Templates
with: use context manager for transaction in changegroup apply...
Bryan O'Sullivan -
r27867:7ced54eb default
parent child Browse files
Show More
@@ -323,8 +323,9 b' class cg1unpacker(object):'
323
323
324 changesets = files = revisions = 0
324 changesets = files = revisions = 0
325
325
326 tr = repo.transaction("\n".join([srctype, util.hidepassword(url)]))
327 try:
326 try:
327 with repo.transaction("\n".join([srctype,
328 util.hidepassword(url)])) as tr:
328 # The transaction could have been created before and already
329 # The transaction could have been created before and already
329 # carries source information. In this case we use the top
330 # carries source information. In this case we use the top
330 # level data. We overwrite the argument because we need to use
331 # level data. We overwrite the argument because we need to use
@@ -349,8 +350,8 b' class cg1unpacker(object):'
349 self._total = total
350 self._total = total
350 self._count = 1
351 self._count = 1
351 def __call__(self):
352 def __call__(self):
352 repo.ui.progress(self._step, self._count, unit=_('chunks'),
353 repo.ui.progress(self._step, self._count,
353 total=self._total)
354 unit=_('chunks'), total=self._total)
354 self._count += 1
355 self._count += 1
355 self.callback = prog(_('changesets'), expectedtotal)
356 self.callback = prog(_('changesets'), expectedtotal)
356
357
@@ -377,7 +378,8 b' class cg1unpacker(object):'
377 if repo.ui.configbool('server', 'validate', default=False):
378 if repo.ui.configbool('server', 'validate', default=False):
378 # validate incoming csets have their manifests
379 # validate incoming csets have their manifests
379 for cset in xrange(clstart, clend):
380 for cset in xrange(clstart, clend):
380 mfnode = repo.changelog.read(repo.changelog.node(cset))[0]
381 mfnode = repo.changelog.read(
382 repo.changelog.node(cset))[0]
381 mfest = repo.manifest.readdelta(mfnode)
383 mfest = repo.manifest.readdelta(mfnode)
382 # store file nodes we must see
384 # store file nodes we must see
383 for f, n in mfest.iteritems():
385 for f, n in mfest.iteritems():
@@ -429,12 +431,15 b' class cg1unpacker(object):'
429 # We should not use added here but the list of all change in
431 # We should not use added here but the list of all change in
430 # the bundle
432 # the bundle
431 if publishing:
433 if publishing:
432 phases.advanceboundary(repo, tr, phases.public, srccontent)
434 phases.advanceboundary(repo, tr, phases.public,
435 srccontent)
433 else:
436 else:
434 # Those changesets have been pushed from the outside, their
437 # Those changesets have been pushed from the
435 # phases are going to be pushed alongside. Therefor
438 # outside, their phases are going to be pushed
436 # `targetphase` is ignored.
439 # alongside. Therefor `targetphase` is
437 phases.advanceboundary(repo, tr, phases.draft, srccontent)
440 # ignored.
441 phases.advanceboundary(repo, tr, phases.draft,
442 srccontent)
438 phases.retractboundary(repo, tr, phases.draft, added)
443 phases.retractboundary(repo, tr, phases.draft, added)
439 elif srctype != 'strip':
444 elif srctype != 'strip':
440 # publishing only alter behavior during push
445 # publishing only alter behavior during push
@@ -444,9 +449,10 b' class cg1unpacker(object):'
444
449
445 if changesets > 0:
450 if changesets > 0:
446 if srctype != 'strip':
451 if srctype != 'strip':
447 # During strip, branchcache is invalid but coming call to
452 # During strip, branchcache is invalid but
448 # `destroyed` will repair it.
453 # coming call to `destroyed` will repair it.
449 # In other case we can safely update cache on disk.
454 # In other case we can safely update cache on
455 # disk.
450 branchmap.updatecache(repo.filtered('served'))
456 branchmap.updatecache(repo.filtered('served'))
451
457
452 def runhooks():
458 def runhooks():
@@ -466,7 +472,8 b' class cg1unpacker(object):'
466 del args['node_last']
472 del args['node_last']
467 repo.hook("incoming", **args)
473 repo.hook("incoming", **args)
468
474
469 newheads = [h for h in repo.heads() if h not in oldheads]
475 newheads = [h for h in repo.heads()
476 if h not in oldheads]
470 repo.ui.log("incoming",
477 repo.ui.log("incoming",
471 "%s incoming changes - new heads: %s\n",
478 "%s incoming changes - new heads: %s\n",
472 len(added),
479 len(added),
@@ -474,11 +481,7 b' class cg1unpacker(object):'
474
481
475 tr.addpostclose('changegroup-runhooks-%020i' % clstart,
482 tr.addpostclose('changegroup-runhooks-%020i' % clstart,
476 lambda tr: repo._afterlock(runhooks))
483 lambda tr: repo._afterlock(runhooks))
477
478 tr.close()
479
480 finally:
484 finally:
481 tr.release()
482 repo.ui.flush()
485 repo.ui.flush()
483 # never return 0 here:
486 # never return 0 here:
484 if dh < 0:
487 if dh < 0:
General Comments 0
You need to be logged in to leave comments. Login now