mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
64ed8a8d62
fbamend was using the python system rebase instead of the one loaded by Mercurial. This broke the tests when the installed rebase differed from the version of Mercurial we were running the tests with.
350 lines
9.7 KiB
Perl
350 lines
9.7 KiB
Perl
Test functionality is present
|
|
|
|
$ extpath=$(dirname $TESTDIR)
|
|
$ cp $extpath/fbamend.py $TESTTMP # use $TESTTMP substitution in message
|
|
$ cat >> $HGRCPATH << EOF
|
|
> [extensions]
|
|
> fbamend=$TESTTMP/fbamend.py
|
|
> rebase=
|
|
> EOF
|
|
|
|
$ hg help commit | grep -- --fixup
|
|
--fixup (with --amend) rebase children commits from a
|
|
$ hg help commit | grep -- --rebase
|
|
--rebase (with --amend) rebases children commits after the
|
|
$ hg help amend
|
|
hg amend [OPTION]...
|
|
|
|
amend the current commit with more changes
|
|
|
|
options ([+] can be repeated):
|
|
|
|
-A --addremove mark new/missing files as added/removed before
|
|
committing
|
|
-e --edit prompt to edit the commit message
|
|
--rebase rebases children commits after the amend
|
|
--fixup rebase children commits from a previous amend
|
|
-I --include PATTERN [+] include names matching the given patterns
|
|
-X --exclude PATTERN [+] exclude names matching the given patterns
|
|
-m --message TEXT use text as commit message
|
|
-l --logfile FILE read commit message from file
|
|
|
|
(some details hidden, use --verbose to show complete help)
|
|
|
|
Test basic functions
|
|
|
|
$ hg init repo
|
|
$ cd repo
|
|
$ echo a > a
|
|
$ hg add a
|
|
$ hg commit -m 'a'
|
|
$ echo a >> a
|
|
$ hg commit -m 'aa'
|
|
$ echo b >> b
|
|
$ hg add b
|
|
$ hg commit -m 'b'
|
|
$ hg up .^
|
|
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
|
$ echo a >> a
|
|
$ hg amend
|
|
warning: the commit's children were left behind
|
|
(use 'hg amend --fixup' to rebase them)
|
|
$ hg amend --fixup
|
|
rebasing the children of 34414ab6546d.preamend
|
|
rebasing 2:a764265b74cf "b"
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/a764265b74cf-c5eef4f8-backup.hg (glob)
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/86cf3bb05fcf-36a6cbd7-preamend-backup.hg (glob)
|
|
$ echo a >> a
|
|
$ hg amend --rebase
|
|
rebasing the children of 7817096bf624.preamend
|
|
rebasing 2:e1c831172263 "b"
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/e1c831172263-eee3b8f6-backup.hg (glob)
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/34414ab6546d-72d06a8e-preamend-backup.hg (glob)
|
|
|
|
Test that current bookmark is maintained
|
|
|
|
$ hg bookmark bm
|
|
$ hg bookmarks
|
|
* bm 1:7817096bf624
|
|
$ echo a >> a
|
|
$ hg amend --rebase
|
|
rebasing the children of bm.preamend
|
|
rebasing 2:1e390e3ec656 "b"
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/1e390e3ec656-8362bab7-backup.hg (glob)
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/7817096bf624-d72fddeb-preamend-backup.hg (glob)
|
|
$ hg bookmarks
|
|
* bm 1:7635008c16e1
|
|
|
|
Set up education
|
|
|
|
$ echo "[fbamend]" >> $HGRCPATH
|
|
$ echo "education = user education" >> $HGRCPATH
|
|
$ echo " second line" >> $HGRCPATH
|
|
$ echo "" >> $HGRCPATH
|
|
|
|
Test that bookmarked re-amends work well
|
|
|
|
$ echo a >> a
|
|
$ hg amend
|
|
user education
|
|
second line
|
|
warning: the commit's children were left behind
|
|
(use 'hg amend --fixup' to rebase them)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ edf5fd2f5332 aa bm
|
|
|
|
|
| o 2d6884e15790 b
|
|
| |
|
|
| o 7635008c16e1 aa bm.preamend
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ echo a >> a
|
|
$ hg amend
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/edf5fd2f5332-81b0ec5b-amend-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ 0889a0030a17 aa bm
|
|
|
|
|
| o 2d6884e15790 b
|
|
| |
|
|
| o 7635008c16e1 aa bm.preamend
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ hg amend --fixup
|
|
rebasing the children of bm.preamend
|
|
rebasing 2:2d6884e15790 "b"
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/2d6884e15790-909076cb-backup.hg (glob)
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/7635008c16e1-65f65ff6-preamend-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
o 6ba7926ba204 b
|
|
|
|
|
@ 0889a0030a17 aa bm
|
|
|
|
|
o cb9a9f314b8b a
|
|
|
|
$ hg bookmarks
|
|
* bm 1:0889a0030a17
|
|
|
|
Test that unbookmarked re-amends work well
|
|
|
|
$ hg boo -d bm
|
|
$ echo a >> a
|
|
$ hg amend
|
|
user education
|
|
second line
|
|
warning: the commit's children were left behind
|
|
(use 'hg amend --fixup' to rebase them)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ 94eb429c9465 aa
|
|
|
|
|
| o 6ba7926ba204 b
|
|
| |
|
|
| o 0889a0030a17 aa 94eb429c9465.preamend
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ echo a >> a
|
|
$ hg amend
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/94eb429c9465-30a7ee2c-amend-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ 83455f1f6049 aa
|
|
|
|
|
| o 6ba7926ba204 b
|
|
| |
|
|
| o 0889a0030a17 aa 83455f1f6049.preamend
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ hg amend --fixup
|
|
rebasing the children of 83455f1f6049.preamend
|
|
rebasing 2:6ba7926ba204 "b"
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/6ba7926ba204-9ac223ef-backup.hg (glob)
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/0889a0030a17-6bebea0c-preamend-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
o 455e4104f605 b
|
|
|
|
|
@ 83455f1f6049 aa
|
|
|
|
|
o cb9a9f314b8b a
|
|
|
|
|
|
Test interaction with histedit
|
|
|
|
$ echo '[extensions]' >> $HGRCPATH
|
|
$ echo "histedit=" >> $HGRCPATH
|
|
$ echo "fbhistedit=" >> $HGRCPATH
|
|
$ hg up tip
|
|
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
$ echo c >> c
|
|
$ hg add c
|
|
$ hg commit -m c
|
|
$ hg log -T '{node|short} {desc}\n'
|
|
765b28efbe8b c
|
|
455e4104f605 b
|
|
83455f1f6049 aa
|
|
cb9a9f314b8b a
|
|
$ hg histedit .^^ --commands - <<EOF
|
|
> pick 83455f1f6049
|
|
> x echo amending from exec
|
|
> x hg commit --amend -m 'message from exec'
|
|
> stop 455e4104f605
|
|
> pick 765b28efbe8b
|
|
> EOF
|
|
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
|
amending from exec
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
warning: the commit's children were left behind
|
|
(this is okay since a histedit is in progress)
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
Changes commited as a2329fab3fab. You may amend the commit now.
|
|
When you are finished, run hg histedit --continue to resume
|
|
[1]
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ a2329fab3fab b
|
|
|
|
|
o 048e86baa19d message from exec
|
|
|
|
|
| o 765b28efbe8b c
|
|
| |
|
|
| o 455e4104f605 b
|
|
| |
|
|
| o 83455f1f6049 aa
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ hg amend --rebase
|
|
abort: histedit in progress
|
|
(during histedit, use amend without --rebase)
|
|
[255]
|
|
$ hg commit --amend -m 'commit --amend message'
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/a2329fab3fab-e6fb940f-amend-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ 3166f3b5587d commit --amend message
|
|
|
|
|
o 048e86baa19d message from exec
|
|
|
|
|
| o 765b28efbe8b c
|
|
| |
|
|
| o 455e4104f605 b
|
|
| |
|
|
| o 83455f1f6049 aa
|
|
|/
|
|
o cb9a9f314b8b a
|
|
|
|
$ hg histedit --continue
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/83455f1f6049-922a304e-backup.hg (glob)
|
|
$ hg log -G -T '{node|short} {desc} {bookmarks}\n'
|
|
@ 0f83a9508203 c
|
|
|
|
|
o 3166f3b5587d commit --amend message
|
|
|
|
|
o 048e86baa19d message from exec
|
|
|
|
|
o cb9a9f314b8b a
|
|
|
|
Test that --message is respected
|
|
|
|
$ hg amend
|
|
nothing changed
|
|
$ hg amend --message foo
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/0f83a9508203-7d2a99ee-amend-backup.hg (glob)
|
|
$ hg amend -m bar
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/29272a1da891-35a82ce4-amend-backup.hg (glob)
|
|
$ hg amend
|
|
nothing changed
|
|
|
|
Test that --addremove/-A works
|
|
|
|
$ echo new > new
|
|
$ hg amend -A
|
|
adding new
|
|
saved backup bundle to $TESTTMP/repo/.hg/strip-backup/772f45f5a69d-90a7bd63-amend-backup.hg (glob)
|
|
|
|
Test that the extension disables itself when evolution is enabled
|
|
|
|
$ $PYTHON -c 'import evolve' || exit 80
|
|
$ cat >> .hg/hgrc <<EOF
|
|
> [extensions]
|
|
> evolve=
|
|
> EOF
|
|
|
|
noisy warning during amend
|
|
|
|
$ hg amend 2>&1
|
|
fbamend and evolve extension are incompatible, fbamend deactivated.
|
|
You can either disable it globally:
|
|
- type `hg config --edit`
|
|
- drop the `fbamend=` line from the `[extensions]` section
|
|
or disable it for a specific repo:
|
|
- type `hg config --local --edit`
|
|
- add a `fbamend=!$TESTTMP/fbamend.py` line in the `[extensions]` section
|
|
nothing changed
|
|
|
|
no warning if only obsolete markers are enabled
|
|
|
|
$ cat >> .hg/hgrc <<EOF
|
|
> [experimental]
|
|
> evolution=createmarkers
|
|
> EOF
|
|
|
|
$ hg amend
|
|
nothing changed
|
|
|
|
Fbamend respects the createmarkers option
|
|
|
|
$ hg log -G -T '{rev} {node|short} {desc} {bookmarks}\n'
|
|
@ 3 01dd7a39383a bar
|
|
|
|
|
o 2 3166f3b5587d commit --amend message
|
|
|
|
|
o 1 048e86baa19d message from exec
|
|
|
|
|
o 0 cb9a9f314b8b a
|
|
|
|
$ hg up 048e86
|
|
0 files updated, 0 files merged, 3 files removed, 0 files unresolved
|
|
$ echo "bb" > bb
|
|
$ hg add bb
|
|
$ hg amend --debug
|
|
amending changeset 048e86baa19d
|
|
committing files:
|
|
bb
|
|
committing manifest
|
|
committing changelog
|
|
copying changeset 4e21ff9ac40b to cb9a9f314b8b
|
|
committing files:
|
|
a
|
|
bb
|
|
committing manifest
|
|
committing changelog
|
|
user education
|
|
second line
|
|
warning: the commit's children were left behind
|
|
(use 'hg amend --fixup' to rebase them)
|
|
$ hg amend --fixup
|
|
rebasing the children of 3a4d2824efc1.preamend
|
|
rebasing 2:3166f3b5587d "commit --amend message"
|
|
rebasing 3:01dd7a39383a "bar"
|
|
$ hg log -G -T '{rev} {node|short} {desc} {bookmarks}\n'
|
|
o 7 9752120dcffe bar
|
|
|
|
|
o 6 bc3b6a46cdb4 commit --amend message
|
|
|
|
|
@ 5 3a4d2824efc1 message from exec
|
|
|
|
|
o 0 cb9a9f314b8b a
|
|
|
|
$ echo "cc" > cc
|
|
$ hg add cc
|
|
$ hg amend --rebase --traceback
|
|
rebasing the children of 1c16dd8e35d2.preamend
|
|
rebasing 6:bc3b6a46cdb4 "commit --amend message"
|
|
rebasing 7:9752120dcffe "bar"
|
|
|
|
|
|
|
|
|