1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
|
#testcases secret draft
Load commonly used test logic
$ . "$TESTDIR/testutil"
$ cat >> $HGRCPATH <<EOF
> [templates]
> p = {rev}|{phase}|{bookmarks}|{tags}\n
> EOF
#if secret
The phases setting should not affect hg-git
$ cat >> $HGRCPATH <<EOF
> [phases]
> new-commit = secret
> EOF
#endif
set up a git repo with some commits, branches and a tag
$ git init -q gitrepo
$ cd gitrepo
$ echo alpha > alpha
$ git add alpha
$ fn_git_commit -m 'add alpha'
$ git tag t_alpha
$ git checkout -qb beta
$ echo beta > beta
$ git add beta
$ fn_git_commit -m 'add beta'
$ git checkout -qb delta master
$ echo delta > delta
$ git add delta
$ fn_git_commit -m 'add delta'
$ cd ..
pull without a name
$ hg init hgrepo
$ cd hgrepo
$ hg pull ../gitrepo
pulling from ../gitrepo
importing 3 git commits
adding bookmark beta
adding bookmark delta
adding bookmark master
new changesets ff7a2f2d8d70:678ebee93e38 (3 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ git --git-dir .hg/git for-each-ref
7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 commit refs/tags/t_alpha
$ hg log -Tp
2|draft|delta|tip
1|draft|beta|
0|draft|master|t_alpha
$ cd ..
$ rm -rf hgrepo
pull with an implied name
$ hg init hgrepo
$ cd hgrepo
$ echo "[paths]" >> .hg/hgrc
$ echo "default=$TESTTMP/gitrepo" >> .hg/hgrc
$ hg pull ../gitrepo
pulling from ../gitrepo
importing 3 git commits
adding bookmark beta
adding bookmark delta
adding bookmark master
new changesets ff7a2f2d8d70:678ebee93e38 (3 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ git --git-dir .hg/git for-each-ref
9497a4ee62e16ee641860d7677cdb2589ea15554 commit refs/remotes/default/beta
8cbeb817785fe2676ab0eda570534702b6b6f9cf commit refs/remotes/default/delta
7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 commit refs/remotes/default/master
7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 commit refs/tags/t_alpha
$ hg log -Tp
2|draft|delta|default/delta tip
1|draft|beta|default/beta
0|draft|master|default/master t_alpha
$ cd ..
$ rm -rf hgrepo
pull with an explicit name
$ hg init hgrepo
$ cd hgrepo
$ echo "[paths]" >> .hg/hgrc
$ echo "default=$TESTTMP/gitrepo" >> .hg/hgrc
$ hg pull
pulling from $TESTTMP/gitrepo
importing 3 git commits
adding bookmark beta
adding bookmark delta
adding bookmark master
new changesets ff7a2f2d8d70:678ebee93e38 (3 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ git --git-dir .hg/git for-each-ref
9497a4ee62e16ee641860d7677cdb2589ea15554 commit refs/remotes/default/beta
8cbeb817785fe2676ab0eda570534702b6b6f9cf commit refs/remotes/default/delta
7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 commit refs/remotes/default/master
7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 commit refs/tags/t_alpha
$ hg log -Tp
2|draft|delta|default/delta tip
1|draft|beta|default/beta
0|draft|master|default/master t_alpha
$ cd ..
$ rm -rf hgrepo
pull a tag
$ hg init hgrepo
$ echo "[paths]" >> hgrepo/.hg/hgrc
$ echo "default=$TESTTMP/gitrepo" >> hgrepo/.hg/hgrc
$ hg -R hgrepo pull -r t_alpha
pulling from $TESTTMP/gitrepo
importing 1 git commits
adding bookmark master
new changesets ff7a2f2d8d70 (1 drafts)
(run 'hg update' to get a working copy)
$ hg -R hgrepo update t_alpha
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg log -Tp -R hgrepo
0|draft|master|default/master t_alpha tip
no-op pull
$ hg -R hgrepo pull -r t_alpha
pulling from $TESTTMP/gitrepo
no changes found
no-op pull with added bookmark
$ cd gitrepo
$ git checkout -qb epsilon t_alpha
$ cd ..
$ hg -R hgrepo pull -r epsilon
pulling from $TESTTMP/gitrepo
no changes found
adding bookmark epsilon
pull something that doesn't exist
$ hg -R hgrepo pull -r kaflaflibob
pulling from $TESTTMP/gitrepo
abort: unknown revision 'kaflaflibob'!? (re)
[10]
pull an ambiguous reference
$ GIT_DIR=gitrepo/.git git branch t_alpha t_alpha
$ hg -R hgrepo pull -r t_alpha
pulling from $TESTTMP/gitrepo
abort: ambiguous reference t_alpha: refs/heads/t_alpha, refs/tags/t_alpha!? (re)
[10]
$ GIT_DIR=gitrepo/.git git branch -qD t_alpha
pull a branch
$ hg -R hgrepo pull -r beta
pulling from $TESTTMP/gitrepo
importing 1 git commits
adding bookmark beta
new changesets 7fe02317c63d (1 drafts)
(run 'hg update' to get a working copy)
$ hg -R hgrepo log --graph --template=phases
o changeset: 1:7fe02317c63d
| bookmark: beta
| tag: default/beta
| tag: tip
| phase: draft
| user: test <test@example.org>
| date: Mon Jan 01 00:00:11 2007 +0000
| summary: add beta
|
@ changeset: 0:ff7a2f2d8d70
bookmark: epsilon
bookmark: master
tag: default/epsilon
tag: default/master
tag: t_alpha
phase: draft
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: add alpha
no-op pull should affect phases
$ hg -R hgrepo phase -fs beta
$ hg -R hgrepo pull -r beta
pulling from $TESTTMP/gitrepo
no changes found
$ hg -R hgrepo phase beta
1: draft
add another commit and tag to the git repo
$ cd gitrepo
$ git checkout -q beta
$ git tag t_beta
$ git checkout -q master
$ echo gamma > gamma
$ git add gamma
$ fn_git_commit -m 'add gamma'
$ cd ..
pull everything else
$ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo
importing 2 git commits
adding bookmark delta
updating bookmark master
new changesets 678ebee93e38:6f898ad1f3e1 (2 drafts)
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg -R hgrepo log --graph --template=phases
o changeset: 3:6f898ad1f3e1
| bookmark: master
| tag: default/master
| tag: tip
| phase: draft
| parent: 0:ff7a2f2d8d70
| user: test <test@example.org>
| date: Mon Jan 01 00:00:13 2007 +0000
| summary: add gamma
|
| o changeset: 2:678ebee93e38
|/ bookmark: delta
| tag: default/delta
| phase: draft
| parent: 0:ff7a2f2d8d70
| user: test <test@example.org>
| date: Mon Jan 01 00:00:12 2007 +0000
| summary: add delta
|
| o changeset: 1:7fe02317c63d
|/ bookmark: beta
| tag: default/beta
| tag: t_beta
| phase: draft
| user: test <test@example.org>
| date: Mon Jan 01 00:00:11 2007 +0000
| summary: add beta
|
@ changeset: 0:ff7a2f2d8d70
bookmark: epsilon
tag: default/epsilon
tag: t_alpha
phase: draft
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: add alpha
add a merge to the git repo, and delete the branch
$ cd gitrepo
$ git merge -q -m "Merge branch 'beta'" beta
$ git show --oneline
8642e88 Merge branch 'beta'
$ git branch -d beta
Deleted branch beta (was 9497a4e).
$ cd ..
pull the merge
$ hg -R hgrepo tags | grep default/beta
default/beta 1:7fe02317c63d
$ hg -R hgrepo pull --config git.pull-prune-remote-branches=false
pulling from $TESTTMP/gitrepo
importing 1 git commits
updating bookmark master
deleting bookmark beta
new changesets a02330f767a4 (1 drafts)
(run 'hg update' to get a working copy)
$ hg -R hgrepo tags | grep default/beta
default/beta 1:7fe02317c63d
$ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo
no changes found
$ hg -R hgrepo tags | grep default/beta
[1]
$ hg -R hgrepo log --graph
o changeset: 4:a02330f767a4
|\ bookmark: master
| | tag: default/master
| | tag: tip
| | parent: 3:6f898ad1f3e1
| | parent: 1:7fe02317c63d
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:13 2007 +0000
| | summary: Merge branch 'beta'
| |
| o changeset: 3:6f898ad1f3e1
| | parent: 0:ff7a2f2d8d70
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:13 2007 +0000
| | summary: add gamma
| |
| | o changeset: 2:678ebee93e38
| |/ bookmark: delta
| | tag: default/delta
| | parent: 0:ff7a2f2d8d70
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:12 2007 +0000
| | summary: add delta
| |
o | changeset: 1:7fe02317c63d
|/ tag: t_beta
| user: test <test@example.org>
| date: Mon Jan 01 00:00:11 2007 +0000
| summary: add beta
|
@ changeset: 0:ff7a2f2d8d70
bookmark: epsilon
tag: default/epsilon
tag: t_alpha
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: add alpha
pull with wildcards
$ cd gitrepo
$ git checkout -qb releases/v1 master
$ echo zeta > zeta
$ git add zeta
$ fn_git_commit -m 'add zeta'
$ git checkout -qb releases/v2 master
$ echo eta > eta
$ git add eta
$ fn_git_commit -m 'add eta'
$ git checkout -qb notreleases/v1 master
$ echo theta > theta
$ git add theta
$ fn_git_commit -m 'add theta'
ensure that releases/v1 and releases/v2 are pulled but not notreleases/v1
$ cd ..
$ hg -R hgrepo pull -r 'releases/*'
pulling from $TESTTMP/gitrepo
importing 2 git commits
adding bookmark releases/v1
adding bookmark releases/v2
new changesets 218b2d0660d3:a3f95e150b0a (2 drafts)
(run 'hg heads .' to see heads, 'hg merge' to merge)
$ hg -R hgrepo log --graph
o changeset: 6:a3f95e150b0a
| bookmark: releases/v2
| tag: default/releases/v2
| tag: tip
| parent: 4:a02330f767a4
| user: test <test@example.org>
| date: Mon Jan 01 00:00:15 2007 +0000
| summary: add eta
|
| o changeset: 5:218b2d0660d3
|/ bookmark: releases/v1
| tag: default/releases/v1
| user: test <test@example.org>
| date: Mon Jan 01 00:00:14 2007 +0000
| summary: add zeta
|
o changeset: 4:a02330f767a4
|\ bookmark: master
| | tag: default/master
| | parent: 3:6f898ad1f3e1
| | parent: 1:7fe02317c63d
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:13 2007 +0000
| | summary: Merge branch 'beta'
| |
| o changeset: 3:6f898ad1f3e1
| | parent: 0:ff7a2f2d8d70
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:13 2007 +0000
| | summary: add gamma
| |
| | o changeset: 2:678ebee93e38
| |/ bookmark: delta
| | tag: default/delta
| | parent: 0:ff7a2f2d8d70
| | user: test <test@example.org>
| | date: Mon Jan 01 00:00:12 2007 +0000
| | summary: add delta
| |
o | changeset: 1:7fe02317c63d
|/ tag: t_beta
| user: test <test@example.org>
| date: Mon Jan 01 00:00:11 2007 +0000
| summary: add beta
|
@ changeset: 0:ff7a2f2d8d70
bookmark: epsilon
tag: default/epsilon
tag: t_alpha
user: test <test@example.org>
date: Mon Jan 01 00:00:10 2007 +0000
summary: add alpha
add old and new commits to the git repo -- make sure we're using the commit date
and not the author date
$ cat >> $HGRCPATH <<EOF
> [git]
> mindate = 2014-01-02 00:00:00 +0000
> EOF
$ cd gitrepo
$ git checkout -q master
$ echo oldcommit > oldcommit
$ git add oldcommit
$ GIT_AUTHOR_DATE="2014-03-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2009-01-01 00:00:00 +0000" \
> git commit -m oldcommit > /dev/null || echo "git commit error"
also add an annotated tag
$ git checkout -q master^
$ echo oldtag > oldtag
$ git add oldtag
$ GIT_AUTHOR_DATE="2014-03-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2009-01-01 00:00:00 +0000" \
> git commit -m oldtag > /dev/null || echo "git commit error"
$ GIT_COMMITTER_DATE="2009-02-01 00:00:00 +0000" \
> git tag -a -m 'tagging oldtag' oldtag
$ cd ..
Master is now filtered, so it's just stays there:
$ hg -R hgrepo pull --config git.pull-prune-bookmarks=no
pulling from $TESTTMP/gitrepo
no changes found
$ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo
no changes found
$ hg -R hgrepo log -r master
changeset: 4:a02330f767a4
bookmark: master
tag: default/master
parent: 3:6f898ad1f3e1
parent: 1:7fe02317c63d
user: test <test@example.org>
date: Mon Jan 01 00:00:13 2007 +0000
summary: Merge branch 'beta'
$ cd gitrepo
$ git checkout -q master
$ echo newcommit > newcommit
$ git add newcommit
$ GIT_AUTHOR_DATE="2014-01-01 00:00:00 +0000" \
> GIT_COMMITTER_DATE="2014-01-02 00:00:00 +0000" \
> git commit -m newcommit > /dev/null || echo "git commit error"
$ git checkout -q refs/tags/oldtag
$ GIT_COMMITTER_DATE="2014-01-02 00:00:00 +0000" \
> git tag -a -m 'tagging newtag' newtag
$ cd ..
$ hg -R hgrepo pull
pulling from $TESTTMP/gitrepo
importing 3 git commits
updating bookmark master
new changesets 49713da8f665:e103a73f33be (3 drafts)
(run 'hg heads .' to see heads, 'hg merge' to merge)
$ hg -R hgrepo heads
changeset: 9:e103a73f33be
bookmark: master
tag: default/master
tag: tip
user: test <test@example.org>
date: Wed Jan 01 00:00:00 2014 +0000
summary: newcommit
changeset: 7:49713da8f665
tag: newtag
tag: oldtag
parent: 4:a02330f767a4
user: test <test@example.org>
date: Sat Mar 01 00:00:00 2014 +0000
summary: oldtag
changeset: 6:a3f95e150b0a
bookmark: releases/v2
tag: default/releases/v2
parent: 4:a02330f767a4
user: test <test@example.org>
date: Mon Jan 01 00:00:15 2007 +0000
summary: add eta
changeset: 5:218b2d0660d3
bookmark: releases/v1
tag: default/releases/v1
user: test <test@example.org>
date: Mon Jan 01 00:00:14 2007 +0000
summary: add zeta
changeset: 2:678ebee93e38
bookmark: delta
tag: default/delta
parent: 0:ff7a2f2d8d70
user: test <test@example.org>
date: Mon Jan 01 00:00:12 2007 +0000
summary: add delta
test for ssh vulnerability
$ cat >> $HGRCPATH << EOF
> [ui]
> ssh = ssh -o ConnectTimeout=1
> EOF
$ hg init a
$ cd a
$ hg pull -q 'git+ssh://-oProxyCommand=rm${IFS}nonexistent/path'
abort: potentially unsafe hostname: '-oProxyCommand=rm${IFS}nonexistent'
[255]
$ hg pull -q 'git+ssh://-oProxyCommand=rm%20nonexistent/path'
abort: potentially unsafe hostname: '-oProxyCommand=rm nonexistent'
[255]
$ hg pull -q 'git+ssh://fakehost|shellcommand/path'
ssh: * fakehost%7?shellcommand* (glob)
abort: git remote error: The remote server unexpectedly closed the connection.
[255]
$ hg pull -q 'git+ssh://fakehost%7Cshellcommand/path'
ssh: * fakehost%7?shellcommand* (glob)
abort: git remote error: The remote server unexpectedly closed the connection.
[255]
|