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