Mercurial > public > mercurial-scm > hg
view tests/test-commit-amend.t @ 45892:06b64fabf91c
copies: cache the ancestor checking call when tracing copy
A good share of the time spent in this function is spent doing ancestors
checking. To avoid spending time in duplicated call, we cache the result of
calls.
In the slower case, this provide a quite significant performance boost. Below
are the result for a set of selected pairs (many of them pathological):
(And further down is another table that summarize the current state of filelog
based vs changeset base copy tracing)
The benchmark have been configured to be killed after 6 minutes of runtime,
which mean that any detect slower than 2 minutes will be marked as "killed".
This drop some useful information about how much slower these case are? but also
prevent 99% of the benchmark time to be spent on case that can be labelled "very
slow" anyway.
Repo Case Source-Rev Dest-Rev Old-Time New-Time Difference Factor
------------------------------------------------------------------------------------------------------------------------------------
mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 0.000044 s, 0.000044 s, +0.000000 s, ? 1.0000
mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 0.000138 s, 0.000138 s, +0.000000 s, ? 1.0000
mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 0.005067 s, 0.005052 s, -0.000015 s, ? 0.9970
pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 0.000218 s, 0.000219 s, +0.000001 s, ? 1.0046
pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 0.000053 s, 0.000055 s, +0.000002 s, ? 1.0377
pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 0.000125 s, 0.000128 s, +0.000003 s, ? 1.0240
pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 0.001098 s, 0.001089 s, -0.000009 s, ? 0.9918
pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 0.017546 s, 0.017407 s, -0.000139 s, ? 0.9921
pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 0.096723 s, 0.094175 s, -0.002548 s, ? 0.9737
pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 0.271796 s, 0.238009 s, -0.033787 s, ? 0.8757
pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 0.128602 s, 0.125876 s, -0.002726 s, ? 0.9788
pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 7.086742 s, 3.581556 s, -3.505186 s, ? 0.5054
pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 0.016634 s, 0.016721 s, +0.000087 s, ? 1.0052
pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 0.254225 s, 0.242367 s, -0.011858 s, ? 0.9534
netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 0.000166 s, 0.000165 s, -0.000001 s, ? 0.9940
netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 0.000118 s, 0.000114 s, -0.000004 s, ? 0.9661
netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 0.000296 s, 0.000296 s, +0.000000 s, ? 1.0000
netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 0.001137 s, 0.001124 s, -0.000013 s, ? 0.9886
netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 0.014133 s, 0.013060 s, -0.001073 s, ? 0.9241
netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 0.016988 s, 0.017112 s, +0.000124 s, ? 1.0073
netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 0.676361 s, 0.660350 s, -0.016011 s, ? 0.9763
netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 12.515149 s, 10.032499 s, -2.482650 s, ? 0.8016
mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 0.000186 s, 0.000189 s, +0.000003 s, ? 1.0161
mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 0.000459 s, 0.000462 s, +0.000003 s, ? 1.0065
mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 0.000273 s, 0.000270 s, -0.000003 s, ? 0.9890
mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 0.001503 s, 0.001474 s, -0.000029 s, ? 0.9807
mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 0.004862 s, 0.004806 s, -0.000056 s, ? 0.9885
mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 0.088291 s, 0.085150 s, -0.003141 s, ? 0.9644
mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.007113 s, 0.007064 s, -0.000049 s, ? 0.9931
mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.004687 s, 0.004741 s, +0.000054 s, ? 1.0115
mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 0.198710 s, 0.190133 s, -0.008577 s, ? 0.9568
mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 0.036068 s, 0.035651 s, -0.000417 s, ? 0.9884
mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 0.465362 s, 0.440694 s, -0.024668 s, ? 0.9470
mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 24.519684 s, 18.454163 s, -6.065521 s, ? 0.7526
mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 42.711897 s, 31.562719 s, -11.149178 s, ? 0.7390
mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 0.001201 s, 0.001189 s, -0.000012 s, ? 0.9900
mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 0.001216 s, 0.001204 s, -0.000012 s, ? 0.9901
mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 0.000595 s, 0.000586 s, -0.000009 s, ? 0.9849
mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 0.001856 s, 0.001845 s, -0.000011 s, ? 0.9941
mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 0.064936 s, 0.063822 s, -0.001114 s, ? 0.9828
mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 0.090601 s, 0.088038 s, -0.002563 s, ? 0.9717
mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.007510 s, 0.007389 s, -0.000121 s, ? 0.9839
mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.004911 s, 0.004868 s, -0.000043 s, ? 0.9912
mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 0.233231 s, 0.222450 s, -0.010781 s, ? 0.9538
mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 0.419989 s, 0.370675 s, -0.049314 s, ? 0.8826
mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 0.401521 s, 0.358020 s, -0.043501 s, ? 0.8917
mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 0.179555 s, 0.145235 s, -0.034320 s, ? 0.8089
mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 0.038004 s, 0.037606 s, -0.000398 s, ? 0.9895
mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 52.838482 s, 7.382439 s, -45.456043 s, ? 0.1397
mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 8.705874 s, 7.273506 s, -1.432368 s, ? 0.8355
mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 1.126708 s, 1.074593 s, -0.052115 s, ? 0.9537
mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 83.854020 s, 27.746195 s, -56.107825 s, ? 0.3309
Below is a table comparing the runtime of the current "filelog centric"
algorithm, with the "changeset centric" one, we just modified.
The changeset centric algorithm is a significant win in many scenario, but they
are still various cases where it is quite slower. When many revision has to be
considered the cost of retrieving the copy information, creating new
dictionaries, merging dictionaries and checking if revision are ancestors of
each other can slow things down.
The rest of this series, will introduce a rust version of the copy tracing code
to deal with most of theses issues.
Repo Case Source-Rev Dest-Rev filelog sidedata Difference Factor
---------------------------------------------------------------------------------------------------------------------------------------
mercurial x_revs_x_added_0_copies ad6b123de1c7 39cfcef4f463 : 0.000914 s, 0.000044 s, - 0.000870 s, ? 0.048140
mercurial x_revs_x_added_x_copies 2b1c78674230 0c1d10351869 : 0.001812 s, 0.000138 s, - 0.001674 s, ? 0.076159
mercurial x000_revs_x000_added_x_copies 81f8ff2a9bf2 dd3267698d84 : 0.017954 s, 0.005052 s, - 0.012902 s, ? 0.281386
pypy x_revs_x_added_0_copies aed021ee8ae8 099ed31b181b : 0.001509 s, 0.000219 s, - 0.001290 s, ? 0.145129
pypy x_revs_x000_added_0_copies 4aa4e1f8e19a 359343b9ac0e : 0.206881 s, 0.000055 s, - 0.206826 s, ? 0.000266
pypy x_revs_x_added_x_copies ac52eb7bbbb0 72e022663155 : 0.016951 s, 0.000128 s, - 0.016823 s, ? 0.007551
pypy x_revs_x00_added_x_copies c3b14617fbd7 ace7255d9a26 : 0.019096 s, 0.001089 s, - 0.018007 s, ? 0.057028
pypy x_revs_x000_added_x000_copies df6f7a526b60 a83dc6a2d56f : 0.762506 s, 0.017407 s, - 0.745099 s, ? 0.022829
pypy x000_revs_xx00_added_0_copies 89a76aede314 2f22446ff07e : 1.179211 s, 0.094175 s, - 1.085036 s, ? 0.079863
pypy x000_revs_x000_added_x_copies 8a3b5bfd266e 2c68e87c3efe : 1.249058 s, 0.238009 s, - 1.011049 s, ? 0.190551
pypy x000_revs_x000_added_x000_copies 89a76aede314 7b3dda341c84 : 1.614107 s, 0.125876 s, - 1.488231 s, ? 0.077985
pypy x0000_revs_x_added_0_copies d1defd0dc478 c9cb1334cc78 : 0.001064 s, 3.581556 s, + 3.580492 s, ? 3366.124060
pypy x0000_revs_xx000_added_0_copies bf2c629d0071 4ffed77c095c : 1.061275 s, 0.016721 s, - 1.044554 s, ? 0.015756
pypy x0000_revs_xx000_added_x000_copies 08ea3258278e d9fa043f30c0 : 1.341119 s, 0.242367 s, - 1.098752 s, ? 0.180720
netbeans x_revs_x_added_0_copies fb0955ffcbcd a01e9239f9e7 : 0.027803 s, 0.000165 s, - 0.027638 s, ? 0.005935
netbeans x_revs_x000_added_0_copies 6f360122949f 20eb231cc7d0 : 0.130014 s, 0.000114 s, - 0.129900 s, ? 0.000877
netbeans x_revs_x_added_x_copies 1ada3faf6fb6 5a39d12eecf4 : 0.024990 s, 0.000296 s, - 0.024694 s, ? 0.011845
netbeans x_revs_x00_added_x_copies 35be93ba1e2c 9eec5e90c05f : 0.052201 s, 0.001124 s, - 0.051077 s, ? 0.021532
netbeans x000_revs_xx00_added_0_copies eac3045b4fdd 51d4ae7f1290 : 0.037642 s, 0.013060 s, - 0.024582 s, ? 0.346953
netbeans x000_revs_x000_added_x_copies e2063d266acd 6081d72689dc : 0.197086 s, 0.017112 s, - 0.179974 s, ? 0.086825
netbeans x000_revs_x000_added_x000_copies ff453e9fee32 411350406ec2 : 0.935148 s, 0.660350 s, - 0.274798 s, ? 0.706145
netbeans x0000_revs_xx000_added_x000_copies 588c2d1ced70 1aad62e59ddd : 3.920674 s, 10.032499 s, + 6.111825 s, ? 2.558871
mozilla-central x_revs_x_added_0_copies 3697f962bb7b 7015fcdd43a2 : 0.024232 s, 0.000189 s, - 0.024043 s, ? 0.007800
mozilla-central x_revs_x000_added_0_copies dd390860c6c9 40d0c5bed75d : 0.141483 s, 0.000462 s, - 0.141021 s, ? 0.003265
mozilla-central x_revs_x_added_x_copies 8d198483ae3b 14207ffc2b2f : 0.025775 s, 0.000270 s, - 0.025505 s, ? 0.010475
mozilla-central x_revs_x00_added_x_copies 98cbc58cc6bc 446a150332c3 : 0.084922 s, 0.001474 s, - 0.083448 s, ? 0.017357
mozilla-central x_revs_x000_added_x000_copies 3c684b4b8f68 0a5e72d1b479 : 0.194784 s, 0.004806 s, - 0.189978 s, ? 0.024673
mozilla-central x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 2.161103 s, 0.085150 s, - 2.075953 s, ? 0.039401
mozilla-central x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.089347 s, 0.007064 s, - 0.082283 s, ? 0.079063
mozilla-central x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.732171 s, 0.004741 s, - 0.727430 s, ? 0.006475
mozilla-central x000_revs_x000_added_x000_copies 7c97034feb78 4407bd0c6330 : 1.157287 s, 0.190133 s, - 0.967154 s, ? 0.164292
mozilla-central x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 6.726568 s, 0.035651 s, - 6.690917 s, ? 0.005300
mozilla-central x0000_revs_xx000_added_x000_copies f78c615a656c 96a38b690156 : 3.266229 s, 0.440694 s, - 2.825535 s, ? 0.134924
mozilla-central x00000_revs_x0000_added_x0000_copies 6832ae71433c 4c222a1d9a00 : 15.860534 s, 18.454163 s, + 2.593629 s, ? 1.163527
mozilla-central x00000_revs_x00000_added_x000_copies 76caed42cf7c 1daa622bbe42 : 20.450475 s, 31.562719 s, +11.112244 s, ? 1.543373
mozilla-try x_revs_x_added_0_copies aaf6dde0deb8 9790f499805a : 0.080442 s, 0.001189 s, - 0.079253 s, ? 0.014781
mozilla-try x_revs_x000_added_0_copies d8d0222927b4 5bb8ce8c7450 : 0.497672 s, 0.001204 s, - 0.496468 s, ? 0.002419
mozilla-try x_revs_x_added_x_copies 092fcca11bdb 936255a0384a : 0.021183 s, 0.000586 s, - 0.020597 s, ? 0.027664
mozilla-try x_revs_x00_added_x_copies b53d2fadbdb5 017afae788ec : 0.230991 s, 0.001845 s, - 0.229146 s, ? 0.007987
mozilla-try x_revs_x000_added_x000_copies 20408ad61ce5 6f0ee96e21ad : 1.118461 s, 0.063822 s, - 1.054639 s, ? 0.057062
mozilla-try x_revs_x0000_added_x0000_copies effb563bb7e5 c07a39dc4e80 : 2.206083 s, 0.088038 s, - 2.118045 s, ? 0.039907
mozilla-try x000_revs_xx00_added_0_copies 6100d773079a 04a55431795e : 0.089404 s, 0.007389 s, - 0.082015 s, ? 0.082647
mozilla-try x000_revs_x000_added_x_copies 9f17a6fc04f9 2d37b966abed : 0.733043 s, 0.004868 s, - 0.728175 s, ? 0.006641
mozilla-try x000_revs_x000_added_x000_copies 1346fd0130e4 4c65cbdabc1f : 1.163367 s, 0.222450 s, - 0.940917 s, ? 0.191212
mozilla-try x0000_revs_x_added_0_copies 63519bfd42ee a36a2a865d92 : 0.085456 s, 0.370675 s, + 0.285219 s, ? 4.337612
mozilla-try x0000_revs_x_added_x_copies 9fe69ff0762d bcabf2a78927 : 0.083601 s, 0.358020 s, + 0.274419 s, ? 4.282485
mozilla-try x0000_revs_xx000_added_x_copies 156f6e2674f2 4d0f2c178e66 : 7.366614 s, 0.145235 s, - 7.221379 s, ? 0.019715
mozilla-try x0000_revs_xx000_added_0_copies 9eec5917337d 67118cc6dcad : 6.664464 s, 0.037606 s, - 6.626858 s, ? 0.005643
mozilla-try x0000_revs_xx000_added_x000_copies 89294cd501d9 7ccb2fc7ccb5 : 7.467836 s, 7.382439 s, - 0.085397 s, ? 0.988565
mozilla-try x0000_revs_x0000_added_x0000_copies e928c65095ed e951f4ad123a : 9.801294 s, 7.273506 s, - 2.527788 s, ? 0.742097
mozilla-try x00000_revs_x_added_0_copies 6a320851d377 1ebb79acd503 : 0.091886 s, killed
mozilla-try x00000_revs_x00000_added_0_copies dc8a3ca7010e d16fde900c9c : 26.491140 s, 1.074593 s, -25.416547 s, ? 0.040564
mozilla-try x00000_revs_x_added_x_copies 5173c4b6f97c 95d83ee7242d : 0.092863 s, killed
mozilla-try x00000_revs_x000_added_x_copies 9126823d0e9c ca82787bb23c : 0.226823 s, killed
mozilla-try x00000_revs_x0000_added_x0000_copies 8d3fafa80d4b eb884023b810 : 18.914630 s, 27.746195 s, + 8.831565 s, ? 1.466917
mozilla-try x00000_revs_x00000_added_x0000_copies 1b661134e2ca 1ae03d022d6d : 21.198903 s, killed
mozilla-try x00000_revs_x00000_added_x000_copies 9b2a99adc05e 8e29777b48e6 : 24.952268 s, killed
Differential Revision: https://phab.mercurial-scm.org/D9296
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 02 Nov 2020 11:03:56 +0100 |
parents | b4694ef45db5 |
children | fa87536d3d70 |
line wrap: on
line source
$ hg init Setup: $ echo a >> a $ hg ci -Am 'base' adding a Refuse to amend public csets: $ hg phase -r . -p $ hg ci --amend abort: cannot amend public changesets (see 'hg help phases' for details) [10] $ hg phase -r . -f -d $ echo a >> a $ hg ci -Am 'base1' Nothing to amend: $ hg ci --amend -m 'base1' nothing changed [1] $ cat >> $HGRCPATH <<EOF > [hooks] > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE" > EOF Amending changeset with changes in working dir: (and check that --message does not trigger an editor) $ echo a >> a $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1' pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149 43f1ba15f28a tip saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-5ab4f721-amend.hg $ echo 'pretxncommit.foo = ' >> $HGRCPATH $ hg diff -c . diff -r ad120869acf0 -r 43f1ba15f28a a --- a/a Thu Jan 01 00:00:00 1970 +0000 +++ b/a Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +1,3 @@ a +a +a $ hg log changeset: 1:43f1ba15f28a tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: amend base1 changeset: 0:ad120869acf0 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: base Check proper abort for empty message $ cat > editor.sh << '__EOF__' > #!/bin/sh > echo "" > "$1" > __EOF__ Update the existing file to ensure that the dirstate is not in pending state (where the status of some files in the working copy is not known yet). This in turn ensures that when the transaction is aborted due to an empty message during the amend, there should be no rollback. $ echo a >> a $ echo b > b $ hg add b $ hg summary parent: 1:43f1ba15f28a tip amend base1 branch: default commit: 1 modified, 1 added, 1 unknown update: (current) phases: 2 draft $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend abort: empty commit message [10] $ hg summary parent: 1:43f1ba15f28a tip amend base1 branch: default commit: 1 modified, 1 added, 1 unknown update: (current) phases: 2 draft Add new file along with modified existing file: $ hg ci --amend -m 'amend base1 new file' saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-007467c2-amend.hg Remove file that was added in amended commit: (and test logfile option) (and test that logfile option do not trigger an editor) $ hg rm b $ echo 'amend base1 remove new file' > ../logfile $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile saved backup bundle to $TESTTMP/.hg/strip-backup/c16295aaf401-1ada9901-amend.hg $ hg cat b b: no such file in rev 47343646fa3d [1] No changes, just a different message: $ hg ci -v --amend -m 'no changes, new message' amending changeset 47343646fa3d copying changeset 47343646fa3d to ad120869acf0 committing files: a committing manifest committing changelog 1 changesets found uncompressed size of bundle content: 254 (changelog) 163 (manifests) 131 a saved backup bundle to $TESTTMP/.hg/strip-backup/47343646fa3d-c2758885-amend.hg 1 changesets found uncompressed size of bundle content: 250 (changelog) 163 (manifests) 131 a adding branch adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files committed changeset 1:401431e913a1 $ hg diff -c . diff -r ad120869acf0 -r 401431e913a1 a --- a/a Thu Jan 01 00:00:00 1970 +0000 +++ b/a Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +1,4 @@ a +a +a +a $ hg log changeset: 1:401431e913a1 tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: no changes, new message changeset: 0:ad120869acf0 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: base Disable default date on commit so when -d isn't given, the old date is preserved: $ echo '[defaults]' >> $HGRCPATH $ echo 'commit=' >> $HGRCPATH Test -u/-d: $ cat > .hg/checkeditform.sh <<EOF > env | grep HGEDITFORM > true > EOF $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0' HGEDITFORM=commit.amend.normal saved backup bundle to $TESTTMP/.hg/strip-backup/401431e913a1-5e8e532c-amend.hg $ echo a >> a $ hg ci --amend -u foo -d '1 0' saved backup bundle to $TESTTMP/.hg/strip-backup/d96b1d28ae33-677e0afb-amend.hg $ hg log -r . changeset: 1:a9a13940fc03 tag: tip user: foo date: Thu Jan 01 00:00:01 1970 +0000 summary: no changes, new message Open editor with old commit message if a message isn't given otherwise: $ cat > editor.sh << '__EOF__' > #!/bin/sh > cat $1 > echo "another precious commit message" > "$1" > __EOF__ at first, test saving last-message.txt $ cat > .hg/hgrc << '__EOF__' > [hooks] > pretxncommit.test-saving-last-message = false > __EOF__ $ rm -f .hg/last-message.txt $ hg commit --amend -v -m "message given from command line" amending changeset a9a13940fc03 copying changeset a9a13940fc03 to ad120869acf0 committing files: a committing manifest committing changelog running hook pretxncommit.test-saving-last-message: false transaction abort! rollback completed abort: pretxncommit.test-saving-last-message hook exited with status 1 [255] $ cat .hg/last-message.txt message given from command line (no-eol) $ rm -f .hg/last-message.txt $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v amending changeset a9a13940fc03 copying changeset a9a13940fc03 to ad120869acf0 no changes, new message HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: foo HG: branch 'default' HG: changed a committing files: a committing manifest committing changelog running hook pretxncommit.test-saving-last-message: false transaction abort! rollback completed abort: pretxncommit.test-saving-last-message hook exited with status 1 [255] $ cat .hg/last-message.txt another precious commit message $ cat > .hg/hgrc << '__EOF__' > [hooks] > pretxncommit.test-saving-last-message = > __EOF__ then, test editing custom commit message $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v amending changeset a9a13940fc03 copying changeset a9a13940fc03 to ad120869acf0 no changes, new message HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: foo HG: branch 'default' HG: changed a committing files: a committing manifest committing changelog 1 changesets found uncompressed size of bundle content: 249 (changelog) 163 (manifests) 133 a saved backup bundle to $TESTTMP/.hg/strip-backup/a9a13940fc03-7c2e8674-amend.hg 1 changesets found uncompressed size of bundle content: 257 (changelog) 163 (manifests) 133 a adding branch adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files committed changeset 1:64a124ba1b44 Same, but with changes in working dir (different code path): $ echo a >> a $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v amending changeset 64a124ba1b44 another precious commit message HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: foo HG: branch 'default' HG: changed a committing files: a committing manifest committing changelog 1 changesets found uncompressed size of bundle content: 257 (changelog) 163 (manifests) 133 a saved backup bundle to $TESTTMP/.hg/strip-backup/64a124ba1b44-10374b8f-amend.hg 1 changesets found uncompressed size of bundle content: 257 (changelog) 163 (manifests) 135 a adding branch adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files committed changeset 1:7892795b8e38 $ rm editor.sh $ hg log -r . changeset: 1:7892795b8e38 tag: tip user: foo date: Thu Jan 01 00:00:01 1970 +0000 summary: another precious commit message Moving bookmarks, preserve active bookmark: $ hg book book1 $ hg book book2 $ hg ci --amend -m 'move bookmarks' saved backup bundle to $TESTTMP/.hg/strip-backup/7892795b8e38-3fb46217-amend.hg $ hg book book1 1:8311f17e2616 * book2 1:8311f17e2616 $ echo a >> a $ hg ci --amend -m 'move bookmarks' saved backup bundle to $TESTTMP/.hg/strip-backup/8311f17e2616-f0504fe3-amend.hg $ hg book book1 1:a3b65065808c * book2 1:a3b65065808c abort does not loose bookmarks $ cat > editor.sh << '__EOF__' > #!/bin/sh > echo "" > "$1" > __EOF__ $ echo a >> a $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend abort: empty commit message [10] $ hg book book1 1:a3b65065808c * book2 1:a3b65065808c $ hg revert -Caq $ rm editor.sh $ echo '[defaults]' >> $HGRCPATH $ echo "commit=-d '0 0'" >> $HGRCPATH Moving branches: $ hg branch foo marked working directory as branch foo (branches are permanent and global, did you want a bookmark?) $ echo a >> a $ hg ci -m 'branch foo' $ hg branch default -f marked working directory as branch default $ hg ci --amend -m 'back to default' saved backup bundle to $TESTTMP/.hg/strip-backup/f8339a38efe1-c18453c9-amend.hg $ hg branches default 2:9c07515f2650 Close branch: $ hg up -q 0 $ echo b >> b $ hg branch foo marked working directory as branch foo (branches are permanent and global, did you want a bookmark?) $ hg ci -Am 'fork' adding b $ echo b >> b $ hg ci -mb $ hg ci --amend --close-branch -m 'closing branch foo' saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-54245dc7-amend.hg Same thing, different code path: $ echo b >> b $ hg ci -m 'reopen branch' reopening closed branch head 4 $ echo b >> b $ hg ci --amend --close-branch saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-b900d9fa-amend.hg $ hg branches default 2:9c07515f2650 Refuse to amend during a merge: $ hg up -q default $ hg merge foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg ci --amend abort: cannot amend while merging [20] $ hg ci -m 'merge' Refuse to amend if there is a merge conflict (issue5805): $ hg up -q foo $ echo c > a $ hg up default -t :fail 0 files updated, 0 files merged, 0 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges [1] $ hg resolve -l U a $ hg ci --amend abort: unresolved merge conflicts (see 'hg help resolve') [255] $ hg up -qC . Follow copies/renames: $ hg mv b c $ hg ci -m 'b -> c' $ hg mv c d $ hg ci --amend -m 'b -> d' saved backup bundle to $TESTTMP/.hg/strip-backup/42f3f27a067d-f23cc9f7-amend.hg $ hg st --rev '.^' --copies d A d b $ hg cp d e $ hg ci -m 'e = d' $ hg cp e f $ hg ci --amend -m 'f = d' saved backup bundle to $TESTTMP/.hg/strip-backup/9198f73182d5-251d584a-amend.hg $ hg st --rev '.^' --copies f A f d $ mv f f.orig $ hg rm -A f $ hg ci -m removef $ hg cp a f $ mv f.orig f $ hg ci --amend -m replacef saved backup bundle to $TESTTMP/.hg/strip-backup/f0993ab6b482-eda301bf-amend.hg $ hg st --change . --copies $ hg log -r . --template "{file_copies}\n" Move added file (issue3410): $ echo g >> g $ hg ci -Am g adding g $ hg mv g h $ hg ci --amend saved backup bundle to $TESTTMP/.hg/strip-backup/58585e3f095c-0f5ebcda-amend.hg $ hg st --change . --copies h A h $ hg log -r . --template "{file_copies}\n" Can't rollback an amend: $ hg rollback no rollback information available [1] Preserve extra dict (issue3430): $ hg branch a marked working directory as branch a (branches are permanent and global, did you want a bookmark?) $ echo a >> a $ hg ci -ma $ hg ci --amend -m "a'" saved backup bundle to $TESTTMP/.hg/strip-backup/39a162f1d65e-9dfe13d8-amend.hg $ hg log -r . --template "{branch}\n" a $ hg ci --amend -m "a''" saved backup bundle to $TESTTMP/.hg/strip-backup/d5ca7b1ac72b-0b4c1a34-amend.hg $ hg log -r . --template "{branch}\n" a Also preserve other entries in the dict that are in the old commit, first graft something so there's an additional entry: $ hg up 0 -q $ echo z > z $ hg ci -Am 'fork' adding z created new head $ hg up 11 5 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg graft 12 grafting 12:2647734878ef "fork" (tip) $ hg ci --amend -m 'graft amend' saved backup bundle to $TESTTMP/.hg/strip-backup/fe8c6f7957ca-25638666-amend.hg $ hg log -r . --debug | grep extra extra: amend_source=fe8c6f7957ca1665ed77496ed7a07657d469ac60 extra: branch=a extra: source=2647734878ef0236dda712fae9c1651cf694ea8a Preserve phase $ hg phase '.^::.' 11: draft 13: draft $ hg phase --secret --force . $ hg phase '.^::.' 11: draft 13: secret $ hg commit --amend -m 'amend for phase' -q $ hg phase '.^::.' 11: draft 13: secret Test amend with obsolete --------------------------- Enable obsolete $ cat >> $HGRCPATH << EOF > [experimental] > evolution.createmarkers=True > evolution.allowunstable=True > EOF Amend with no files changes $ hg id -n 13 $ hg ci --amend -m 'babar' $ hg id -n 14 $ hg log -Gl 3 --style=compact @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test | babar | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | | fork | ~ o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test | a'' ~ $ hg log -Gl 4 --hidden --style=compact @ 14[tip]:11 682950e85999 1970-01-01 00:00 +0000 test | babar | | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |/ amend for phase | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | | fork | ~ o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test | a'' ~ Amend with files changes (note: the extra commit over 15 is a temporary junk I would be happy to get ride of) $ echo 'babar' >> a $ hg commit --amend $ hg log -Gl 6 --hidden --style=compact @ 15[tip]:11 a5b42b49b0d5 1970-01-01 00:00 +0000 test | babar | | x 14:11 682950e85999 1970-01-01 00:00 +0000 test |/ babar | | x 13:11 5167600b0f7a 1970-01-01 00:00 +0000 test |/ amend for phase | | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test | | fork | ~ o 11 0ddb275cfad1 1970-01-01 00:00 +0000 test | a'' | o 10 5fa75032e226 1970-01-01 00:00 +0000 test | g ~ Test that amend does not make it easy to create obsolescence cycle --------------------------------------------------------------------- $ hg id -r 14 --hidden 682950e85999 (a) $ hg revert -ar 14 --hidden reverting a $ hg commit --amend $ hg id 37973c7e0b61 (a) tip Test that rewriting leaving instability behind is allowed --------------------------------------------------------------------- $ hg up '.^' 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo 'b' >> a $ hg log --style compact -r 'children(.)' 16[tip]:11 37973c7e0b61 1970-01-01 00:00 +0000 test babar $ hg commit --amend 1 new orphan changesets $ hg log -r 'orphan()' changeset: 16:37973c7e0b61 branch: a parent: 11:0ddb275cfad1 user: test date: Thu Jan 01 00:00:00 1970 +0000 instability: orphan summary: babar Amend a merge changeset (with renames and conflicts from the second parent): $ hg up -q default $ hg branch -q bar $ hg cp a aa $ hg mv z zz $ echo cc > cc $ hg add cc $ hg ci -m aazzcc $ hg up -q default $ echo a >> a $ echo dd > cc $ hg add cc $ hg ci -m aa $ hg merge -q bar warning: conflicts while merging cc! (edit, then use 'hg resolve --mark') [1] $ hg resolve -m cc (no more unresolved files) $ hg ci -m 'merge bar' $ hg log --config diff.git=1 -pr . changeset: 20:5aba7f3726e6 tag: tip parent: 19:30d96aeaf27b parent: 18:1aa437659d19 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar diff --git a/a b/aa copy from a copy to aa diff --git a/cc b/cc --- a/cc +++ b/cc @@ -1,1 +1,5 @@ +<<<<<<< working copy: 30d96aeaf27b - test: aa dd +======= +cc +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc diff --git a/z b/zz rename from z rename to zz $ hg debugrename aa aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e $ hg debugrename zz zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a $ hg debugrename cc cc not renamed $ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -m 'merge bar (amend message)' --edit HGEDITFORM=commit.amend.merge $ hg log --config diff.git=1 -pr . changeset: 21:4b0631ef043e tag: tip parent: 19:30d96aeaf27b parent: 18:1aa437659d19 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar (amend message) diff --git a/a b/aa copy from a copy to aa diff --git a/cc b/cc --- a/cc +++ b/cc @@ -1,1 +1,5 @@ +<<<<<<< working copy: 30d96aeaf27b - test: aa dd +======= +cc +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc diff --git a/z b/zz rename from z rename to zz $ hg debugrename aa aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e $ hg debugrename zz zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a $ hg debugrename cc cc not renamed $ hg mv zz z $ hg ci --amend -m 'merge bar (undo rename)' $ hg log --config diff.git=1 -pr . changeset: 22:06423be42d60 tag: tip parent: 19:30d96aeaf27b parent: 18:1aa437659d19 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar (undo rename) diff --git a/a b/aa copy from a copy to aa diff --git a/cc b/cc --- a/cc +++ b/cc @@ -1,1 +1,5 @@ +<<<<<<< working copy: 30d96aeaf27b - test: aa dd +======= +cc +>>>>>>> merge rev: 1aa437659d19 bar - test: aazzcc $ hg debugrename z z not renamed Amend a merge changeset (with renames during the merge): $ hg up -q bar $ echo x > x $ hg add x $ hg ci -m x $ hg up -q default $ hg merge -q bar $ hg mv aa aaa $ echo aa >> aaa $ hg ci -m 'merge bar again' $ hg log --config diff.git=1 -pr . changeset: 24:a89974a20457 tag: tip parent: 22:06423be42d60 parent: 23:4c94d5bc65f5 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar again diff --git a/aa b/aa deleted file mode 100644 --- a/aa +++ /dev/null @@ -1,2 +0,0 @@ -a -a diff --git a/aaa b/aaa new file mode 100644 --- /dev/null +++ b/aaa @@ -0,0 +1,3 @@ +a +a +aa diff --git a/x b/x new file mode 100644 --- /dev/null +++ b/x @@ -0,0 +1,1 @@ +x $ hg debugrename aaa aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980 Update to p1 with 'aaa' modified. 'aaa' was renamed from 'aa' in p2. 'aa' exists in p1 too, but it was recorded as copied from p2. $ echo modified >> aaa $ hg co -m '.^' -t :merge3 file 'aaa' was deleted in other [destination] but was modified in local [working copy]. You can use (c)hanged version, (d)elete, or leave (u)nresolved. What do you want to do? u 1 files updated, 0 files merged, 1 files removed, 1 files unresolved use 'hg resolve' to retry unresolved file merges [1] $ hg co -C tip 2 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg mv aaa aa $ hg ci --amend -m 'merge bar again (undo rename)' $ hg log --config diff.git=1 -pr . changeset: 25:282080768800 tag: tip parent: 22:06423be42d60 parent: 23:4c94d5bc65f5 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar again (undo rename) diff --git a/aa b/aa --- a/aa +++ b/aa @@ -1,2 +1,3 @@ a a +aa diff --git a/x b/x new file mode 100644 --- /dev/null +++ b/x @@ -0,0 +1,1 @@ +x $ hg debugrename aa aa not renamed $ hg debugrename -r '.^' aa aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e Amend a merge changeset (with manifest-level conflicts): $ hg up -q bar $ hg rm aa $ hg ci -m 'rm aa' $ hg up -q default $ echo aa >> aa $ hg ci -m aa $ hg merge -q bar --config ui.interactive=True << EOF > c > EOF file 'aa' was deleted in other [merge rev] but was modified in local [working copy]. You can use (c)hanged version, (d)elete, or leave (u)nresolved. What do you want to do? c $ hg ci -m 'merge bar (with conflicts)' $ hg log --config diff.git=1 -pr . changeset: 28:ed15db12298d tag: tip parent: 27:eb5adec0b43b parent: 26:67db8847a540 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar (with conflicts) $ hg rm aa $ hg ci --amend -m 'merge bar (with conflicts, amended)' $ hg log --config diff.git=1 -pr . changeset: 29:0eeafd043f63 tag: tip parent: 27:eb5adec0b43b parent: 26:67db8847a540 user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: merge bar (with conflicts, amended) diff --git a/aa b/aa deleted file mode 100644 --- a/aa +++ /dev/null @@ -1,4 +0,0 @@ -a -a -aa -aa Issue 3445: amending with --close-branch a commit that created a new head should fail This shouldn't be possible: $ hg up -q default $ hg branch closewithamend marked working directory as branch closewithamend $ echo foo > foo $ hg add foo $ hg ci -m.. $ hg ci --amend --close-branch -m 'closing' abort: can only close branch heads [10] This silliness fails: $ hg branch silliness marked working directory as branch silliness $ echo b >> b $ hg ci --close-branch -m'open and close' abort: branch "silliness" has no heads to close [10] Test that amend with --secret creates new secret changeset forcibly --------------------------------------------------------------------- $ hg phase '.^::.' 29: draft 30: draft $ hg commit --amend --secret -m 'amend as secret' -q $ hg phase '.^::.' 29: draft 31: secret Test that amend with --edit invokes editor forcibly --------------------------------------------------- $ hg parents --template "{desc}\n" amend as secret $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed" $ hg parents --template "{desc}\n" editor should be suppressed $ hg status --rev '.^1::.' A foo $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit editor should be invoked HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: test HG: branch 'silliness' HG: added foo $ hg parents --template "{desc}\n" editor should be invoked Test that amend with --no-edit avoids the editor ------------------------------------------------ $ hg commit --amend -m "before anything happens" $ hg parents --template "{desc}\n" before anything happens $ HGEDITOR=cat hg commit --amend --no-edit -m "editor should be suppressed" $ hg parents --template "{desc}\n" editor should be suppressed (We need a file change here since we won't have a message change) $ cp foo foo.orig $ echo hi >> foo $ HGEDITOR=cat hg commit --amend --no-edit $ hg parents --template "{desc}\n" editor should be suppressed $ hg status -mar (Let's undo adding that "hi" so later tests don't need to be adjusted) $ mv foo.orig foo $ hg commit --amend --no-edit Test that "diff()" in committemplate works correctly for amending ----------------------------------------------------------------- $ cat >> .hg/hgrc <<EOF > [committemplate] > changeset.commit.amend = {desc}\n > HG: M: {file_mods} > HG: A: {file_adds} > HG: R: {file_dels} > {splitlines(diff()) % 'HG: {line}\n'} > EOF $ hg parents --template "M: {file_mods}\nA: {file_adds}\nR: {file_dels}\n" M: A: foo R: $ hg status -amr $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo" expecting diff of foo HG: M: HG: A: foo HG: R: HG: diff -r 0eeafd043f63 foo HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +foo $ echo y > y $ hg add y $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of foo and y" expecting diff of foo and y HG: M: HG: A: foo y HG: R: HG: diff -r 0eeafd043f63 foo HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +foo HG: diff -r 0eeafd043f63 y HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +y $ hg rm a $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo and y" expecting diff of a, foo and y HG: M: HG: A: foo y HG: R: a HG: diff -r 0eeafd043f63 a HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,2 +0,0 @@ HG: -a HG: -a HG: diff -r 0eeafd043f63 foo HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +foo HG: diff -r 0eeafd043f63 y HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +y $ hg rm x $ HGEDITOR=cat hg commit --amend -e -m "expecting diff of a, foo, x and y" expecting diff of a, foo, x and y HG: M: HG: A: foo y HG: R: a x HG: diff -r 0eeafd043f63 a HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,2 +0,0 @@ HG: -a HG: -a HG: diff -r 0eeafd043f63 foo HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +foo HG: diff -r 0eeafd043f63 x HG: --- a/x Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,1 +0,0 @@ HG: -x HG: diff -r 0eeafd043f63 y HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +y $ echo cccc >> cc $ hg status -amr M cc $ HGEDITOR=cat hg commit --amend -e -m "cc should be excluded" -X cc cc should be excluded HG: M: HG: A: foo y HG: R: a x HG: diff -r 0eeafd043f63 a HG: --- a/a Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,2 +0,0 @@ HG: -a HG: -a HG: diff -r 0eeafd043f63 foo HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/foo Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +foo HG: diff -r 0eeafd043f63 x HG: --- a/x Thu Jan 01 00:00:00 1970 +0000 HG: +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: @@ -1,1 +0,0 @@ HG: -x HG: diff -r 0eeafd043f63 y HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000 HG: +++ b/y Thu Jan 01 00:00:00 1970 +0000 HG: @@ -0,0 +1,1 @@ HG: +y Check for issue4405 ------------------- Setup the repo with a file that gets moved in a second commit. $ hg init repo $ cd repo $ touch a0 $ hg add a0 $ hg commit -m a0 $ hg mv a0 a1 $ hg commit -m a1 $ hg up -q 0 $ hg log -G --template '{rev} {desc}' o 1 a1 | @ 0 a0 Now we branch the repro, but re-use the file contents, so we have a divergence in the file revlog topology and the changelog topology. $ hg revert --rev 1 --all removing a0 adding a1 $ hg ci -qm 'a1-amend' $ hg log -G --template '{rev} {desc}' @ 2 a1-amend | | o 1 a1 |/ o 0 a0 The way mercurial does amends is by folding the working copy and old commit together into another commit (rev 3). During this process, _findlimit is called to check how far back to look for the transitive closure of file copy information, but due to the divergence of the filelog and changelog graph topologies, before _findlimit was fixed, it returned a rev which was not far enough back in this case. $ hg mv a1 a2 $ hg status --copies --rev 0 A a2 a0 R a0 $ hg ci --amend -q $ hg log -G --template '{rev} {desc}' @ 3 a1-amend | | o 1 a1 |/ o 0 a0 Before the fix, the copy information was lost. $ hg status --copies --rev 0 A a2 a0 R a0 $ cd .. Check that amend properly preserve rename from directory rename (issue-4516) If a parent of the merge renames a full directory, any files added to the old directory in the other parent will be renamed to the new directory. For some reason, the rename metadata was when amending such merge. This test ensure we do not regress. We have a dedicated repo because it needs a setup with renamed directory) $ hg init issue4516 $ cd issue4516 $ mkdir olddirname $ echo line1 > olddirname/commonfile.py $ hg add olddirname/commonfile.py $ hg ci -m first $ hg branch newdirname marked working directory as branch newdirname (branches are permanent and global, did you want a bookmark?) $ hg mv olddirname newdirname moving olddirname/commonfile.py to newdirname/commonfile.py $ hg ci -m rename $ hg update default 1 files updated, 0 files merged, 1 files removed, 0 files unresolved $ echo line1 > olddirname/newfile.py $ hg add olddirname/newfile.py $ hg ci -m log $ hg up newdirname 1 files updated, 0 files merged, 2 files removed, 0 files unresolved $ # create newdirname/newfile.py $ hg merge default 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) $ hg ci -m add $ $ hg debugrename newdirname/newfile.py newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def $ hg status -C --change . A newdirname/newfile.py $ hg status -C --rev 1 A newdirname/newfile.py $ hg status -C --rev 2 A newdirname/commonfile.py olddirname/commonfile.py A newdirname/newfile.py olddirname/newfile.py R olddirname/commonfile.py R olddirname/newfile.py $ hg debugindex newdirname/newfile.py rev linkrev nodeid p1 p2 0 3 34a4d536c0c0 000000000000 000000000000 $ echo a >> newdirname/commonfile.py $ hg ci --amend -m bug $ hg debugrename newdirname/newfile.py newdirname/newfile.py renamed from olddirname/newfile.py:690b295714aed510803d3020da9c70fca8336def $ hg debugindex newdirname/newfile.py rev linkrev nodeid p1 p2 0 3 34a4d536c0c0 000000000000 000000000000 #if execbit Test if amend preserves executable bit changes $ chmod +x newdirname/commonfile.py $ hg ci -m chmod $ hg ci --amend -m "chmod amended" $ hg ci --amend -m "chmod amended second time" $ hg log -p --git -r . changeset: 7:b1326f52dddf branch: newdirname tag: tip parent: 4:7fd235f7cb2f user: test date: Thu Jan 01 00:00:00 1970 +0000 summary: chmod amended second time diff --git a/newdirname/commonfile.py b/newdirname/commonfile.py old mode 100644 new mode 100755 #endif Test amend with file inclusion options -------------------------------------- These tests ensure that we are always amending some files that were part of the pre-amend commit. We want to test that the remaining files in the pre-amend commit were not changed in the amended commit. We do so by performing a diff of the amended commit against its parent commit. $ cd .. $ hg init testfileinclusions $ cd testfileinclusions $ echo a > a $ echo b > b $ hg commit -Aqm "Adding a and b" Only add changes to a particular file $ echo a >> a $ echo b >> b $ hg commit --amend -I a $ hg diff --git -r null -r . diff --git a/a b/a new file mode 100644 --- /dev/null +++ b/a @@ -0,0 +1,2 @@ +a +a diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,1 @@ +b $ echo a >> a $ hg commit --amend b $ hg diff --git -r null -r . diff --git a/a b/a new file mode 100644 --- /dev/null +++ b/a @@ -0,0 +1,2 @@ +a +a diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,2 @@ +b +b Exclude changes to a particular file $ echo b >> b $ hg commit --amend -X a $ hg diff --git -r null -r . diff --git a/a b/a new file mode 100644 --- /dev/null +++ b/a @@ -0,0 +1,2 @@ +a +a diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,3 @@ +b +b +b Check the addremove flag $ echo c > c $ rm a $ hg commit --amend -A removing a adding c $ hg diff --git -r null -r . diff --git a/b b/b new file mode 100644 --- /dev/null +++ b/b @@ -0,0 +1,3 @@ +b +b +b diff --git a/c b/c new file mode 100644 --- /dev/null +++ b/c @@ -0,0 +1,1 @@ +c