##// END OF EJS Templates
changegroup: delete "if True" and reflow
Martin von Zweigbergk -
r32931:b08431e1 default
parent child Browse files
Show More
@@ -279,151 +279,149 b' class cg1unpacker(object):'
279 279 changesets = files = revisions = 0
280 280
281 281 try:
282 if True:
283 # The transaction may already carry source information. In this
284 # case we use the top level data. We overwrite the argument
285 # because we need to use the top level value (if they exist)
286 # in this function.
287 srctype = tr.hookargs.setdefault('source', srctype)
288 url = tr.hookargs.setdefault('url', url)
289 repo.hook('prechangegroup', throw=True, **tr.hookargs)
282 # The transaction may already carry source information. In this
283 # case we use the top level data. We overwrite the argument
284 # because we need to use the top level value (if they exist)
285 # in this function.
286 srctype = tr.hookargs.setdefault('source', srctype)
287 url = tr.hookargs.setdefault('url', url)
288 repo.hook('prechangegroup', throw=True, **tr.hookargs)
290 289
291 # write changelog data to temp files so concurrent readers
292 # will not see an inconsistent view
293 cl = repo.changelog
294 cl.delayupdate(tr)
295 oldheads = set(cl.heads())
290 # write changelog data to temp files so concurrent readers
291 # will not see an inconsistent view
292 cl = repo.changelog
293 cl.delayupdate(tr)
294 oldheads = set(cl.heads())
296 295
297 trp = weakref.proxy(tr)
298 # pull off the changeset group
299 repo.ui.status(_("adding changesets\n"))
300 clstart = len(cl)
301 class prog(object):
302 def __init__(self, step, total):
303 self._step = step
304 self._total = total
305 self._count = 1
306 def __call__(self):
307 repo.ui.progress(self._step, self._count,
308 unit=_('chunks'), total=self._total)
309 self._count += 1
310 self.callback = prog(_('changesets'), expectedtotal)
296 trp = weakref.proxy(tr)
297 # pull off the changeset group
298 repo.ui.status(_("adding changesets\n"))
299 clstart = len(cl)
300 class prog(object):
301 def __init__(self, step, total):
302 self._step = step
303 self._total = total
304 self._count = 1
305 def __call__(self):
306 repo.ui.progress(self._step, self._count, unit=_('chunks'),
307 total=self._total)
308 self._count += 1
309 self.callback = prog(_('changesets'), expectedtotal)
311 310
312 efiles = set()
313 def onchangelog(cl, node):
314 efiles.update(cl.readfiles(node))
311 efiles = set()
312 def onchangelog(cl, node):
313 efiles.update(cl.readfiles(node))
315 314
316 self.changelogheader()
317 cgnodes = cl.addgroup(self, csmap, trp,
318 addrevisioncb=onchangelog)
319 efiles = len(efiles)
315 self.changelogheader()
316 cgnodes = cl.addgroup(self, csmap, trp, addrevisioncb=onchangelog)
317 efiles = len(efiles)
320 318
321 if not (cgnodes or emptyok):
322 raise error.Abort(_("received changelog group is empty"))
323 clend = len(cl)
324 changesets = clend - clstart
325 repo.ui.progress(_('changesets'), None)
326 self.callback = None
319 if not (cgnodes or emptyok):
320 raise error.Abort(_("received changelog group is empty"))
321 clend = len(cl)
322 changesets = clend - clstart
323 repo.ui.progress(_('changesets'), None)
324 self.callback = None
327 325
328 # pull off the manifest group
329 repo.ui.status(_("adding manifests\n"))
330 self._unpackmanifests(repo, revmap, trp, prog, changesets)
326 # pull off the manifest group
327 repo.ui.status(_("adding manifests\n"))
328 self._unpackmanifests(repo, revmap, trp, prog, changesets)
331 329
332 needfiles = {}
333 if repo.ui.configbool('server', 'validate', default=False):
334 cl = repo.changelog
335 ml = repo.manifestlog
336 # validate incoming csets have their manifests
337 for cset in xrange(clstart, clend):
338 mfnode = cl.changelogrevision(cset).manifest
339 mfest = ml[mfnode].readdelta()
340 # store file cgnodes we must see
341 for f, n in mfest.iteritems():
342 needfiles.setdefault(f, set()).add(n)
330 needfiles = {}
331 if repo.ui.configbool('server', 'validate', default=False):
332 cl = repo.changelog
333 ml = repo.manifestlog
334 # validate incoming csets have their manifests
335 for cset in xrange(clstart, clend):
336 mfnode = cl.changelogrevision(cset).manifest
337 mfest = ml[mfnode].readdelta()
338 # store file cgnodes we must see
339 for f, n in mfest.iteritems():
340 needfiles.setdefault(f, set()).add(n)
343 341
344 # process the files
345 repo.ui.status(_("adding file changes\n"))
346 newrevs, newfiles = _addchangegroupfiles(
347 repo, self, revmap, trp, efiles, needfiles)
348 revisions += newrevs
349 files += newfiles
342 # process the files
343 repo.ui.status(_("adding file changes\n"))
344 newrevs, newfiles = _addchangegroupfiles(
345 repo, self, revmap, trp, efiles, needfiles)
346 revisions += newrevs
347 files += newfiles
350 348
351 deltaheads = 0
352 if oldheads:
353 heads = cl.heads()
354 deltaheads = len(heads) - len(oldheads)
355 for h in heads:
356 if h not in oldheads and repo[h].closesbranch():
357 deltaheads -= 1
358 htext = ""
359 if deltaheads:
360 htext = _(" (%+d heads)") % deltaheads
349 deltaheads = 0
350 if oldheads:
351 heads = cl.heads()
352 deltaheads = len(heads) - len(oldheads)
353 for h in heads:
354 if h not in oldheads and repo[h].closesbranch():
355 deltaheads -= 1
356 htext = ""
357 if deltaheads:
358 htext = _(" (%+d heads)") % deltaheads
361 359
362 repo.ui.status(_("added %d changesets"
363 " with %d changes to %d files%s\n")
364 % (changesets, revisions, files, htext))
365 repo.invalidatevolatilesets()
360 repo.ui.status(_("added %d changesets"
361 " with %d changes to %d files%s\n")
362 % (changesets, revisions, files, htext))
363 repo.invalidatevolatilesets()
366 364
367 if changesets > 0:
368 if 'node' not in tr.hookargs:
369 tr.hookargs['node'] = hex(cl.node(clstart))
370 tr.hookargs['node_last'] = hex(cl.node(clend - 1))
371 hookargs = dict(tr.hookargs)
372 else:
373 hookargs = dict(tr.hookargs)
374 hookargs['node'] = hex(cl.node(clstart))
375 hookargs['node_last'] = hex(cl.node(clend - 1))
376 repo.hook('pretxnchangegroup', throw=True, **hookargs)
365 if changesets > 0:
366 if 'node' not in tr.hookargs:
367 tr.hookargs['node'] = hex(cl.node(clstart))
368 tr.hookargs['node_last'] = hex(cl.node(clend - 1))
369 hookargs = dict(tr.hookargs)
370 else:
371 hookargs = dict(tr.hookargs)
372 hookargs['node'] = hex(cl.node(clstart))
373 hookargs['node_last'] = hex(cl.node(clend - 1))
374 repo.hook('pretxnchangegroup', throw=True, **hookargs)
377 375
378 added = [cl.node(r) for r in xrange(clstart, clend)]
379 if srctype in ('push', 'serve'):
380 # Old servers can not push the boundary themselves.
381 # New servers won't push the boundary if changeset already
382 # exists locally as secret
383 #
384 # We should not use added here but the list of all change in
385 # the bundle
386 if repo.publishing():
387 phases.advanceboundary(repo, tr, phases.public, cgnodes)
388 else:
389 # Those changesets have been pushed from the
390 # outside, their phases are going to be pushed
391 # alongside. Therefor `targetphase` is
392 # ignored.
393 phases.advanceboundary(repo, tr, phases.draft, cgnodes)
394 phases.retractboundary(repo, tr, phases.draft, added)
395 elif srctype != 'strip':
396 # publishing only alter behavior during push
397 #
398 # strip should not touch boundary at all
399 phases.retractboundary(repo, tr, targetphase, added)
376 added = [cl.node(r) for r in xrange(clstart, clend)]
377 if srctype in ('push', 'serve'):
378 # Old servers can not push the boundary themselves.
379 # New servers won't push the boundary if changeset already
380 # exists locally as secret
381 #
382 # We should not use added here but the list of all change in
383 # the bundle
384 if repo.publishing():
385 phases.advanceboundary(repo, tr, phases.public, cgnodes)
386 else:
387 # Those changesets have been pushed from the
388 # outside, their phases are going to be pushed
389 # alongside. Therefor `targetphase` is
390 # ignored.
391 phases.advanceboundary(repo, tr, phases.draft, cgnodes)
392 phases.retractboundary(repo, tr, phases.draft, added)
393 elif srctype != 'strip':
394 # publishing only alter behavior during push
395 #
396 # strip should not touch boundary at all
397 phases.retractboundary(repo, tr, targetphase, added)
400 398
401 if changesets > 0:
399 if changesets > 0:
402 400
403 def runhooks():
404 # These hooks run when the lock releases, not when the
405 # transaction closes. So it's possible for the changelog
406 # to have changed since we last saw it.
407 if clstart >= len(repo):
408 return
401 def runhooks():
402 # These hooks run when the lock releases, not when the
403 # transaction closes. So it's possible for the changelog
404 # to have changed since we last saw it.
405 if clstart >= len(repo):
406 return
409 407
410 repo.hook("changegroup", **hookargs)
408 repo.hook("changegroup", **hookargs)
411 409
412 for n in added:
413 args = hookargs.copy()
414 args['node'] = hex(n)
415 del args['node_last']
416 repo.hook("incoming", **args)
410 for n in added:
411 args = hookargs.copy()
412 args['node'] = hex(n)
413 del args['node_last']
414 repo.hook("incoming", **args)
417 415
418 newheads = [h for h in repo.heads()
419 if h not in oldheads]
420 repo.ui.log("incoming",
421 "%s incoming changes - new heads: %s\n",
422 len(added),
423 ', '.join([hex(c[:6]) for c in newheads]))
416 newheads = [h for h in repo.heads()
417 if h not in oldheads]
418 repo.ui.log("incoming",
419 "%s incoming changes - new heads: %s\n",
420 len(added),
421 ', '.join([hex(c[:6]) for c in newheads]))
424 422
425 tr.addpostclose('changegroup-runhooks-%020i' % clstart,
426 lambda tr: repo._afterlock(runhooks))
423 tr.addpostclose('changegroup-runhooks-%020i' % clstart,
424 lambda tr: repo._afterlock(runhooks))
427 425 finally:
428 426 repo.ui.flush()
429 427 # never return 0 here:
General Comments 0
You need to be logged in to leave comments. Login now