| 1 |
$ cat <<EOF >> $HGRCPATH |
| 2 |
> [extensions] |
| 3 |
> mq = |
| 4 |
> [mq] |
| 5 |
> git = keep |
| 6 |
> [diff] |
| 7 |
> nodates = 1 |
| 8 |
> EOF |
| 9 |
|
| 10 |
init: |
| 11 |
|
| 12 |
$ hg init repo |
| 13 |
$ cd repo |
| 14 |
$ echo a > a |
| 15 |
$ hg ci -Am adda |
| 16 |
adding a |
| 17 |
$ echo a >> a |
| 18 |
$ hg qnew -f p1 |
| 19 |
$ echo b >> a |
| 20 |
$ hg qnew -f p2 |
| 21 |
$ echo c >> a |
| 22 |
$ hg qnew -f p3 |
| 23 |
|
| 24 |
Fold in the middle of the queue: |
| 25 |
(this tests also that editor is not invoked if '--edit' is not |
| 26 |
specified) |
| 27 |
|
| 28 |
$ hg qpop p1 |
| 29 |
popping p3 |
| 30 |
popping p2 |
| 31 |
now at: p1 |
| 32 |
|
| 33 |
$ hg qdiff |
| 34 |
diff -r 07f494440405 a |
| 35 |
--- a/a |
| 36 |
+++ b/a |
| 37 |
@@ -1,1 +1,2 @@ |
| 38 |
a |
| 39 |
+a |
| 40 |
|
| 41 |
$ HGEDITOR=cat hg qfold p2 |
| 42 |
$ grep git .hg/patches/p1 && echo 'git patch found!' |
| 43 |
[1] |
| 44 |
|
| 45 |
$ hg qser |
| 46 |
p1 |
| 47 |
p3 |
| 48 |
|
| 49 |
$ hg qdiff |
| 50 |
diff -r 07f494440405 a |
| 51 |
--- a/a |
| 52 |
+++ b/a |
| 53 |
@@ -1,1 +1,3 @@ |
| 54 |
a |
| 55 |
+a |
| 56 |
+b |
| 57 |
|
| 58 |
Fold with local changes: |
| 59 |
|
| 60 |
$ echo d >> a |
| 61 |
$ hg qfold p3 |
| 62 |
abort: local changes found, qrefresh first |
| 63 |
[255] |
| 64 |
|
| 65 |
$ hg diff -c . |
| 66 |
diff -r 07f494440405 -r ???????????? a (glob) |
| 67 |
--- a/a |
| 68 |
+++ b/a |
| 69 |
@@ -1,1 +1,3 @@ |
| 70 |
a |
| 71 |
+a |
| 72 |
+b |
| 73 |
|
| 74 |
$ hg revert -a --no-backup |
| 75 |
reverting a |
| 76 |
|
| 77 |
Fold git patch into a regular patch, expect git patch: |
| 78 |
|
| 79 |
$ echo a >> a |
| 80 |
$ hg qnew -f regular |
| 81 |
$ hg cp a aa |
| 82 |
$ hg qnew --git -f git |
| 83 |
|
| 84 |
$ hg qpop |
| 85 |
popping git |
| 86 |
now at: regular |
| 87 |
|
| 88 |
$ hg qfold git |
| 89 |
|
| 90 |
$ cat .hg/patches/regular |
| 91 |
# HG changeset patch |
| 92 |
# Parent ???????????????????????????????????????? (glob) |
| 93 |
|
| 94 |
diff --git a/a b/a |
| 95 |
--- a/a |
| 96 |
+++ b/a |
| 97 |
@@ -1,3 +1,4 @@ |
| 98 |
a |
| 99 |
a |
| 100 |
b |
| 101 |
+a |
| 102 |
diff --git a/a b/aa |
| 103 |
copy from a |
| 104 |
copy to aa |
| 105 |
--- a/a |
| 106 |
+++ b/aa |
| 107 |
@@ -1,3 +1,4 @@ |
| 108 |
a |
| 109 |
a |
| 110 |
b |
| 111 |
+a |
| 112 |
|
| 113 |
$ hg qpop |
| 114 |
popping regular |
| 115 |
now at: p1 |
| 116 |
|
| 117 |
$ hg qdel regular |
| 118 |
|
| 119 |
Fold regular patch into a git patch, expect git patch: |
| 120 |
|
| 121 |
$ hg cp a aa |
| 122 |
$ hg qnew --git -f git |
| 123 |
$ echo b >> aa |
| 124 |
$ hg qnew -f regular |
| 125 |
|
| 126 |
$ hg qpop |
| 127 |
popping regular |
| 128 |
now at: git |
| 129 |
|
| 130 |
$ hg qfold regular |
| 131 |
|
| 132 |
$ cat .hg/patches/git |
| 133 |
# HG changeset patch |
| 134 |
# Parent ???????????????????????????????????????? (glob) |
| 135 |
|
| 136 |
diff --git a/a b/aa |
| 137 |
copy from a |
| 138 |
copy to aa |
| 139 |
--- a/a |
| 140 |
+++ b/aa |
| 141 |
@@ -1,3 +1,4 @@ |
| 142 |
a |
| 143 |
a |
| 144 |
b |
| 145 |
+b |
| 146 |
|
| 147 |
Test saving last-message.txt: |
| 148 |
|
| 149 |
$ hg qrefresh -m "original message" |
| 150 |
|
| 151 |
$ cat > $TESTTMP/commitfailure.py <<EOF |
| 152 |
> from mercurial import error |
| 153 |
> def reposetup(ui, repo): |
| 154 |
> class commitfailure(repo.__class__): |
| 155 |
> def commit(self, *args, **kwargs): |
| 156 |
> raise error.Abort(b'emulating unexpected abort') |
| 157 |
> repo.__class__ = commitfailure |
| 158 |
> EOF |
| 159 |
|
| 160 |
$ cat >> .hg/hgrc <<EOF |
| 161 |
> [extensions] |
| 162 |
> # this failure occurs before editor invocation |
| 163 |
> commitfailure = $TESTTMP/commitfailure.py |
| 164 |
> EOF |
| 165 |
|
| 166 |
$ cat > $TESTTMP/editor.sh << EOF |
| 167 |
> echo "==== before editing" |
| 168 |
> cat \$1 |
| 169 |
> echo "====" |
| 170 |
> (echo; echo "test saving last-message.txt") >> \$1 |
| 171 |
> EOF |
| 172 |
|
| 173 |
$ hg qapplied |
| 174 |
p1 |
| 175 |
git |
| 176 |
$ hg tip --template "{files}\n" |
| 177 |
aa |
| 178 |
|
| 179 |
(test that editor is not invoked before transaction starting, |
| 180 |
and that combination of '--edit' and '--message' doesn't abort execution) |
| 181 |
|
| 182 |
$ rm -f .hg/last-message.txt |
| 183 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qfold -e -m MESSAGE p3 |
| 184 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 185 |
abort: emulating unexpected abort |
| 186 |
[255] |
| 187 |
$ test -f .hg/last-message.txt |
| 188 |
[1] |
| 189 |
|
| 190 |
(reset applied patches and directory status) |
| 191 |
|
| 192 |
$ cat >> .hg/hgrc <<EOF |
| 193 |
> [extensions] |
| 194 |
> # this failure occurs after editor invocation |
| 195 |
> commitfailure = ! |
| 196 |
> EOF |
| 197 |
|
| 198 |
$ hg qapplied |
| 199 |
p1 |
| 200 |
$ hg status -A aa |
| 201 |
? aa |
| 202 |
$ rm aa |
| 203 |
$ hg status -m |
| 204 |
M a |
| 205 |
$ hg revert --no-backup -q a |
| 206 |
$ hg qpush -q git |
| 207 |
now at: git |
| 208 |
|
| 209 |
(test that editor is invoked and commit message is saved into |
| 210 |
"last-message.txt") |
| 211 |
|
| 212 |
$ cat >> .hg/hgrc <<EOF |
| 213 |
> [hooks] |
| 214 |
> # this failure occurs after editor invocation |
| 215 |
> pretxncommit.unexpectedabort = false |
| 216 |
> EOF |
| 217 |
|
| 218 |
$ rm -f .hg/last-message.txt |
| 219 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qfold -e p3 |
| 220 |
==== before editing |
| 221 |
original message |
| 222 |
|
| 223 |
|
| 224 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
| 225 |
HG: Leave message empty to use default message. |
| 226 |
HG: -- |
| 227 |
HG: user: test |
| 228 |
HG: branch 'default' |
| 229 |
HG: added aa |
| 230 |
HG: changed a |
| 231 |
==== |
| 232 |
note: commit message saved in .hg/last-message.txt |
| 233 |
note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it |
| 234 |
transaction abort! |
| 235 |
rollback completed |
| 236 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 237 |
abort: pretxncommit.unexpectedabort hook exited with status 1 |
| 238 |
[40] |
| 239 |
$ cat .hg/last-message.txt |
| 240 |
original message |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
test saving last-message.txt |
| 245 |
|
| 246 |
(confirm whether files listed up in the commit message editing are correct) |
| 247 |
|
| 248 |
$ cat >> .hg/hgrc <<EOF |
| 249 |
> [hooks] |
| 250 |
> pretxncommit.unexpectedabort = |
| 251 |
> EOF |
| 252 |
$ hg status -u | while read f; do rm ${f}; done |
| 253 |
$ hg revert --no-backup -q --all |
| 254 |
$ hg qpush -q git |
| 255 |
now at: git |
| 256 |
$ hg qpush -q --move p3 |
| 257 |
now at: p3 |
| 258 |
|
| 259 |
$ hg status --rev "git^1" --rev . -arm |
| 260 |
M a |
| 261 |
A aa |
| 262 |
|
| 263 |
$ cd .. |
| 264 |
|