sapling/eden/scm/tests/test-infinitepush-scratchbookmark-commands.t
Zeyi (Rice) Fan 92f6f35e7a mark all tests requiring Python 2
Summary:
This diff marks **ALL** mercurial tests requiring Python 2 feature.

After you fixes some tests, simply remove the `py2` feature requirement and that tests will be continuously run after your diff is landed.

To bypass this feature requirement, run the tests command with `HGTEST_FORCE_PY2=1`. For example:

```
HGTEST_FORCE_PY2=1 buck test //eden/scm/tests:hg_run_tests
```

or

```
HGTEST_FORCE_PY2=1 python run-tests.py
```

----

Basically this diff are created with the following commands:

```
$ sed -i 's/import feature\(.*\)$/import feature\1\n\nfeature.require(["py2"])/' test-*-t.py
$ sed -i '1s/^/#require py2\n/' test-*.t
$ ls | grep -P "^test.*(?<\!-t)\.py$" > list && vim -p $(cat list)
# manually adding feature requires for these Python tests.
```

(Note: this ignores all push blocking failures!)

ignore-conflict-markers

Reviewed By: singhsrb

Differential Revision: D19655148

fbshipit-source-id: 985e3ccb4010cc559049f1d89f8909bc2d9b5e20
2020-01-30 18:49:21 -08:00

243 lines
6.2 KiB
Perl

#require py2
#chg-compatible
$ disable treemanifest
Common configuration for both the server and client.
$ enable infinitepush remotenames
$ setconfig infinitepush.branchpattern="re:scratch/.+"
$ setconfig ui.ssh="python \"$TESTDIR/dummyssh\""
Initialize the server.
$ newrepo server
$ setconfig infinitepush.server=yes infinitepush.indextype=disk \
> infinitepush.storetype=disk phases.new-commit="public"
Make some commits on the server.
$ echo base > base
$ hg commit -Aqm "public commit"
$ echo 1 > file
$ hg commit -Aqm "another public commit"
Initialize the client.
$ cd $TESTTMP
$ hg clone -q ssh://user@dummy/server client
$ cd client
Push a public commit to a scratch bookmark.
$ hg push -q --to "scratch/public" --create -r "."
Push a draft commit to a scratch bookmark.
$ echo 2 > file
$ hg commit -Aqm "draft commit"
$ hg push -q --to "scratch/draft" --create -r "."
Test invalid invocations of the `debugcreatescratchbookmark` command.
$ hg debugcreatescratchbookmark -r "." -B scratch/bookmark
abort: scratch bookmarks can only be created on an infinitepush server
[255]
$ cd ../server
$ hg debugcreatescratchbookmark -r "all()" -B scratch/bookmark
abort: must specify exactly one target commit for scratch bookmark
[255]
$ hg debugcreatescratchbookmark -r "."
abort: scratch bookmark name is required
[255]
Make another public scratch bookmark on an older commit on the server.
$ hg debugcreatescratchbookmark -r "." -B scratch/anotherpublic
Test that we cannot create a scratch bookmark with the same name.
$ hg debugcreatescratchbookmark -r "." -B scratch/anotherpublic
abort: scratch bookmark 'scratch/anotherpublic' already exists
[255]
Test that we cannot create a real bookmark.
$ hg debugcreatescratchbookmark -r "." -B nonscratchbookmark
abort: invalid scratch bookmark name
[255]
Check that the bookmarks show as expected on the client.
$ cd ../client
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit"
72feb0cc373f "another public commit" default/scratch/public
68d8ff913700 "draft commit" default/scratch/draft
$ hg pull -B scratch/anotherpublic
pulling from ssh://user@dummy/server
no changes found
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit"
72feb0cc373f "another public commit" default/scratch/anotherpublic default/scratch/public
68d8ff913700 "draft commit" default/scratch/draft
Make another scratch bookmark on a draft commit on the server.
$ cd ../server
$ hg debugcreatescratchbookmark -r "68d8ff913700" -B scratch/anotherdraft
Check that the draft scratch bookmark shows up on the client as expected.
$ cd ../client
$ hg pull -r scratch/anotherdraft
pulling from ssh://user@dummy/server
no changes found
adding changesets
adding manifests
adding file changes
added 0 changesets with 0 changes to 1 files
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit"
72feb0cc373f "another public commit" default/scratch/anotherpublic default/scratch/public
68d8ff913700 "draft commit" default/scratch/anotherdraft default/scratch/draft
Test the attempting to create a scratch bookmark on a non existing commit fails.
$ cd ../server
$ hg debugcreatescratchbookmark -r "aaaaaaaaaaaa" -B scratch/bookmark
abort: unknown revision 'aaaaaaaaaaaa'!
(if aaaaaaaaaaaa is a remote bookmark or commit, try to 'hg pull' it first)
[255]
Test invalid invocations of the `debugmovescratchbookmark` command.
$ cd ../client
$ hg debugmovescratchbookmark -r "." -B scratch/draft
abort: scratch bookmarks can only be moved on an infinitepush server
[255]
$ cd ../server
$ hg debugmovescratchbookmark -r "all()" -B scratch/draft
abort: must specify exactly one target commit for scratch bookmark
[255]
$ hg debugmovescratchbookmark -r "."
abort: scratch bookmark name is required
[255]
$ hg debugmovescratchbookmark -r "." -B scratch/nonexistingbookmark
abort: scratch bookmark 'scratch/nonexistingbookmark' does not exist
[255]
Test that we cannot move a real bookmark.
$ hg debugmovescratchbookmark -r "." -B nonscratchbookmark
abort: invalid scratch bookmark name
[255]
Move a public scratch bookmark to an older commit on the server.
$ hg debugmovescratchbookmark -r ".^" -B scratch/public
Check that the bookmarks show as expected on the client.
$ cd ../client
$ hg pull -B scratch/public
pulling from ssh://user@dummy/server
no changes found
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit" default/scratch/public
72feb0cc373f "another public commit" default/scratch/anotherpublic
68d8ff913700 "draft commit" default/scratch/anotherdraft default/scratch/draft
Push another draft commit to a scratch bookmark.
$ echo 2 >> file
$ hg commit -Aqm "another draft commit"
$ hg push -q --to "scratch/draft" -r "."
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit" default/scratch/public
72feb0cc373f "another public commit" default/scratch/anotherpublic
68d8ff913700 "draft commit" default/scratch/anotherdraft
6051090c9df8 "another draft commit" default/scratch/draft
Swap the draft scratch bookmarks.
$ cd ../server
$ hg debugmovescratchbookmark -r "68d8ff913700" -B scratch/draft
$ hg debugmovescratchbookmark -r "6051090c9df8" -B scratch/anotherdraft
Check that the bookmarks show as expected on the client.
$ cd ../client
$ hg pull -B scratch/draft
pulling from ssh://user@dummy/server
no changes found
adding changesets
adding manifests
adding file changes
added 0 changesets with 0 changes to 1 files
$ hg pull -B scratch/anotherdraft
pulling from ssh://user@dummy/server
no changes found
adding changesets
adding manifests
adding file changes
added 0 changesets with 0 changes to 1 files
$ hg log -r "all()" -T '{node|short} "{desc}" {remotebookmarks}\n'
74903ee2450a "public commit" default/scratch/public
72feb0cc373f "another public commit" default/scratch/anotherpublic
68d8ff913700 "draft commit" default/scratch/draft
6051090c9df8 "another draft commit" default/scratch/anotherdraft