| 1 |
$ cat > writelines.py <<EOF |
| 2 |
> import sys |
| 3 |
> encode = lambda x: x.encode('utf-8').decode('unicode_escape').encode('utf-8') |
| 4 |
> path = sys.argv[1] |
| 5 |
> args = sys.argv[2:] |
| 6 |
> assert (len(args) % 2) == 0 |
| 7 |
> |
| 8 |
> f = open(path, 'wb') |
| 9 |
> for i in range(len(args) // 2): |
| 10 |
> count, s = args[2 * i:2 * i + 2] |
| 11 |
> count = int(count) |
| 12 |
> s = encode(s) |
| 13 |
> f.write(s * count) |
| 14 |
> f.close() |
| 15 |
> |
| 16 |
> EOF |
| 17 |
> cat <<EOF >> $HGRCPATH |
| 18 |
> [extensions] |
| 19 |
> mq = |
| 20 |
> [diff] |
| 21 |
> git = 1 |
| 22 |
> EOF |
| 23 |
$ hg init repo |
| 24 |
$ cd repo |
| 25 |
|
| 26 |
qimport without file or revision |
| 27 |
|
| 28 |
$ hg qimport |
| 29 |
abort: no files or revisions specified |
| 30 |
[255] |
| 31 |
|
| 32 |
qimport non-existing-file |
| 33 |
|
| 34 |
$ hg qimport non-existing-file |
| 35 |
abort: unable to read file non-existing-file |
| 36 |
[255] |
| 37 |
|
| 38 |
qimport null revision |
| 39 |
|
| 40 |
$ hg qimport -r null |
| 41 |
abort: revision -1 is not mutable |
| 42 |
(see 'hg help phases' for details) |
| 43 |
[255] |
| 44 |
$ hg qseries |
| 45 |
|
| 46 |
import email |
| 47 |
|
| 48 |
$ hg qimport --push -n email - <<EOF |
| 49 |
> From: Username in email <[email protected]> |
| 50 |
> Subject: [PATCH] Message in email |
| 51 |
> Date: Fri, 02 Jan 1970 00:00:00 +0000 |
| 52 |
> |
| 53 |
> Text before patch. |
| 54 |
> |
| 55 |
> # HG changeset patch |
| 56 |
> # User Username in patch <[email protected]> |
| 57 |
> # Date 0 0 |
| 58 |
> # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220 |
| 59 |
> # Parent 0000000000000000000000000000000000000000 |
| 60 |
> First line of commit message. |
| 61 |
> |
| 62 |
> More text in commit message. |
| 63 |
> --- confuse the diff detection |
| 64 |
> |
| 65 |
> diff --git a/x b/x |
| 66 |
> new file mode 100644 |
| 67 |
> --- /dev/null |
| 68 |
> +++ b/x |
| 69 |
> @@ -0,0 +1,1 @@ |
| 70 |
> +new file |
| 71 |
> Text after patch. |
| 72 |
> |
| 73 |
> EOF |
| 74 |
adding email to series file |
| 75 |
applying email |
| 76 |
now at: email |
| 77 |
|
| 78 |
hg tip -v |
| 79 |
|
| 80 |
$ hg tip -v |
| 81 |
changeset: 0:1a706973a7d8 |
| 82 |
tag: email |
| 83 |
tag: qbase |
| 84 |
tag: qtip |
| 85 |
tag: tip |
| 86 |
user: Username in patch <[email protected]> |
| 87 |
date: Thu Jan 01 00:00:00 1970 +0000 |
| 88 |
files: x |
| 89 |
description: |
| 90 |
First line of commit message. |
| 91 |
|
| 92 |
More text in commit message. |
| 93 |
|
| 94 |
|
| 95 |
$ hg qpop |
| 96 |
popping email |
| 97 |
patch queue now empty |
| 98 |
$ hg qdelete email |
| 99 |
|
| 100 |
import URL |
| 101 |
|
| 102 |
$ echo foo >> foo |
| 103 |
$ hg add foo |
| 104 |
$ hg diff > url.diff |
| 105 |
$ hg revert --no-backup foo |
| 106 |
$ rm foo |
| 107 |
|
| 108 |
Under unix: file:///foobar/blah |
| 109 |
Under windows: file:///c:/foobar/blah |
| 110 |
|
| 111 |
$ patchurl=`pwd | tr '\\\\' /`/url.diff |
| 112 |
$ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl" |
| 113 |
$ hg qimport file://"$patchurl" |
| 114 |
adding url.diff to series file |
| 115 |
$ rm url.diff |
| 116 |
$ hg qun |
| 117 |
url.diff |
| 118 |
|
| 119 |
import patch that already exists |
| 120 |
|
| 121 |
$ echo foo2 >> foo |
| 122 |
$ hg add foo |
| 123 |
$ hg diff > ../url.diff |
| 124 |
$ hg revert --no-backup foo |
| 125 |
$ rm foo |
| 126 |
$ hg qimport ../url.diff |
| 127 |
abort: patch "url.diff" already exists |
| 128 |
[255] |
| 129 |
$ hg qpush |
| 130 |
applying url.diff |
| 131 |
now at: url.diff |
| 132 |
$ cat foo |
| 133 |
foo |
| 134 |
$ hg qpop |
| 135 |
popping url.diff |
| 136 |
patch queue now empty |
| 137 |
|
| 138 |
qimport -f |
| 139 |
|
| 140 |
$ hg qimport -f ../url.diff |
| 141 |
adding url.diff to series file |
| 142 |
$ hg qpush |
| 143 |
applying url.diff |
| 144 |
now at: url.diff |
| 145 |
$ cat foo |
| 146 |
foo2 |
| 147 |
$ hg qpop |
| 148 |
popping url.diff |
| 149 |
patch queue now empty |
| 150 |
|
| 151 |
build diff with CRLF |
| 152 |
|
| 153 |
$ "$PYTHON" ../writelines.py b 5 'a\n' 5 'a\r\n' |
| 154 |
$ hg ci -Am addb |
| 155 |
adding b |
| 156 |
$ "$PYTHON" ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n' |
| 157 |
$ hg diff > b.diff |
| 158 |
$ hg up -C |
| 159 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 160 |
|
| 161 |
qimport CRLF diff |
| 162 |
|
| 163 |
$ hg qimport b.diff |
| 164 |
adding b.diff to series file |
| 165 |
$ hg qpush |
| 166 |
applying b.diff |
| 167 |
now at: b.diff |
| 168 |
|
| 169 |
try to import --push |
| 170 |
|
| 171 |
$ cat > appendfoo.diff <<EOF |
| 172 |
> append foo |
| 173 |
> |
| 174 |
> diff -r 07f494440405 -r 261500830e46 baz |
| 175 |
> --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
| 176 |
> +++ b/baz Thu Jan 01 00:00:00 1970 +0000 |
| 177 |
> @@ -0,0 +1,1 @@ |
| 178 |
> +foo |
| 179 |
> EOF |
| 180 |
|
| 181 |
$ cat > appendbar.diff <<EOF |
| 182 |
> append bar |
| 183 |
> |
| 184 |
> diff -r 07f494440405 -r 261500830e46 baz |
| 185 |
> --- a/baz Thu Jan 01 00:00:00 1970 +0000 |
| 186 |
> +++ b/baz Thu Jan 01 00:00:00 1970 +0000 |
| 187 |
> @@ -1,1 +1,2 @@ |
| 188 |
> foo |
| 189 |
> +bar |
| 190 |
> EOF |
| 191 |
|
| 192 |
$ hg qimport --push appendfoo.diff appendbar.diff |
| 193 |
adding appendfoo.diff to series file |
| 194 |
adding appendbar.diff to series file |
| 195 |
applying appendfoo.diff |
| 196 |
applying appendbar.diff |
| 197 |
now at: appendbar.diff |
| 198 |
$ hg qfin -a |
| 199 |
patch b.diff finalized without changeset message |
| 200 |
$ touch .hg/patches/append_foo |
| 201 |
$ hg qimport -r 'p1(.)::' |
| 202 |
$ hg qapplied |
| 203 |
append_foo__1 |
| 204 |
append_bar |
| 205 |
$ hg qfin -a |
| 206 |
$ rm .hg/patches/append_foo |
| 207 |
$ hg qimport -r 'p1(.)::' -P |
| 208 |
$ hg qpop -a |
| 209 |
popping append_bar |
| 210 |
popping append_foo |
| 211 |
patch queue now empty |
| 212 |
$ hg qdel append_foo |
| 213 |
$ hg qdel -k append_bar |
| 214 |
|
| 215 |
qimport -e |
| 216 |
|
| 217 |
$ hg qimport -e append_bar |
| 218 |
adding append_bar to series file |
| 219 |
$ hg qdel -k append_bar |
| 220 |
|
| 221 |
qimport -e --name newname oldexisitingpatch |
| 222 |
|
| 223 |
$ hg qimport -e --name this-name-is-better append_bar |
| 224 |
renaming append_bar to this-name-is-better |
| 225 |
adding this-name-is-better to series file |
| 226 |
$ hg qser |
| 227 |
this-name-is-better |
| 228 |
url.diff |
| 229 |
|
| 230 |
qimport -e --name without --force |
| 231 |
|
| 232 |
$ cp .hg/patches/this-name-is-better .hg/patches/3.diff |
| 233 |
$ hg qimport -e --name this-name-is-better 3.diff |
| 234 |
abort: patch "this-name-is-better" already exists |
| 235 |
[255] |
| 236 |
$ hg qser |
| 237 |
this-name-is-better |
| 238 |
url.diff |
| 239 |
|
| 240 |
qimport -e --name with --force |
| 241 |
|
| 242 |
$ hg qimport --force -e --name this-name-is-better 3.diff |
| 243 |
renaming 3.diff to this-name-is-better |
| 244 |
adding this-name-is-better to series file |
| 245 |
$ hg qser |
| 246 |
this-name-is-better |
| 247 |
url.diff |
| 248 |
|
| 249 |
import patch of bad filename |
| 250 |
|
| 251 |
$ touch '../ bad.diff' |
| 252 |
$ hg qimport '../ bad.diff' |
| 253 |
abort: patch name cannot begin or end with whitespace |
| 254 |
[255] |
| 255 |
$ touch '.hg/patches/ bad.diff' |
| 256 |
$ hg qimport -e ' bad.diff' |
| 257 |
abort: patch name cannot begin or end with whitespace |
| 258 |
[255] |
| 259 |
|
| 260 |
qimport with bad name, should abort before reading file |
| 261 |
|
| 262 |
$ hg qimport non-existent-file --name .hg |
| 263 |
abort: patch name cannot begin with ".hg" |
| 264 |
[255] |
| 265 |
$ hg qimport non-existent-file --name ' foo' |
| 266 |
abort: patch name cannot begin or end with whitespace |
| 267 |
[255] |
| 268 |
$ hg qimport non-existent-file --name 'foo ' |
| 269 |
abort: patch name cannot begin or end with whitespace |
| 270 |
[255] |
| 271 |
|
| 272 |
qimport http:// patch with leading slashes in url |
| 273 |
|
| 274 |
set up hgweb |
| 275 |
|
| 276 |
$ cd .. |
| 277 |
$ hg init served |
| 278 |
$ cd served |
| 279 |
$ echo a > a |
| 280 |
$ hg ci -Am patch |
| 281 |
adding a |
| 282 |
$ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log |
| 283 |
$ cat hg.pid >> $DAEMON_PIDS |
| 284 |
|
| 285 |
$ cd ../repo |
| 286 |
$ hg qimport http://localhost:$HGPORT/raw-rev/0/// |
| 287 |
adding 0 to series file |
| 288 |
|
| 289 |
check qimport phase: |
| 290 |
|
| 291 |
$ hg -q qpush |
| 292 |
now at: 0 |
| 293 |
$ hg phase qparent |
| 294 |
1: draft |
| 295 |
$ hg qimport -r qparent |
| 296 |
$ hg phase qbase |
| 297 |
1: draft |
| 298 |
$ hg qfinish qbase |
| 299 |
$ echo '[mq]' >> $HGRCPATH |
| 300 |
$ echo 'secret=true' >> $HGRCPATH |
| 301 |
$ hg qimport -r qparent |
| 302 |
$ hg phase qbase |
| 303 |
1: secret |
| 304 |
|
| 305 |
$ cd .. |
| 306 |
|
| 307 |
$ killdaemons.py |
| 308 |
|
| 309 |
check patch name generation for non-alpha-numeric summary line |
| 310 |
|
| 311 |
$ cd repo |
| 312 |
|
| 313 |
$ hg qpop -a -q |
| 314 |
patch queue now empty |
| 315 |
$ hg qseries -v |
| 316 |
0 U imported_patch_b_diff |
| 317 |
1 U 0 |
| 318 |
2 U this-name-is-better |
| 319 |
3 U url.diff |
| 320 |
|
| 321 |
$ echo bb >> b |
| 322 |
$ hg commit -m '==++--==' |
| 323 |
|
| 324 |
$ hg qimport -r tip |
| 325 |
$ hg qseries -v |
| 326 |
0 A 1.diff |
| 327 |
1 U imported_patch_b_diff |
| 328 |
2 U 0 |
| 329 |
3 U this-name-is-better |
| 330 |
4 U url.diff |
| 331 |
|
| 332 |
check reserved patch names |
| 333 |
|
| 334 |
$ hg qpop -qa |
| 335 |
patch queue now empty |
| 336 |
$ echo >> b |
| 337 |
$ hg commit -m 'status' |
| 338 |
$ echo >> b |
| 339 |
$ hg commit -m '.' |
| 340 |
$ echo >> b |
| 341 |
$ hg commit -m 'taken' |
| 342 |
$ mkdir .hg/patches/taken |
| 343 |
$ touch .hg/patches/taken__1 |
| 344 |
$ hg qimport -r -3:: |
| 345 |
$ hg qap |
| 346 |
1.diff__1 |
| 347 |
2.diff |
| 348 |
taken__2 |
| 349 |
|
| 350 |
check very long patch name |
| 351 |
|
| 352 |
$ hg qpop -qa |
| 353 |
patch queue now empty |
| 354 |
$ echo >> b |
| 355 |
$ hg commit -m 'abcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' |
| 356 |
$ hg qimport -r . |
| 357 |
$ hg qap |
| 358 |
abcdefghi_pqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi_pqrstuvwxyzabcdefg |