mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
395 lines
7.1 KiB
Perl
395 lines
7.1 KiB
Perl
|
#testcases case-innodb case-rocksdb
|
||
|
|
||
|
#if case-rocksdb
|
||
|
$ DBENGINE=rocksdb
|
||
|
#else
|
||
|
$ DBENGINE=innodb
|
||
|
#endif
|
||
|
|
||
|
$ . "$TESTDIR/hgsql/library.sh"
|
||
|
|
||
|
Test operations on server repository with bad configuration fail in expected
|
||
|
ways.
|
||
|
|
||
|
$ hg init master
|
||
|
$ cd master
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [extensions]
|
||
|
> globalrevs=
|
||
|
> [hgsql]
|
||
|
> enabled = True
|
||
|
> EOF
|
||
|
|
||
|
- Expectation is to fail because hgsql extension is not enabled.
|
||
|
|
||
|
$ hg log -r 'tip' -T {node}
|
||
|
abort: hgsql extension is not enabled
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Properly configure the server with respect to hgsql extension.
|
||
|
|
||
|
$ configureserver . master
|
||
|
|
||
|
|
||
|
- Expectation is to fail because pushrebase extension is not enabled.
|
||
|
|
||
|
$ hg log -r 'tip' -T {node}
|
||
|
abort: pushrebase extension is not enabled
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Enable pushrebase extension on the server.
|
||
|
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [extensions]
|
||
|
> pushrebase=
|
||
|
> EOF
|
||
|
|
||
|
|
||
|
- Expectation is to fail because we need to configure pushrebase to only allow
|
||
|
commits created through pushrebase extension.
|
||
|
|
||
|
$ hg log -r 'tip' -T {node}
|
||
|
abort: pushrebase using incorrect configuration
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Configure server repository to only allow commits created through pushrebase.
|
||
|
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [pushrebase]
|
||
|
> blocknonpushrebase = True
|
||
|
> EOF
|
||
|
|
||
|
|
||
|
- Test that the `globalrev` command fails because there is no entry in the
|
||
|
database for the next available strictly increasing revision number.
|
||
|
|
||
|
$ hg globalrev
|
||
|
abort: no commit counters for master in database
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Test that the `initglobalrev` command fails when run without the
|
||
|
`--i-know-what-i-am-doing` flag.
|
||
|
|
||
|
$ hg initglobalrev 5000
|
||
|
abort: * (glob)
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Test that incorrect arguments to the `initglobalrev` command result in error.
|
||
|
|
||
|
$ hg initglobalrev "blah" --i-know-what-i-am-doing
|
||
|
abort: start must be an integer.
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Configure the next available strictly increasing revision number to be 5000.
|
||
|
$ hg initglobalrev 5000 --i-know-what-i-am-doing
|
||
|
$ hg globalrev
|
||
|
5000
|
||
|
|
||
|
|
||
|
- Check that we can only set the next available strictly increasing revision
|
||
|
number once.
|
||
|
|
||
|
$ hg initglobalrev 5000 --i-know-what-i-am-doing 2> /dev/null
|
||
|
[1]
|
||
|
|
||
|
|
||
|
- Server is configured properly now. We can create an initial commit in the
|
||
|
database.
|
||
|
|
||
|
$ hg log -r 'tip' -T {node}
|
||
|
0000000000000000000000000000000000000000 (no-eol)
|
||
|
|
||
|
$ touch a && hg ci -Aqm a
|
||
|
$ hg book master
|
||
|
|
||
|
|
||
|
Test that pushing to a server with the `globalrevs` extension enabled leads to
|
||
|
creation of commits with strictly increasing revision numbers accessible through
|
||
|
the `globalrev` template.
|
||
|
|
||
|
- Configure client. `globalrevs` extension is enabled for making the `globalrev`
|
||
|
template available to the client.
|
||
|
|
||
|
$ cd ..
|
||
|
$ initclient client
|
||
|
$ cd client
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [extensions]
|
||
|
> globalrevs=
|
||
|
> pushrebase=
|
||
|
> [experimental]
|
||
|
> evolution = all
|
||
|
> EOF
|
||
|
|
||
|
|
||
|
- Make commits on the client.
|
||
|
|
||
|
$ hg pull -q ssh://user@dummy/master
|
||
|
$ hg up -q tip
|
||
|
$ touch b && hg ci -Aqm b
|
||
|
$ touch c && hg ci -Aqm c
|
||
|
|
||
|
|
||
|
- Finally, push the commits to the server.
|
||
|
|
||
|
$ hg push -q ssh://user@dummy/master --to master
|
||
|
|
||
|
|
||
|
- Check that the `globalrev` template on the client and server shows strictly
|
||
|
increasing revision numbers for the pushed commits.
|
||
|
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
@ 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
o a
|
||
|
|
||
|
|
||
|
$ cd ../master
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
@ a
|
||
|
|
||
|
|
||
|
|
||
|
Test that running the `globalrev` command on the client fails.
|
||
|
|
||
|
$ cd ../client
|
||
|
$ hg globalrev
|
||
|
abort: this repository is not a sql backed repository
|
||
|
[255]
|
||
|
|
||
|
$ cd ../master
|
||
|
|
||
|
|
||
|
Test that failure of the transaction is handled gracefully and does not affect
|
||
|
the assignment of subsequent strictly increasing revision numbers.
|
||
|
|
||
|
- Configure the transaction to always fail before closing on the server.
|
||
|
|
||
|
$ cp .hg/hgrc .hg/hgrc.bak
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [hooks]
|
||
|
> pretxnclose.error = exit 1
|
||
|
> EOF
|
||
|
|
||
|
|
||
|
- Make some commits on the client.
|
||
|
|
||
|
$ cd ../client
|
||
|
$ touch d && hg ci -Aqm d
|
||
|
$ touch e && hg ci -Aqm e
|
||
|
|
||
|
|
||
|
- Try pushing the commits to the server. Push should fail because of the
|
||
|
incorrect configuration on the server.
|
||
|
|
||
|
$ hg push -q ssh://user@dummy/master --to master
|
||
|
abort: push failed on remote
|
||
|
[255]
|
||
|
|
||
|
|
||
|
- Fix the configuration on the server and retry. This time the pushing should
|
||
|
succeed.
|
||
|
|
||
|
$ cd ../master
|
||
|
$ mv .hg/hgrc.bak .hg/hgrc
|
||
|
|
||
|
$ cd ../client
|
||
|
$ hg push -q ssh://user@dummy/master --to master
|
||
|
|
||
|
|
||
|
- Check that both the client and server have the expected strictly increasing
|
||
|
revisions numbers.
|
||
|
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
@ 5003 e
|
||
|
|
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
o a
|
||
|
|
||
|
|
||
|
$ cd ../master
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
o 5003 e
|
||
|
|
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
@ a
|
||
|
|
||
|
|
||
|
|
||
|
Test pushing to a different head on the server.
|
||
|
|
||
|
- Make some commits on the client to a different head (other than the current
|
||
|
tip).
|
||
|
|
||
|
$ cd ../client
|
||
|
$ hg up -q 'tip^'
|
||
|
$ touch f && hg ci -Aqm f
|
||
|
$ touch g && hg ci -Aqm g
|
||
|
|
||
|
|
||
|
- Push the commits to the server.
|
||
|
|
||
|
$ hg push -q ssh://user@dummy/master --to master
|
||
|
|
||
|
|
||
|
- Check that both the client and server have the expected strictly increasing
|
||
|
revisions numbers.
|
||
|
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
@ 5005 g
|
||
|
|
|
||
|
o 5004 f
|
||
|
|
|
||
|
| o 5003 e
|
||
|
|/
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
o a
|
||
|
|
||
|
|
||
|
$ cd ../master
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
o 5005 g
|
||
|
|
|
||
|
o 5004 f
|
||
|
|
|
||
|
| o 5003 e
|
||
|
|/
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
@ a
|
||
|
|
||
|
|
||
|
|
||
|
Test cherry picking commits from a branch and pushing to another branch.
|
||
|
|
||
|
- On the client, cherry pick a commit from one branch to copy to the only other
|
||
|
branch head. In particular, we are copying the commit with description `g` on
|
||
|
top of commit with description `e`.
|
||
|
|
||
|
$ cd ../client
|
||
|
$ hg rebase -qk -d 'desc("e")' -r 'tip' --collapse -m g1 \
|
||
|
> --config extensions.rebase=
|
||
|
|
||
|
- Check that the rebase did not add `globalrev` to the commit since the commit
|
||
|
did not reach the server yet.
|
||
|
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
@ g1
|
||
|
|
|
||
|
| o 5005 g
|
||
|
| |
|
||
|
| o 5004 f
|
||
|
| |
|
||
|
o | 5003 e
|
||
|
|/
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
o a
|
||
|
|
||
|
|
||
|
- Push the commits to the server.
|
||
|
|
||
|
$ hg push -q ssh://user@dummy/master --to master
|
||
|
|
||
|
|
||
|
- Check that both the client and server have the expected strictly increasing
|
||
|
revisions numbers.
|
||
|
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
@ 5006 g1
|
||
|
|
|
||
|
| o 5005 g
|
||
|
| |
|
||
|
| o 5004 f
|
||
|
| |
|
||
|
o | 5003 e
|
||
|
|/
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
o a
|
||
|
|
||
|
|
||
|
$ cd ../master
|
||
|
$ hg log -GT '{globalrev} {desc}\n'
|
||
|
o 5006 g1
|
||
|
|
|
||
|
| o 5005 g
|
||
|
| |
|
||
|
| o 5004 f
|
||
|
| |
|
||
|
o | 5003 e
|
||
|
|/
|
||
|
o 5002 d
|
||
|
|
|
||
|
o 5001 c
|
||
|
|
|
||
|
o 5000 b
|
||
|
|
|
||
|
@ a
|
||
|
|
||
|
|
||
|
|
||
|
Test errors for bad configuration of the hgsql extension on the server
|
||
|
|
||
|
- Configure the server to bypass hgsql extension.
|
||
|
|
||
|
$ cat >> .hg/hgrc <<EOF
|
||
|
> [hgsql]
|
||
|
> bypass = True
|
||
|
> EOF
|
||
|
|
||
|
|
||
|
- Make a commit on the client.
|
||
|
|
||
|
$ cd ../client
|
||
|
$ touch h && hg ci -Aqm h
|
||
|
|
||
|
|
||
|
- Try to push the commit to the server. It should fail because the hgsql
|
||
|
extension is misconfigured.
|
||
|
|
||
|
$ hg push ssh://user@dummy/master --to master
|
||
|
pushing to ssh://user@dummy/master
|
||
|
remote: abort: hgsql using incorrect configuration
|
||
|
abort: no suitable response from remote hg!
|
||
|
[255]
|