Mercurial > hg
annotate hgext/amend.py @ 49777:e1953a34c110
bundle: emit full snapshot as is, without doing a redelta
With the new `forced` delta-reused policy, it become important to be able to
send full snapshot where full snapshot are needed. Otherwise, the fallback delta
will simply be used on the client sideā¦ creating monstrous delta chain, since
revision that are meant as a reset of delta-chain chain becoming too complex are
simply adding a new full delta-tree on the leaf of another one.
In the `non-forced` cases, client process full snapshot from the bundle
differently from deltas, so client will still try to convert the full snapshot
into a delta if possible. So this will no lead to pathological storage
explosion.
I have considered making this configurable, but the impact seems limited enough
that it does not seems to be worth it. Especially with the current
sparse-revlog format that use "delta-tree" with multiple level snapshots, full
snapshot are much less frequent and not that different from other intermediate
snapshot that we are already sending over the wire anyway.
CPU wise, this will help the bundling side a little as it will not need to
reconstruct revisions and compute deltas. The unbundling side might save a tiny
amount of CPU as it won't need to reconstruct the delta-base to reconstruct the
revision full text. This only slightly visible in some of the benchmarks. And
have no real impact on most of them.
### data-env-vars.name = pypy-2018-08-01-zstd-sparse-revlog
# benchmark.name = perf-bundle
# benchmark.variants.revs = last-40000
before: 11.467186 seconds
just-emit-full: 11.190576 seconds (-2.41%)
with-pull-force: 11.041091 seconds (-3.72%)
# benchmark.name = perf-unbundle
# benchmark.variants.revs = last-40000
before: 16.744862
just-emit-full:: 16.561036 seconds (-1.10%)
with-pull-force: 16.389344 seconds (-2.12%)
# benchmark.name = pull
# benchmark.variants.revs = last-40000
before: 26.870569
just-emit-full: 26.391188 seconds (-1.78%)
with-pull-force: 25.633184 seconds (-4.60%)
Space wise (so network-wise) the impact is fairly small. When taking compression into
account.
Below are tests the size of `hg bundle --all` for a handful of benchmark repositories
(with bzip, zstd compression and without it)
This show a small increase in the bundle size, but nothing really significant
except maybe for mozilla-try (+12%) that nobody really pulls large chunk of anyway.
Mozilla-try is also the repository that benefit the most for not having to
recompute deltas client size.
### mercurial:
bzip-before: 26 406 342 bytes
bzip-after: 26 691 543 bytes +1.08%
zstd-before: 27 918 645 bytes
zstd-after: 28 075 896 bytes +0.56%
none-before: 98 675 601 bytes
none-after: 100 411 237 bytes +1.76%
### pypy
bzip-before: 201 295 752 bytes
bzip-after: 209 780 282 bytes +4.21%
zstd-before: 202 974 795 bytes
zstd-after: 205 165 780 bytes +1.08%
none-before: 871 070 261 bytes
none-after: 993 595 057 bytes +14.07%
### netbeans
bzip-before: 601 314 330 bytes
bzip-after: 614 246 241 bytes +2.15%
zstd-before: 604 745 136 bytes
zstd-after: 615 497 705 bytes +1.78%
none-before: 3 338 238 571 bytes
none-after: 3 439 422 535 bytes +3.03%
### mozilla-central
bzip-before: 1 493 006 921 bytes
bzip-after: 1 549 650 570 bytes +3.79%
zstd-before: 1 481 910 102 bytes
zstd-after: 1 513 052 415 bytes +2.10%
none-before: 6 535 929 910 bytes
none-after: 7 010 191 342 bytes +7.26%
### mozilla-try
bzip-before: 6 583 425 999 bytes
bzip-after: 7 423 536 928 bytes +12.76%
zstd-before: 6 021 009 212 bytes
zstd-after: 6 674 922 420 bytes +10.86%
none-before: 22 954 739 558 bytes
none-after: 26 013 854 771 bytes +13.32%
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 07 Dec 2022 20:12:23 +0100 |
parents | e78a41686464 |
children | f4733654f144 |
rev | line source |
---|---|
33404
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
1 # amend.py - provide the amend command |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
2 # |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
3 # Copyright 2017 Facebook, Inc. |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
4 # |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
7 """provide the amend command (EXPERIMENTAL) |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
8 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
9 This extension provides an ``amend`` command that is similar to |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
10 ``commit --amend`` but does not prompt an editor. |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
11 """ |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
12 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
13 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
14 from mercurial.i18n import _ |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
15 from mercurial import ( |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
16 cmdutil, |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
17 commands, |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
18 registrar, |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
19 ) |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
20 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
21 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
22 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
23 # be specifying the version(s) of Mercurial they are tested with, or |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
24 # leave the attribute unspecified. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
25 testedwith = b'ships-with-hg-core' |
33404
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
26 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
27 cmdtable = {} |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
28 command = registrar.command(cmdtable) |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
29 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
30 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
31 @command( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
32 b'amend', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
33 [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
34 ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
35 b'A', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
36 b'addremove', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
37 None, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
38 _(b'mark new/missing files as added/removed before committing'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
39 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
40 (b'e', b'edit', None, _(b'invoke editor on commit messages')), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
41 (b'i', b'interactive', None, _(b'use interactive mode')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
42 ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
43 b'', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
44 b'close-branch', |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
45 None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
46 _(b'mark a branch as closed, hiding it from the branch list'), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
47 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
48 (b's', b'secret', None, _(b'use the secret phase for committing')), |
49772
e78a41686464
amend: add a --draft option to set phase to draft
Martin von Zweigbergk <martinvonz@google.com>
parents:
48875
diff
changeset
|
49 (b'', b'draft', None, _(b'use the draft phase for committing')), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
50 (b'n', b'note', b'', _(b'store a note on the amend')), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
51 ] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
52 + cmdutil.walkopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
53 + cmdutil.commitopts |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
54 + cmdutil.commitopts2 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
55 + cmdutil.commitopts3, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
56 _(b'[OPTION]... [FILE]...'), |
40293
c303d65d2e34
help: assigning categories to existing commands
rdamazio@google.com
parents:
34970
diff
changeset
|
57 helpcategory=command.CATEGORY_COMMITTING, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
58 inferrepo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42935
diff
changeset
|
59 ) |
33404
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
60 def amend(ui, repo, *pats, **opts): |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
61 """amend the working copy parent with all or specified outstanding changes |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
62 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
63 Similar to :hg:`commit --amend`, but reuse the commit message without |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
64 invoking editor, unless ``--edit`` was set. |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
65 |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
66 See :hg:`help commit` for more details. |
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
67 """ |
49772
e78a41686464
amend: add a --draft option to set phase to draft
Martin von Zweigbergk <martinvonz@google.com>
parents:
48875
diff
changeset
|
68 cmdutil.check_at_most_one_arg(opts, 'draft', 'secret') |
47428
54849b65dc5f
cmdutil: make checknotesize() work on str-keyed opts
Martin von Zweigbergk <martinvonz@google.com>
parents:
47427
diff
changeset
|
69 cmdutil.check_note_size(opts) |
42933
7e9997041781
amend: prevent '\n' in the note string
Matt Harbison <matt_harbison@yahoo.com>
parents:
42932
diff
changeset
|
70 |
33404
0d5afd360e9e
amend: new extension providing the amend command
Jun Wu <quark@fb.com>
parents:
diff
changeset
|
71 with repo.wlock(), repo.lock(): |
47427
6ce89165eaa0
amend: work mostly with str-type **opts for simplicity
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
72 if not opts.get('logfile'): |
6ce89165eaa0
amend: work mostly with str-type **opts for simplicity
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
73 opts['message'] = opts.get('message') or repo[b'.'].description() |
6ce89165eaa0
amend: work mostly with str-type **opts for simplicity
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
74 opts['amend'] = True |
6ce89165eaa0
amend: work mostly with str-type **opts for simplicity
Martin von Zweigbergk <martinvonz@google.com>
parents:
43077
diff
changeset
|
75 return commands._docommit(ui, repo, *pats, **opts) |