| 1 |
Environment setup for MQ |
| 2 |
|
| 3 |
$ echo "[extensions]" >> $HGRCPATH |
| 4 |
$ echo "mq=" >> $HGRCPATH |
| 5 |
$ cat >> $HGRCPATH <<EOF |
| 6 |
> [defaults] |
| 7 |
> # explicit date to commit with fixed hashid |
| 8 |
> qnew = -d "0 0" |
| 9 |
> qrefresh = -d "0 0" |
| 10 |
> qfold = -d "0 0" |
| 11 |
> EOF |
| 12 |
$ hg init |
| 13 |
$ hg qinit |
| 14 |
|
| 15 |
Should fail if no patches applied |
| 16 |
(this tests also that editor is not invoked if '--edit' is not |
| 17 |
specified) |
| 18 |
|
| 19 |
$ hg qrefresh |
| 20 |
no patches applied |
| 21 |
[1] |
| 22 |
$ hg qrefresh -e |
| 23 |
no patches applied |
| 24 |
[1] |
| 25 |
$ hg qnew -m "First commit message" first-patch |
| 26 |
$ echo aaaa > file |
| 27 |
$ hg add file |
| 28 |
$ HGEDITOR=cat hg qrefresh |
| 29 |
|
| 30 |
Should display 'First commit message' |
| 31 |
|
| 32 |
$ hg log -l1 --template "{desc}\n" |
| 33 |
First commit message |
| 34 |
|
| 35 |
Testing changing message with -m |
| 36 |
(this tests also that '--edit' can be used with '--message', and |
| 37 |
that '[committemplate] changeset' definition and commit log specific |
| 38 |
template keyword 'extramsg' work well) |
| 39 |
|
| 40 |
$ cat >> .hg/hgrc <<EOF |
| 41 |
> [committemplate] |
| 42 |
> listupfiles = {file_adds % |
| 43 |
> "HG: added {file}\n" }{file_mods % |
| 44 |
> "HG: changed {file}\n" }{file_dels % |
| 45 |
> "HG: removed {file}\n" }{if(files, "", |
| 46 |
> "HG: no files changed\n")} |
| 47 |
> |
| 48 |
> changeset = HG: this is customized commit template |
| 49 |
> {desc}\n\n |
| 50 |
> HG: Enter commit message. Lines beginning with 'HG:' are removed. |
| 51 |
> HG: {extramsg} |
| 52 |
> HG: -- |
| 53 |
> HG: user: {author} |
| 54 |
> HG: branch '{branch}'\n{listupfiles} |
| 55 |
> EOF |
| 56 |
|
| 57 |
$ echo bbbb > file |
| 58 |
$ HGEDITOR=cat hg qrefresh -m "Second commit message" -e |
| 59 |
HG: this is customized commit template |
| 60 |
Second commit message |
| 61 |
|
| 62 |
|
| 63 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
| 64 |
HG: Leave message empty to use default message. |
| 65 |
HG: -- |
| 66 |
HG: user: test |
| 67 |
HG: branch 'default' |
| 68 |
HG: added file |
| 69 |
|
| 70 |
$ cat >> .hg/hgrc <<EOF |
| 71 |
> # disable customizing for subsequent tests |
| 72 |
> [committemplate] |
| 73 |
> changeset = |
| 74 |
> EOF |
| 75 |
|
| 76 |
Should display 'Second commit message' |
| 77 |
|
| 78 |
$ hg log -l1 --template "{desc}\n" |
| 79 |
Second commit message |
| 80 |
|
| 81 |
Testing changing message with -l |
| 82 |
|
| 83 |
$ echo "Third commit message" > logfile |
| 84 |
$ echo " This is the 3rd log message" >> logfile |
| 85 |
$ echo bbbb > file |
| 86 |
$ hg qrefresh -l logfile |
| 87 |
|
| 88 |
Should display 'Third commit message\\\n This is the 3rd log message' |
| 89 |
|
| 90 |
$ hg log -l1 --template "{desc}\n" |
| 91 |
Third commit message |
| 92 |
This is the 3rd log message |
| 93 |
|
| 94 |
Testing changing message with -l- |
| 95 |
|
| 96 |
$ hg qnew -m "First commit message" second-patch |
| 97 |
$ echo aaaa > file2 |
| 98 |
$ hg add file2 |
| 99 |
$ echo bbbb > file2 |
| 100 |
$ (echo "Fifth commit message"; echo " This is the 5th log message") | hg qrefresh -l- |
| 101 |
|
| 102 |
Should display 'Fifth commit message\\\n This is the 5th log message' |
| 103 |
|
| 104 |
$ hg log -l1 --template "{desc}\n" |
| 105 |
Fifth commit message |
| 106 |
This is the 5th log message |
| 107 |
|
| 108 |
Test saving last-message.txt: |
| 109 |
|
| 110 |
$ cat > $TESTTMP/editor.sh << EOF |
| 111 |
> echo "==== before editing" |
| 112 |
> cat \$1 |
| 113 |
> echo "====" |
| 114 |
> (echo; echo "test saving last-message.txt") >> \$1 |
| 115 |
> EOF |
| 116 |
|
| 117 |
$ cat > $TESTTMP/commitfailure.py <<EOF |
| 118 |
> from mercurial import error |
| 119 |
> def reposetup(ui, repo): |
| 120 |
> class commitfailure(repo.__class__): |
| 121 |
> def commit(self, *args, **kwargs): |
| 122 |
> raise error.Abort(b'emulating unexpected abort') |
| 123 |
> repo.__class__ = commitfailure |
| 124 |
> EOF |
| 125 |
|
| 126 |
$ cat >> .hg/hgrc <<EOF |
| 127 |
> [extensions] |
| 128 |
> # this failure occurs before editor invocation |
| 129 |
> commitfailure = $TESTTMP/commitfailure.py |
| 130 |
> EOF |
| 131 |
|
| 132 |
$ hg qapplied |
| 133 |
first-patch |
| 134 |
second-patch |
| 135 |
$ hg tip --template "{files}\n" |
| 136 |
file2 |
| 137 |
|
| 138 |
(test that editor is not invoked before transaction starting) |
| 139 |
|
| 140 |
$ rm -f .hg/last-message.txt |
| 141 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e |
| 142 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 143 |
abort: emulating unexpected abort |
| 144 |
[255] |
| 145 |
$ test -f .hg/last-message.txt |
| 146 |
[1] |
| 147 |
|
| 148 |
(reset applied patches and directory status) |
| 149 |
|
| 150 |
$ cat >> .hg/hgrc <<EOF |
| 151 |
> [extensions] |
| 152 |
> commitfailure = ! |
| 153 |
> EOF |
| 154 |
|
| 155 |
$ hg qapplied |
| 156 |
first-patch |
| 157 |
$ hg status -A file2 |
| 158 |
? file2 |
| 159 |
$ rm file2 |
| 160 |
$ hg qpush -q second-patch |
| 161 |
now at: second-patch |
| 162 |
|
| 163 |
(test that editor is invoked and commit message is saved into |
| 164 |
"last-message.txt") |
| 165 |
|
| 166 |
$ cat >> .hg/hgrc <<EOF |
| 167 |
> [hooks] |
| 168 |
> # this failure occurs after editor invocation |
| 169 |
> pretxncommit.unexpectedabort = false |
| 170 |
> EOF |
| 171 |
|
| 172 |
$ rm -f .hg/last-message.txt |
| 173 |
$ hg status --rev "second-patch^1" -arm |
| 174 |
A file2 |
| 175 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qrefresh -e |
| 176 |
==== before editing |
| 177 |
Fifth commit message |
| 178 |
This is the 5th log message |
| 179 |
|
| 180 |
|
| 181 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
| 182 |
HG: Leave message empty to use default message. |
| 183 |
HG: -- |
| 184 |
HG: user: test |
| 185 |
HG: branch 'default' |
| 186 |
HG: added file2 |
| 187 |
==== |
| 188 |
note: commit message saved in .hg/last-message.txt |
| 189 |
note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it |
| 190 |
transaction abort! |
| 191 |
rollback completed |
| 192 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 193 |
abort: pretxncommit.unexpectedabort hook exited with status 1 |
| 194 |
[40] |
| 195 |
$ cat .hg/last-message.txt |
| 196 |
Fifth commit message |
| 197 |
This is the 5th log message |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
test saving last-message.txt |
| 202 |
|
| 203 |
Test visibility of in-memory dirstate changes outside transaction to |
| 204 |
external process |
| 205 |
|
| 206 |
$ cat > $TESTTMP/checkvisibility.sh <<EOF |
| 207 |
> echo "====" |
| 208 |
> hg parents --template "{rev}:{node|short}\n" |
| 209 |
> hg status -arm |
| 210 |
> echo "====" |
| 211 |
> EOF |
| 212 |
|
| 213 |
== test visibility to external editor |
| 214 |
|
| 215 |
$ hg update -C -q first-patch |
| 216 |
$ rm -f file2 |
| 217 |
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= |
| 218 |
now at: second-patch |
| 219 |
$ echo bbbb >> file2 |
| 220 |
|
| 221 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 222 |
==== |
| 223 |
1:e30108269082 |
| 224 |
M file2 |
| 225 |
==== |
| 226 |
|
| 227 |
$ HGEDITOR="sh \"$TESTTMP/checkvisibility.sh\"" hg qrefresh -e |
| 228 |
==== |
| 229 |
0:25e397dabed2 |
| 230 |
A file2 |
| 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 |
|
| 240 |
(rebuilding at failure of qrefresh bases on rev #0, and it causes |
| 241 |
dropping status of "file2") |
| 242 |
|
| 243 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 244 |
==== |
| 245 |
0:25e397dabed2 |
| 246 |
==== |
| 247 |
|
| 248 |
== test visibility to precommit external hook |
| 249 |
|
| 250 |
$ hg update -C -q |
| 251 |
$ rm -f file2 |
| 252 |
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= |
| 253 |
now at: second-patch |
| 254 |
$ echo bbbb >> file2 |
| 255 |
|
| 256 |
$ cat >> .hg/hgrc <<EOF |
| 257 |
> [hooks] |
| 258 |
> precommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" |
| 259 |
> EOF |
| 260 |
|
| 261 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 262 |
==== |
| 263 |
1:e30108269082 |
| 264 |
M file2 |
| 265 |
==== |
| 266 |
|
| 267 |
$ hg qrefresh |
| 268 |
==== |
| 269 |
0:25e397dabed2 |
| 270 |
A file2 |
| 271 |
==== |
| 272 |
transaction abort! |
| 273 |
rollback completed |
| 274 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 275 |
abort: pretxncommit.unexpectedabort hook exited with status 1 |
| 276 |
[40] |
| 277 |
|
| 278 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 279 |
==== |
| 280 |
0:25e397dabed2 |
| 281 |
==== |
| 282 |
|
| 283 |
$ cat >> .hg/hgrc <<EOF |
| 284 |
> [hooks] |
| 285 |
> precommit.checkvisibility = |
| 286 |
> EOF |
| 287 |
|
| 288 |
== test visibility to pretxncommit external hook |
| 289 |
|
| 290 |
$ hg update -C -q |
| 291 |
$ rm -f file2 |
| 292 |
$ hg qpush -q second-patch --config hooks.pretxncommit.unexpectedabort= |
| 293 |
now at: second-patch |
| 294 |
$ echo bbbb >> file2 |
| 295 |
|
| 296 |
$ cat >> .hg/hgrc <<EOF |
| 297 |
> [hooks] |
| 298 |
> pretxncommit.checkvisibility = sh "$TESTTMP/checkvisibility.sh" |
| 299 |
> # make checkvisibility run before unexpectedabort |
| 300 |
> priority.pretxncommit.checkvisibility = 10 |
| 301 |
> EOF |
| 302 |
|
| 303 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 304 |
==== |
| 305 |
1:e30108269082 |
| 306 |
M file2 |
| 307 |
==== |
| 308 |
|
| 309 |
$ hg qrefresh |
| 310 |
==== |
| 311 |
0:25e397dabed2 |
| 312 |
A file2 |
| 313 |
==== |
| 314 |
transaction abort! |
| 315 |
rollback completed |
| 316 |
qrefresh interrupted while patch was popped! (revert --all, qpush to recover) |
| 317 |
abort: pretxncommit.unexpectedabort hook exited with status 1 |
| 318 |
[40] |
| 319 |
|
| 320 |
$ sh "$TESTTMP/checkvisibility.sh" |
| 321 |
==== |
| 322 |
0:25e397dabed2 |
| 323 |
==== |
| 324 |
|
| 325 |
$ cat >> .hg/hgrc <<EOF |
| 326 |
> [hooks] |
| 327 |
> pretxncommit.checkvisibility = |
| 328 |
> EOF |