Mercurial > public > mercurial-scm > hg
comparison contrib/perf.py @ 49561:220738a53d05 stable
perf-unbundle: pre-indent the main block in per::unbundle
This makes the next changeset clearer.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 19 Oct 2022 01:54:04 +0200 |
parents | d513ae93dff3 |
children | 27bff60887fe |
comparison
equal
deleted
inserted
replaced
49560:5f778b3a94ca | 49561:220738a53d05 |
---|---|
2679 from mercurial import exchange | 2679 from mercurial import exchange |
2680 from mercurial import bundle2 | 2680 from mercurial import bundle2 |
2681 | 2681 |
2682 opts = _byteskwargs(opts) | 2682 opts = _byteskwargs(opts) |
2683 | 2683 |
2684 with repo.lock(): | 2684 if True: |
2685 bundle = [None, None] | 2685 with repo.lock(): |
2686 orig_quiet = repo.ui.quiet | 2686 bundle = [None, None] |
2687 try: | 2687 orig_quiet = repo.ui.quiet |
2688 repo.ui.quiet = True | 2688 try: |
2689 with open(fname, mode="rb") as f: | 2689 repo.ui.quiet = True |
2690 | 2690 with open(fname, mode="rb") as f: |
2691 def noop_report(*args, **kwargs): | 2691 |
2692 pass | 2692 def noop_report(*args, **kwargs): |
2693 | 2693 pass |
2694 def setup(): | 2694 |
2695 gen, tr = bundle | 2695 def setup(): |
2696 if tr is not None: | 2696 gen, tr = bundle |
2697 tr.abort() | 2697 if tr is not None: |
2698 bundle[:] = [None, None] | 2698 tr.abort() |
2699 f.seek(0) | 2699 bundle[:] = [None, None] |
2700 bundle[0] = exchange.readbundle(ui, f, fname) | 2700 f.seek(0) |
2701 bundle[1] = repo.transaction(b'perf::unbundle') | 2701 bundle[0] = exchange.readbundle(ui, f, fname) |
2702 bundle[1]._report = noop_report # silence the transaction | 2702 bundle[1] = repo.transaction(b'perf::unbundle') |
2703 | 2703 # silence the transaction |
2704 def apply(): | 2704 bundle[1]._report = noop_report |
2705 gen, tr = bundle | 2705 |
2706 bundle2.applybundle( | 2706 def apply(): |
2707 repo, | 2707 gen, tr = bundle |
2708 gen, | 2708 bundle2.applybundle( |
2709 tr, | 2709 repo, |
2710 source=b'perf::unbundle', | 2710 gen, |
2711 url=fname, | 2711 tr, |
2712 ) | 2712 source=b'perf::unbundle', |
2713 | 2713 url=fname, |
2714 timer, fm = gettimer(ui, opts) | 2714 ) |
2715 timer(apply, setup=setup) | 2715 |
2716 fm.end() | 2716 timer, fm = gettimer(ui, opts) |
2717 finally: | 2717 timer(apply, setup=setup) |
2718 repo.ui.quiet == orig_quiet | 2718 fm.end() |
2719 gen, tr = bundle | 2719 finally: |
2720 if tr is not None: | 2720 repo.ui.quiet == orig_quiet |
2721 tr.abort() | 2721 gen, tr = bundle |
2722 if tr is not None: | |
2723 tr.abort() | |
2722 | 2724 |
2723 | 2725 |
2724 @command( | 2726 @command( |
2725 b'perf::unidiff|perfunidiff', | 2727 b'perf::unidiff|perfunidiff', |
2726 revlogopts | 2728 revlogopts |