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