| 1 |
|
| 2 |
$ catpatch() { |
| 3 |
> cat $1 | sed -e "s/^\(# Parent \).*/\1/" |
| 4 |
> } |
| 5 |
$ echo "[extensions]" >> $HGRCPATH |
| 6 |
$ echo "mq=" >> $HGRCPATH |
| 7 |
$ runtest() { |
| 8 |
> hg init mq |
| 9 |
> cd mq |
| 10 |
> |
| 11 |
> echo a > a |
| 12 |
> hg ci -Ama |
| 13 |
> |
| 14 |
> echo '% qnew should refuse bad patch names' |
| 15 |
> hg qnew series |
| 16 |
> hg qnew status |
| 17 |
> hg qnew guards |
| 18 |
> hg qnew . |
| 19 |
> hg qnew .. |
| 20 |
> hg qnew .hgignore |
| 21 |
> hg qnew .mqfoo |
| 22 |
> hg qnew 'foo#bar' |
| 23 |
> hg qnew 'foo:bar' |
| 24 |
> hg qnew "`echo foo; echo bar`" |
| 25 |
> hg qnew ' foo' |
| 26 |
> hg qnew 'foo ' |
| 27 |
> |
| 28 |
> hg qinit -c |
| 29 |
> |
| 30 |
> echo '% qnew with name containing slash' |
| 31 |
> hg qnew foo/ |
| 32 |
> hg qnew foo/bar.patch |
| 33 |
> hg qnew foo |
| 34 |
> hg qseries |
| 35 |
> hg qpop |
| 36 |
> hg qdelete foo/bar.patch |
| 37 |
> |
| 38 |
> echo '% qnew with uncommitted changes' |
| 39 |
> echo a > somefile |
| 40 |
> hg add somefile |
| 41 |
> hg qnew uncommitted.patch |
| 42 |
> hg st |
| 43 |
> hg qseries |
| 44 |
> |
| 45 |
> echo '% qnew implies add' |
| 46 |
> hg -R .hg/patches st |
| 47 |
> |
| 48 |
> echo '% qnew missing' |
| 49 |
> hg qnew missing.patch missing |
| 50 |
> |
| 51 |
> echo '% qnew -m' |
| 52 |
> hg qnew -m 'foo bar' mtest.patch |
| 53 |
> catpatch .hg/patches/mtest.patch |
| 54 |
> |
| 55 |
> echo '% qnew twice' |
| 56 |
> hg qnew first.patch |
| 57 |
> hg qnew first.patch |
| 58 |
> |
| 59 |
> touch ../first.patch |
| 60 |
> hg qimport ../first.patch |
| 61 |
> |
| 62 |
> echo '% qnew -f from a subdirectory' |
| 63 |
> hg qpop -a |
| 64 |
> mkdir d |
| 65 |
> cd d |
| 66 |
> echo b > b |
| 67 |
> hg ci -Am t |
| 68 |
> echo b >> b |
| 69 |
> hg st |
| 70 |
> hg qnew -g -f p |
| 71 |
> catpatch ../.hg/patches/p |
| 72 |
> |
| 73 |
> echo '% qnew -u with no username configured' |
| 74 |
> HGUSER= hg qnew -u blue red |
| 75 |
> catpatch ../.hg/patches/red |
| 76 |
> |
| 77 |
> echo '% qnew -e -u with no username configured' |
| 78 |
> HGUSER= hg qnew -e -u chartreuse fucsia |
| 79 |
> catpatch ../.hg/patches/fucsia |
| 80 |
> |
| 81 |
> echo '% fail when trying to import a merge' |
| 82 |
> hg init merge |
| 83 |
> cd merge |
| 84 |
> touch a |
| 85 |
> hg ci -Am null |
| 86 |
> echo a >> a |
| 87 |
> hg ci -m a |
| 88 |
> hg up -r 0 |
| 89 |
> echo b >> a |
| 90 |
> hg ci -m b |
| 91 |
> hg merge -f 1 |
| 92 |
> hg resolve --mark a |
| 93 |
> hg qnew -f merge |
| 94 |
> |
| 95 |
> cd ../../.. |
| 96 |
> rm -r mq |
| 97 |
> } |
| 98 |
|
| 99 |
plain headers |
| 100 |
|
| 101 |
$ echo "[mq]" >> $HGRCPATH |
| 102 |
$ echo "plain=true" >> $HGRCPATH |
| 103 |
$ mkdir sandbox |
| 104 |
$ (cd sandbox ; runtest) |
| 105 |
adding a |
| 106 |
% qnew should refuse bad patch names |
| 107 |
abort: "series" cannot be used as the name of a patch |
| 108 |
abort: "status" cannot be used as the name of a patch |
| 109 |
abort: "guards" cannot be used as the name of a patch |
| 110 |
abort: "." cannot be used as the name of a patch |
| 111 |
abort: ".." cannot be used as the name of a patch |
| 112 |
abort: patch name cannot begin with ".hg" |
| 113 |
abort: patch name cannot begin with ".mq" |
| 114 |
abort: '#' cannot be used in the name of a patch |
| 115 |
abort: ':' cannot be used in the name of a patch |
| 116 |
abort: '\n' cannot be used in the name of a patch |
| 117 |
abort: patch name cannot begin or end with whitespace |
| 118 |
abort: patch name cannot begin or end with whitespace |
| 119 |
% qnew with name containing slash |
| 120 |
abort: path ends in directory separator: foo/ |
| 121 |
abort: "foo" already exists as a directory |
| 122 |
foo/bar.patch |
| 123 |
popping foo/bar.patch |
| 124 |
patch queue now empty |
| 125 |
% qnew with uncommitted changes |
| 126 |
uncommitted.patch |
| 127 |
% qnew implies add |
| 128 |
A .hgignore |
| 129 |
A series |
| 130 |
A uncommitted.patch |
| 131 |
% qnew missing |
| 132 |
abort: missing: * (glob) |
| 133 |
% qnew -m |
| 134 |
foo bar |
| 135 |
|
| 136 |
% qnew twice |
| 137 |
abort: patch "first.patch" already exists |
| 138 |
abort: patch "first.patch" already exists |
| 139 |
% qnew -f from a subdirectory |
| 140 |
popping first.patch |
| 141 |
popping mtest.patch |
| 142 |
popping uncommitted.patch |
| 143 |
patch queue now empty |
| 144 |
adding d/b |
| 145 |
M d/b |
| 146 |
diff --git a/d/b b/d/b |
| 147 |
--- a/d/b |
| 148 |
+++ b/d/b |
| 149 |
@@ -1,1 +1,2 @@ |
| 150 |
b |
| 151 |
+b |
| 152 |
% qnew -u with no username configured |
| 153 |
From: blue |
| 154 |
|
| 155 |
% qnew -e -u with no username configured |
| 156 |
From: chartreuse |
| 157 |
|
| 158 |
% fail when trying to import a merge |
| 159 |
adding a |
| 160 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 161 |
created new head |
| 162 |
merging a |
| 163 |
warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
| 164 |
0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
| 165 |
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
| 166 |
(no more unresolved files) |
| 167 |
abort: cannot manage merge changesets |
| 168 |
$ rm -r sandbox |
| 169 |
|
| 170 |
hg headers |
| 171 |
|
| 172 |
$ echo "plain=false" >> $HGRCPATH |
| 173 |
$ mkdir sandbox |
| 174 |
$ (cd sandbox ; runtest) |
| 175 |
adding a |
| 176 |
% qnew should refuse bad patch names |
| 177 |
abort: "series" cannot be used as the name of a patch |
| 178 |
abort: "status" cannot be used as the name of a patch |
| 179 |
abort: "guards" cannot be used as the name of a patch |
| 180 |
abort: "." cannot be used as the name of a patch |
| 181 |
abort: ".." cannot be used as the name of a patch |
| 182 |
abort: patch name cannot begin with ".hg" |
| 183 |
abort: patch name cannot begin with ".mq" |
| 184 |
abort: '#' cannot be used in the name of a patch |
| 185 |
abort: ':' cannot be used in the name of a patch |
| 186 |
abort: '\n' cannot be used in the name of a patch |
| 187 |
abort: patch name cannot begin or end with whitespace |
| 188 |
abort: patch name cannot begin or end with whitespace |
| 189 |
% qnew with name containing slash |
| 190 |
abort: path ends in directory separator: foo/ |
| 191 |
abort: "foo" already exists as a directory |
| 192 |
foo/bar.patch |
| 193 |
popping foo/bar.patch |
| 194 |
patch queue now empty |
| 195 |
% qnew with uncommitted changes |
| 196 |
uncommitted.patch |
| 197 |
% qnew implies add |
| 198 |
A .hgignore |
| 199 |
A series |
| 200 |
A uncommitted.patch |
| 201 |
% qnew missing |
| 202 |
abort: missing: * (glob) |
| 203 |
% qnew -m |
| 204 |
# HG changeset patch |
| 205 |
# Parent |
| 206 |
foo bar |
| 207 |
|
| 208 |
% qnew twice |
| 209 |
abort: patch "first.patch" already exists |
| 210 |
abort: patch "first.patch" already exists |
| 211 |
% qnew -f from a subdirectory |
| 212 |
popping first.patch |
| 213 |
popping mtest.patch |
| 214 |
popping uncommitted.patch |
| 215 |
patch queue now empty |
| 216 |
adding d/b |
| 217 |
M d/b |
| 218 |
# HG changeset patch |
| 219 |
# Parent |
| 220 |
|
| 221 |
diff --git a/d/b b/d/b |
| 222 |
--- a/d/b |
| 223 |
+++ b/d/b |
| 224 |
@@ -1,1 +1,2 @@ |
| 225 |
b |
| 226 |
+b |
| 227 |
% qnew -u with no username configured |
| 228 |
# HG changeset patch |
| 229 |
# User blue |
| 230 |
# Parent |
| 231 |
|
| 232 |
% qnew -e -u with no username configured |
| 233 |
# HG changeset patch |
| 234 |
# User chartreuse |
| 235 |
# Parent |
| 236 |
|
| 237 |
% fail when trying to import a merge |
| 238 |
adding a |
| 239 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 240 |
created new head |
| 241 |
merging a |
| 242 |
warning: conflicts while merging a! (edit, then use 'hg resolve --mark') |
| 243 |
0 files updated, 0 files merged, 0 files removed, 1 files unresolved |
| 244 |
use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon |
| 245 |
(no more unresolved files) |
| 246 |
abort: cannot manage merge changesets |
| 247 |
$ rm -r sandbox |
| 248 |
|
| 249 |
Test saving last-message.txt |
| 250 |
|
| 251 |
$ hg init repo |
| 252 |
$ cd repo |
| 253 |
|
| 254 |
$ cat > $TESTTMP/commitfailure.py <<EOF |
| 255 |
> from mercurial import error |
| 256 |
> def reposetup(ui, repo): |
| 257 |
> class commitfailure(repo.__class__): |
| 258 |
> def commit(self, *args, **kwargs): |
| 259 |
> raise error.Abort(b'emulating unexpected abort') |
| 260 |
> repo.__class__ = commitfailure |
| 261 |
> EOF |
| 262 |
$ cat >> .hg/hgrc <<EOF |
| 263 |
> [extensions] |
| 264 |
> # this failure occurs before editor invocation |
| 265 |
> commitfailure = $TESTTMP/commitfailure.py |
| 266 |
> EOF |
| 267 |
|
| 268 |
$ cat > $TESTTMP/editor.sh << EOF |
| 269 |
> echo "==== before editing" |
| 270 |
> cat \$1 |
| 271 |
> echo "====" |
| 272 |
> echo "test saving last-message.txt" >> \$1 |
| 273 |
> EOF |
| 274 |
|
| 275 |
(test that editor is not invoked before transaction starting) |
| 276 |
|
| 277 |
$ rm -f .hg/last-message.txt |
| 278 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch |
| 279 |
abort: emulating unexpected abort |
| 280 |
[255] |
| 281 |
$ test -f .hg/last-message.txt |
| 282 |
[1] |
| 283 |
|
| 284 |
(test that editor is invoked and commit message is saved into |
| 285 |
"last-message.txt") |
| 286 |
|
| 287 |
$ cat >> .hg/hgrc <<EOF |
| 288 |
> [extensions] |
| 289 |
> commitfailure = ! |
| 290 |
> [hooks] |
| 291 |
> # this failure occurs after editor invocation |
| 292 |
> pretxncommit.unexpectedabort = false |
| 293 |
> EOF |
| 294 |
|
| 295 |
$ rm -f .hg/last-message.txt |
| 296 |
$ hg status |
| 297 |
$ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch |
| 298 |
==== before editing |
| 299 |
|
| 300 |
|
| 301 |
HG: Enter commit message. Lines beginning with 'HG:' are removed. |
| 302 |
HG: Leave message empty to use default message. |
| 303 |
HG: -- |
| 304 |
HG: user: test |
| 305 |
HG: branch 'default' |
| 306 |
HG: no files changed |
| 307 |
==== |
| 308 |
transaction abort! |
| 309 |
rollback completed |
| 310 |
note: commit message saved in .hg/last-message.txt |
| 311 |
note: use 'hg commit --logfile .hg/last-message.txt --edit' to reuse it |
| 312 |
abort: pretxncommit.unexpectedabort hook exited with status 1 |
| 313 |
[40] |
| 314 |
$ cat .hg/last-message.txt |
| 315 |
|
| 316 |
|
| 317 |
test saving last-message.txt |
| 318 |
|
| 319 |
$ cat >> .hg/hgrc <<EOF |
| 320 |
> [hooks] |
| 321 |
> pretxncommit.unexpectedabort = |
| 322 |
> EOF |