2019-12-10 02:24:31 +03:00
|
|
|
#chg-compatible
|
|
|
|
|
2020-01-20 13:42:49 +03:00
|
|
|
$ configure mutation-norecord
|
|
|
|
$ disable treemanifest
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag << 'EOS'
|
|
|
|
> B # B/B=B\n
|
|
|
|
> |
|
|
|
|
> A # A/A=A\n
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
Cannot amend null:
|
|
|
|
|
|
|
|
$ hg ci --amend -m x
|
|
|
|
abort: cannot amend null changeset
|
|
|
|
(no changeset checked out)
|
|
|
|
[255]
|
2012-04-18 02:20:16 +04:00
|
|
|
|
|
|
|
Refuse to amend public csets:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg up -Cq $B
|
2020-06-29 23:51:53 +03:00
|
|
|
$ cp -R . ../repo-public
|
|
|
|
$ hg -R ../repo-public debugmakepublic .
|
|
|
|
$ hg -R ../repo-public ci --amend
|
2012-04-18 02:20:16 +04:00
|
|
|
abort: cannot amend public changesets
|
2017-11-28 03:20:45 +03:00
|
|
|
(see 'hg help phases' for details)
|
2012-04-18 02:20:16 +04:00
|
|
|
[255]
|
|
|
|
|
|
|
|
Nothing to amend:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg ci --amend -m 'B'
|
2012-04-18 02:20:16 +04:00
|
|
|
nothing changed
|
|
|
|
[1]
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Amending changeset with changes in working dir:
|
|
|
|
(and check that --message does not trigger an editor)
|
|
|
|
|
2012-06-29 17:21:35 +04:00
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [hooks]
|
2012-09-03 20:25:50 +04:00
|
|
|
> pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
|
2012-06-29 17:21:35 +04:00
|
|
|
> EOF
|
2012-06-23 20:57:29 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ echo a >> A
|
2012-11-13 20:41:56 +04:00
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
|
2019-02-13 08:39:24 +03:00
|
|
|
pretxncommit 217e580a9218a74044be7970e41021181317b52b
|
2019-12-18 00:45:17 +03:00
|
|
|
217e580a9218
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ echo '%unset pretxncommit.foo' >> $HGRCPATH
|
|
|
|
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg diff -c .
|
2019-02-13 08:39:24 +03:00
|
|
|
diff -r 4a2df7238c3b -r 217e580a9218 A
|
|
|
|
--- a/A Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
+++ b/A Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
@@ -1,1 +1,2 @@
|
|
|
|
A
|
2016-11-15 23:56:49 +03:00
|
|
|
+a
|
2019-02-13 08:39:24 +03:00
|
|
|
diff -r 4a2df7238c3b -r 217e580a9218 B
|
|
|
|
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
+++ b/B Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
@@ -0,0 +1,1 @@
|
|
|
|
+B
|
|
|
|
$ hg log -Gr 'all()' -T '{desc}'
|
|
|
|
@ amend base1
|
2020-10-20 03:05:23 +03:00
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2012-04-18 02:20:16 +04:00
|
|
|
|
|
|
|
|
2012-12-29 21:00:18 +04:00
|
|
|
Check proper abort for empty message
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2012-12-29 21:00:18 +04:00
|
|
|
$ cat > editor.sh << '__EOF__'
|
|
|
|
> #!/bin/sh
|
|
|
|
> echo "" > "$1"
|
|
|
|
> __EOF__
|
2017-09-01 22:34:36 +03:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ echo a >> A
|
2012-12-29 21:00:18 +04:00
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
|
2019-02-13 08:39:24 +03:00
|
|
|
transaction abort! (?)
|
|
|
|
rollback completed (?)
|
2012-12-29 21:00:18 +04:00
|
|
|
abort: empty commit message
|
|
|
|
[255]
|
|
|
|
|
2017-09-01 22:34:36 +03:00
|
|
|
Add new file along with modified existing file:
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ echo C >> C
|
|
|
|
$ hg add -q C
|
2012-12-29 21:00:18 +04:00
|
|
|
$ hg ci --amend -m 'amend base1 new file'
|
2012-04-18 02:20:16 +04:00
|
|
|
|
|
|
|
Remove file that was added in amended commit:
|
2012-10-24 17:37:32 +04:00
|
|
|
(and test logfile option)
|
2012-11-13 20:41:56 +04:00
|
|
|
(and test that logfile option do not trigger an editor)
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rm C
|
2012-10-24 17:37:32 +04:00
|
|
|
$ echo 'amend base1 remove new file' > ../logfile
|
2012-11-13 20:41:56 +04:00
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg cat C
|
|
|
|
C: no such file in rev 9579b4a5c1df
|
2012-04-18 02:20:16 +04:00
|
|
|
[1]
|
|
|
|
|
|
|
|
No changes, just a different message:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg ci --amend -m 'no changes, new message'
|
|
|
|
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg diff -c .
|
2019-02-13 08:39:24 +03:00
|
|
|
diff -r 4a2df7238c3b -r 80f3c49eb411 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
|
2016-11-15 23:56:49 +03:00
|
|
|
+a
|
2017-09-01 22:34:36 +03:00
|
|
|
+a
|
2019-02-13 08:39:24 +03:00
|
|
|
diff -r 4a2df7238c3b -r 80f3c49eb411 B
|
|
|
|
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
+++ b/B Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
@@ -0,0 +1,1 @@
|
|
|
|
+B
|
2012-04-18 02:20:16 +04:00
|
|
|
|
|
|
|
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:
|
|
|
|
|
2014-08-16 05:43:59 +04:00
|
|
|
$ cat > .hg/checkeditform.sh <<EOF
|
|
|
|
> env | grep HGEDITFORM
|
|
|
|
> true
|
|
|
|
> EOF
|
2019-02-13 08:39:24 +03:00
|
|
|
|
2014-08-16 05:43:59 +04:00
|
|
|
$ HGEDITOR="sh .hg/checkeditform.sh" hg ci --amend -u foo -d '1 0'
|
|
|
|
HGEDITFORM=commit.amend.normal
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ echo a >> A
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg ci --amend -u foo -d '1 0'
|
2019-02-13 08:39:24 +03:00
|
|
|
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg log -r .
|
2020-07-21 03:23:52 +03:00
|
|
|
commit: 815553afc946
|
2012-04-18 02:20:16 +04:00
|
|
|
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:
|
|
|
|
|
2012-06-10 16:41:14 +04:00
|
|
|
$ cat > editor.sh << '__EOF__'
|
2012-04-18 02:20:16 +04:00
|
|
|
> #!/bin/sh
|
|
|
|
> cat $1
|
|
|
|
> echo "another precious commit message" > "$1"
|
|
|
|
> __EOF__
|
2014-03-18 20:07:41 +04:00
|
|
|
|
|
|
|
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
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg commit --amend -m "message given from command line"
|
2020-07-09 00:32:18 +03:00
|
|
|
transaction abort! (?)
|
|
|
|
rollback completed (?)
|
2014-03-18 20:07:41 +04:00
|
|
|
abort: pretxncommit.test-saving-last-message hook exited with status 1
|
|
|
|
[255]
|
2019-02-13 08:39:24 +03:00
|
|
|
|
2014-03-18 20:07:41 +04:00
|
|
|
$ cat .hg/last-message.txt
|
|
|
|
message given from command line (no-eol)
|
|
|
|
|
|
|
|
$ rm -f .hg/last-message.txt
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
|
2014-03-18 20:07:41 +04:00
|
|
|
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'
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: added B
|
|
|
|
HG: changed A
|
2020-07-09 00:32:18 +03:00
|
|
|
transaction abort! (?)
|
|
|
|
rollback completed (?)
|
2014-03-18 20:07:41 +04:00
|
|
|
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
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
|
2012-04-18 02:20:16 +04:00
|
|
|
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'
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: added B
|
|
|
|
HG: changed A
|
2012-04-18 02:20:16 +04:00
|
|
|
|
|
|
|
Same, but with changes in working dir (different code path):
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ echo a >> A
|
|
|
|
$ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
|
2012-04-18 02:20:16 +04:00
|
|
|
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'
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: added B
|
|
|
|
HG: changed A
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2012-06-10 16:41:14 +04:00
|
|
|
$ rm editor.sh
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg log -r .
|
2020-07-21 03:23:52 +03:00
|
|
|
commit: f7f2c5aae908
|
2012-04-18 02:20:16 +04:00
|
|
|
user: foo
|
|
|
|
date: Thu Jan 01 00:00:01 1970 +0000
|
|
|
|
summary: another precious commit message
|
|
|
|
|
|
|
|
|
|
|
|
Moving bookmarks, preserve active bookmark:
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag << 'EOS'
|
|
|
|
> a
|
|
|
|
> EOS
|
|
|
|
$ hg book -r $a book1
|
|
|
|
$ hg book -r $a book2
|
|
|
|
$ hg up -q book1
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg ci --amend -m 'move bookmarks'
|
|
|
|
$ hg book
|
2019-02-13 08:39:24 +03:00
|
|
|
transaction abort! (?)
|
|
|
|
rollback completed (?)
|
2020-10-09 08:27:14 +03:00
|
|
|
* book1 919d9f835a8e
|
|
|
|
book2 919d9f835a8e
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2012-12-30 06:49:15 +04:00
|
|
|
abort does not loose bookmarks
|
2018-07-27 22:07:09 +03:00
|
|
|
(note: with fsmonitor, transaction started before checking commit message)
|
2012-12-30 06:49:15 +04:00
|
|
|
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Restore global hgrc
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ cat >> $HGRCPATH <<EOF
|
|
|
|
> [defaults]
|
|
|
|
> commit=-d '0 0'
|
|
|
|
> EOF
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2013-02-09 01:08:34 +04:00
|
|
|
Refuse to amend during a merge:
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> Y Z
|
|
|
|
> |/
|
|
|
|
> X
|
|
|
|
> EOS
|
|
|
|
$ hg up -q $Y
|
|
|
|
$ hg merge -q $Z
|
2012-04-18 02:20:16 +04:00
|
|
|
$ hg ci --amend
|
|
|
|
abort: cannot amend while merging
|
|
|
|
[255]
|
|
|
|
|
2018-04-10 21:03:26 +03:00
|
|
|
Refuse to amend if there is a merge conflict (issue5805):
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> Y # Y/X=Y
|
|
|
|
> |
|
|
|
|
> X
|
|
|
|
> EOS
|
|
|
|
$ hg up -q $X
|
|
|
|
$ echo c >> X
|
|
|
|
$ hg up $Y -t :fail -q
|
2018-04-10 21:03:26 +03:00
|
|
|
[1]
|
|
|
|
$ hg resolve -l
|
2019-02-13 08:39:24 +03:00
|
|
|
U X
|
2018-04-10 21:03:26 +03:00
|
|
|
|
|
|
|
$ hg ci --amend
|
|
|
|
abort: unresolved merge conflicts (see 'hg help resolve')
|
|
|
|
[255]
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Follow copies/renames (including issue4405):
|
2012-04-30 22:45:45 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> B # B/B=A (renamed from A)
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
2012-04-30 22:45:45 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg up -q $B
|
|
|
|
$ echo 1 >> B
|
|
|
|
$ hg ci --amend -m 'B-amended'
|
|
|
|
$ hg log -r . -T '{file_copies}\n'
|
|
|
|
B (A)
|
2012-04-18 02:20:16 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg mv B C
|
|
|
|
$ hg ci --amend -m 'C'
|
|
|
|
$ hg log -r . -T '{file_copies}\n'
|
|
|
|
C (A)
|
2012-05-11 19:33:45 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Move added file (issue3410):
|
2012-05-11 19:33:45 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> A
|
|
|
|
> EOS
|
2012-09-11 02:12:07 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg up -q $A
|
|
|
|
$ hg mv A B
|
|
|
|
$ hg ci --amend -m 'B'
|
|
|
|
$ hg log -r . --template "{file_copies}\n"
|
|
|
|
|
2012-09-11 02:12:07 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Obsolete information
|
|
|
|
|
|
|
|
$ hg log -r 'predecessors(.)' --hidden -T '{desc}\n'
|
|
|
|
A
|
|
|
|
B
|
|
|
|
|
|
|
|
Amend a merge. Make it trickier by including renames.
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ drawdag << 'EOS'
|
|
|
|
> # D/D=3
|
|
|
|
> D # C/D=2
|
|
|
|
> |\ # B/D=1
|
|
|
|
> B C # B/B=X (renamed from X)
|
|
|
|
> | | # C/C=Y (renamed from Y)
|
|
|
|
> X Y
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg up -q $D
|
|
|
|
$ hg debugrename B
|
|
|
|
B renamed from X:44f0fe2c7b2f8e25d302364ca8d50f37f9bfb143
|
|
|
|
$ hg debugrename C
|
|
|
|
C renamed from Y:949988db577d2987b8dc29aeb0467aad77fd2005
|
|
|
|
|
|
|
|
$ echo 4 >> D
|
|
|
|
$ hg mv B B2
|
|
|
|
$ hg mv C C2
|
|
|
|
$ hg commit --amend -m D2
|
|
|
|
$ hg log -r. -T '{desc}\n'
|
|
|
|
D2
|
|
|
|
$ hg cat -r. D
|
|
|
|
34
|
|
|
|
|
|
|
|
$ hg debugrename B2
|
|
|
|
B2 renamed from B:668baf98ee11de8040fa6e9d9b477cb85157750a
|
|
|
|
$ hg debugrename C2
|
|
|
|
C2 renamed from C:9eeb74a40ee18c256903a5b1d572e0debc1f4cb8
|
|
|
|
|
|
|
|
Undo renames
|
|
|
|
|
|
|
|
$ hg mv B2 B
|
|
|
|
$ hg mv C2 C
|
|
|
|
$ hg commit --amend -m D3
|
|
|
|
$ hg debugrename B
|
|
|
|
B renamed from X:44f0fe2c7b2f8e25d302364ca8d50f37f9bfb143
|
|
|
|
$ hg debugrename C
|
|
|
|
C renamed from Y:949988db577d2987b8dc29aeb0467aad77fd2005
|
|
|
|
|
|
|
|
Undo merge conflict resolution
|
|
|
|
|
|
|
|
$ hg log -GT '{desc}\n' -f D
|
|
|
|
@ D3
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ o C
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o B
|
2020-10-20 03:05:23 +03:00
|
|
|
│
|
2016-03-23 23:34:47 +03:00
|
|
|
~
|
2012-09-11 02:12:07 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
(This is suboptimal. It should only show B without D4)
|
|
|
|
$ printf 1 > D
|
|
|
|
$ hg commit --amend -m D4
|
|
|
|
$ hg log -GT '{desc}\n' -f D
|
|
|
|
@ D4
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ o C
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o B
|
2020-10-20 03:05:23 +03:00
|
|
|
│
|
2016-03-23 23:34:47 +03:00
|
|
|
~
|
2012-09-11 02:12:07 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ printf 2 > D
|
|
|
|
$ hg commit --amend -m D4
|
|
|
|
$ hg log -GT '{desc}\n' -f D
|
|
|
|
o C
|
2020-10-20 03:05:23 +03:00
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
~
|
2012-09-11 02:12:07 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
Amend a merge, with change/deletion conflict.
|
|
|
|
Sadly, this test shows internals are inconsistent.
|
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ drawdag << 'EOS'
|
|
|
|
> # E/A=D
|
|
|
|
> E # E/B=C
|
|
|
|
> |\ # C/A=(removed)
|
|
|
|
> C D # C/B=C
|
|
|
|
> |/ # D/A=D
|
|
|
|
> | # D/B=(removed)
|
|
|
|
> /|
|
|
|
|
> A B
|
|
|
|
> EOS
|
|
|
|
|
|
|
|
$ hg files -r $E
|
|
|
|
A
|
|
|
|
B
|
|
|
|
|
|
|
|
$ hg up -q $E
|
|
|
|
|
|
|
|
$ hg log -f -T '{desc}' -G A
|
|
|
|
o D
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2013-01-01 03:44:18 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -f -T '{desc}' -G B
|
|
|
|
o C
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o B
|
2013-01-01 03:44:18 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -r. -T '{files}'
|
2013-02-09 01:08:34 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg rm A B
|
|
|
|
$ hg ci --amend -m E2
|
|
|
|
$ hg log --removed -f -T '{desc}' -G A
|
|
|
|
o D
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
|
|
|
│ o C
|
|
|
|
╭─┤
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
|
|
|
|
|
|
|
$ hg log --removed -f -T '{desc}' -G B
|
|
|
|
@ E2
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ o D
|
|
|
|
│ ├─╮
|
|
|
|
│ │ │
|
|
|
|
│ │ ~
|
|
|
|
│ │
|
|
|
|
o │ C
|
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
~ │
|
|
|
|
│
|
|
|
|
o B
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
|
|
|
|
Undo the removal
|
|
|
|
|
|
|
|
$ printf C > B
|
|
|
|
$ printf D > A
|
|
|
|
$ hg ci --amend -m E3
|
revset: move "log dir" special path to "follow()" revset
Summary:
The "hg log" implementation chooses to not use the "follow" revset when logging
a directory, but use "_matchfiles" instead. In an upcoming change, we'd like
"follow" to handle directories so fastlog only needs to patch the "follow"
revset.
The "follow" revset can take a directory pattern just fine. The problem is
"follow" will follow *every* file inside the specified directory, which is
quite expensive.
For now, I just moved the "_matchfiles" fallback path to "follow" so when it
detects there are too many files to follow, it will switch to "_matchfiles"
directly.
In theory, tree manfiest repos would have "tree manifest" infomation that speed
up "follow" on a directory. But that's a bigger change, and it's probably very
slow in our setup because our trees are lazy.
This changes some behaviors subtly, as reflected in tests:
- `-f path` can use DAG range instead of rev range, which is a good thing as
rev range does not make much sense to end-users. This removes a "BUG" in
test-commit-amend.t
- `-f dir` can follow renames if the directory contains just a few files.
This looks like a good thing, and is reflected in `test-log.t`.
Reviewed By: sfilipco
Differential Revision: D14863134
fbshipit-source-id: 99ddff46d43f63ce03dc7bf005e3ac1cb9b39d03
2019-04-17 08:15:44 +03:00
|
|
|
$ hg log -fr tip -T '{desc}' -G A
|
2019-02-13 08:39:24 +03:00
|
|
|
o D
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o A
|
2013-02-09 01:08:34 +04:00
|
|
|
|
revset: move "log dir" special path to "follow()" revset
Summary:
The "hg log" implementation chooses to not use the "follow" revset when logging
a directory, but use "_matchfiles" instead. In an upcoming change, we'd like
"follow" to handle directories so fastlog only needs to patch the "follow"
revset.
The "follow" revset can take a directory pattern just fine. The problem is
"follow" will follow *every* file inside the specified directory, which is
quite expensive.
For now, I just moved the "_matchfiles" fallback path to "follow" so when it
detects there are too many files to follow, it will switch to "_matchfiles"
directly.
In theory, tree manfiest repos would have "tree manifest" infomation that speed
up "follow" on a directory. But that's a bigger change, and it's probably very
slow in our setup because our trees are lazy.
This changes some behaviors subtly, as reflected in tests:
- `-f path` can use DAG range instead of rev range, which is a good thing as
rev range does not make much sense to end-users. This removes a "BUG" in
test-commit-amend.t
- `-f dir` can follow renames if the directory contains just a few files.
This looks like a good thing, and is reflected in `test-log.t`.
Reviewed By: sfilipco
Differential Revision: D14863134
fbshipit-source-id: 99ddff46d43f63ce03dc7bf005e3ac1cb9b39d03
2019-04-17 08:15:44 +03:00
|
|
|
$ hg log -fr tip -T '{desc}' -G B
|
|
|
|
o C
|
2020-10-20 03:05:23 +03:00
|
|
|
├─╮
|
|
|
|
│ │
|
|
|
|
│ ~
|
|
|
|
│
|
2019-02-13 08:39:24 +03:00
|
|
|
o B
|
2013-02-09 01:08:34 +04:00
|
|
|
|
2013-05-02 20:36:47 +04:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -r. -T '{files}'
|
|
|
|
B (no-eol)
|
2014-03-13 14:48:41 +04:00
|
|
|
|
2014-04-15 21:38:11 +04:00
|
|
|
Test that amend with --edit invokes editor forcibly
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
|
|
|
$ echo A | hg debugdrawdag
|
|
|
|
$ hg up -q A
|
|
|
|
|
2014-04-15 21:38:11 +04:00
|
|
|
$ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
|
2019-02-13 08:39:24 +03:00
|
|
|
$ hg log -r. -T '{desc}\n'
|
2014-04-15 21:38:11 +04:00
|
|
|
editor should be suppressed
|
|
|
|
|
|
|
|
$ 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
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: branch 'default'
|
2019-12-17 05:10:38 +03:00
|
|
|
HG: bookmark 'A'
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: added A
|
|
|
|
|
|
|
|
$ hg log -r. -T '{desc}\n'
|
2014-04-15 21:38:11 +04:00
|
|
|
editor should be invoked
|
2014-10-16 17:35:06 +04:00
|
|
|
|
2014-12-17 09:09:43 +03:00
|
|
|
Test that "diff()" in committemplate works correctly for amending
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ newrepo
|
2014-12-17 09:09:43 +03:00
|
|
|
$ 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
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ echo A | hg debugdrawdag
|
|
|
|
$ hg up -q A
|
2014-12-17 09:09:43 +03:00
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
$ HGEDITOR=cat hg commit --amend -e -m "expecting diff of A"
|
|
|
|
expecting diff of A
|
2014-12-17 09:09:43 +03:00
|
|
|
|
|
|
|
HG: M:
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: A: A
|
2014-12-17 09:09:43 +03:00
|
|
|
HG: R:
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: diff -r 000000000000 A
|
2015-06-01 20:28:33 +03:00
|
|
|
HG: --- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: +++ b/A Thu Jan 01 00:00:00 1970 +0000
|
2014-12-17 09:09:43 +03:00
|
|
|
HG: @@ -0,0 +1,1 @@
|
2019-02-13 08:39:24 +03:00
|
|
|
HG: +A
|
|
|
|
HG: \ No newline at end of file
|
2015-03-02 22:01:00 +03:00
|
|
|
|
2016-10-30 00:15:09 +03:00
|
|
|
#if execbit
|
|
|
|
|
2016-05-20 00:35:22 +03:00
|
|
|
Test if amend preserves executable bit changes
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ newrepo
|
|
|
|
$ drawdag <<'EOS'
|
|
|
|
> B
|
|
|
|
> |
|
|
|
|
> A
|
|
|
|
> EOS
|
|
|
|
$ hg up -q $B
|
|
|
|
$ chmod +x A
|
2016-05-20 00:35:22 +03:00
|
|
|
$ hg ci -m chmod
|
|
|
|
$ hg ci --amend -m "chmod amended"
|
|
|
|
$ hg ci --amend -m "chmod amended second time"
|
|
|
|
$ hg log -p --git -r .
|
2020-07-21 03:23:52 +03:00
|
|
|
commit: b4aab18bba3e
|
2016-05-20 00:35:22 +03:00
|
|
|
user: test
|
|
|
|
date: Thu Jan 01 00:00:00 1970 +0000
|
|
|
|
summary: chmod amended second time
|
|
|
|
|
2019-02-13 08:39:24 +03:00
|
|
|
diff --git a/A b/A
|
2016-05-20 00:35:22 +03:00
|
|
|
old mode 100644
|
|
|
|
new mode 100755
|
|
|
|
|
2016-10-30 00:15:09 +03:00
|
|
|
#endif
|
2017-09-01 22:34:34 +03:00
|
|
|
|
|
|
|
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.
|
2019-02-13 08:39:24 +03:00
|
|
|
|
|
|
|
$ newrepo testfileinclusions
|
2017-09-01 22:34:34 +03:00
|
|
|
$ 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
|