comparison mercurial/changegroup.py @ 42897:d7304434390f

changegroup: move message about added changes to transaction summary Before that, applying multiple changegroups in the same transaction issued the message multiple time. This result in a confusing output: adding changesets adding manifests adding file changes added 32768 changesets with 60829 changes to 2668 files adding changesets adding manifests adding file changes added 8192 changesets with 16885 changes to 1553 files adding changesets adding manifests adding file changes added 1020 changesets with 1799 changes to 536 files adding changesets adding manifests ... Instead, we now only issue the message once at the end of the transaction, summing up all added changesets, changes and files. The line is identical, but happens sightly later in the output. There are other suboptimal behavior around issue multiple changegroup (eg: progress bar). We'll cover them later. This impact of lot of test as one would expect, but a two pass check show they are just the order change we expected. To deal with "under the hood" bundle application by internal code, we had to take a slightly hacky move. We could clean that up with a more official way to enter "under the hood" section, however I want to keep this series simple to get it landed. This kind of change have a very high bit rot rate since it impact a lot of test output.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 08 Sep 2019 09:42:53 +0200
parents 268662aac075
children 4bbc9569e722
comparison
equal deleted inserted replaced
42896:7e19b640c53e 42897:d7304434390f
268 return len(cl) 268 return len(cl)
269 269
270 def revmap(x): 270 def revmap(x):
271 return cl.rev(x) 271 return cl.rev(x)
272 272
273 changesets = files = revisions = 0 273 changesets = 0
274 274
275 try: 275 try:
276 # The transaction may already carry source information. In this 276 # The transaction may already carry source information. In this
277 # case we use the top level data. We overwrite the argument 277 # case we use the top level data. We overwrite the argument
278 # because we need to use the top level value (if they exist) 278 # because we need to use the top level value (if they exist)
335 335
336 # process the files 336 # process the files
337 repo.ui.status(_("adding file changes\n")) 337 repo.ui.status(_("adding file changes\n"))
338 newrevs, newfiles = _addchangegroupfiles( 338 newrevs, newfiles = _addchangegroupfiles(
339 repo, self, revmap, trp, efiles, needfiles) 339 repo, self, revmap, trp, efiles, needfiles)
340 revisions += newrevs 340
341 files += newfiles 341 # making sure the value exists
342 tr.changes.setdefault('changegroup-count-changesets', 0)
343 tr.changes.setdefault('changegroup-count-revisions', 0)
344 tr.changes.setdefault('changegroup-count-files', 0)
345 tr.changes.setdefault('changegroup-count-heads', 0)
346
347 # some code use bundle operation for internal purpose. They usually
348 # set `ui.quiet` to do this outside of user sight. Size the report
349 # of such operation now happens at the end of the transaction, that
350 # ui.quiet has not direct effect on the output.
351 #
352 # To preserve this intend use an inelegant hack, we fail to report
353 # the change if `quiet` is set. We should probably move to
354 # something better, but this is a good first step to allow the "end
355 # of transaction report" to pass tests.
356 if not repo.ui.quiet:
357 tr.changes['changegroup-count-changesets'] += changesets
358 tr.changes['changegroup-count-revisions'] += newrevs
359 tr.changes['changegroup-count-files'] += newfiles
342 360
343 deltaheads = 0 361 deltaheads = 0
344 if oldheads: 362 if oldheads:
345 heads = cl.heads() 363 heads = cl.heads()
346 deltaheads = len(heads) - len(oldheads) 364 deltaheads += len(heads) - len(oldheads)
347 for h in heads: 365 for h in heads:
348 if h not in oldheads and repo[h].closesbranch(): 366 if h not in oldheads and repo[h].closesbranch():
349 deltaheads -= 1 367 deltaheads -= 1
350 htext = "" 368
351 if deltaheads: 369 # see previous comment about checking ui.quiet
352 htext = _(" (%+d heads)") % deltaheads 370 if not repo.ui.quiet:
353 371 tr.changes['changegroup-count-heads'] += deltaheads
354 repo.ui.status(_("added %d changesets"
355 " with %d changes to %d files%s\n")
356 % (changesets, revisions, files, htext))
357 repo.invalidatevolatilesets() 372 repo.invalidatevolatilesets()
358 373
359 if changesets > 0: 374 if changesets > 0:
360 if 'node' not in tr.hookargs: 375 if 'node' not in tr.hookargs:
361 tr.hookargs['node'] = hex(cl.node(clstart)) 376 tr.hookargs['node'] = hex(cl.node(clstart))