sapling/eden/hg-server/tests/test-memcommit.t
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

284 lines
7.0 KiB
Perl

#require py2
#chg-compatible
#chg-compatible
#testcases hgsql.true hgsql.false
$ disable treemanifest
$ . "$TESTDIR/hgsql/library.sh"
#if hgsql.false
$ initserver()
> {
> hg init "$1"
> }
#endif
$ setupserver()
> {
> initserver "$1" "$1"
> ( cd "$1" && enable commitextras memcommit pushrebase )
> }
$ setupserver originalrepo
$ setupserver mirroredrepo
$ copycommit()
> {
> originalrepo="$1"
> shift
> mirroredrepo="$1"
> shift
> hg -R "${originalrepo}" debugserializecommit "$@" | \
> hg -R "${mirroredrepo}" memcommit
> }
$ testreposimilarity()
> {
> diff <(hg -R "$1" heads) <(hg -R "$2" heads)
> }
$ testmemcommit()
> {
> copycommit "$@" > /dev/null
> testreposimilarity "$1" "$2"
> }
$ testcommits()
> {
> chmod +x test
> hg commit -qm "set executable flag for test"
> testmemcommit "$@"
> hg cp test test1
> hg commit -qm "copied test->test1"
> testmemcommit "$@"
> ln -s test1 test2
> hg commit -Aqm "create soft link test2 for test1"
> testmemcommit "$@"
> hg rm test1 test2
> hg commit -qm "deleted test1 and test2"
> testmemcommit "$@"
> hg mv test test1
> hg commit -qm "renamed test->test1 with commit extra" --extra "key=value"
> testmemcommit "$@"
> hg rm test1
> hg commit -qm "deleted test1 with commit extra" --extra "key1=value1"
> testmemcommit "$@"
> }
$ testmirroring()
> {
> touch test
> hg commit -Aqm "added test without content"
> testmemcommit "$@"
> testcommits "$@"
> echo "a" >> test
> hg commit -Aqm "added test with content"
> testmemcommit "$@"
> testcommits "$@"
> hg bundle -q --base -2 test
> hg commit -Aqm "added test with binary content"
> testmemcommit "$@"
> testcommits "$@"
> }
- Test that the `-q` results in no output.
$ cd originalrepo
$ hg -q memcommit
[255]
- Test that we cannot make a commit without specifying a parent in the default
configuration.
$ touch x
$ hg commit -Aqm "initial commit"
$ copycommit . ../mirroredrepo
{"error": "commit without parents are not allowed"} (no-eol)
[255]
- Test that we can make a commit without specifying a parent in the
memcommit.allowunrelatedroots=true configuration. Also, test that we get the new
commit hash in the output.
$ hg debugserializecommit | \
> hg -R ../mirroredrepo --config memcommit.allowunrelatedroots=true memcommit
{"hash": "eae37600e40b803aa5f53aa9dbf9c45eae74323c"} (no-eol)
$ testreposimilarity . ../mirroredrepo
- Test that the '--to' option works.
$ echo >> y
$ hg commit -Aqm "added another file"
$ testmemcommit . ../mirroredrepo --to ".^"
- Test that committing to new parents is not supported.
$ copycommit . ../mirroredrepo --to "."
{"error": "commit with new parents not supported"} (no-eol)
[255]
- Test that we can mirror commits from the originalrepo to the mirroredrepo. In
this case, each commit will be created on the parent commit specified in the
memcommit request.
$ testmirroring . ../mirroredrepo
- Test that we can mirror commits from the originalrepo to the mirroredrepo when
the destination bookmark is specified. In this case, each commit will be created
on the destination bookmark specified in the memcommit request.
$ cd ../mirroredrepo
$ hg bookmark -r "tip" master
$ cd ../originalrepo
$ hg bookmark -r "tip" master
Make the master bookmark active.
$ hg -q up master
$ testmirroring . ../mirroredrepo -d "master"
- For now, we require that the destination bookmark is the same as the commit
parent when the destination bookmark is specified. Confirm that we fail if that
is not the case.
$ hg -q up ".~2"
$ hg mv test test2
$ hg commit -qm "renamed file"
$ copycommit . ../mirroredrepo -d master
{"error": "destination parent does not match destination bookmark"} (no-eol)
[255]
- Test that destination bookmark is required in case of pushrebase.
$ copycommit . ../mirroredrepo --pushrebase
{"error": "must specify destination bookmark for pushrebase"} (no-eol)
[255]
- Test that the conflicts are reported as expected in case of pushrebase.
$ copycommit . ../mirroredrepo -d master --pushrebase
{"error": "conflicting changes in:\n test"} (no-eol)
[255]
$ testmemcommit . ../mirroredrepo
- Setup client for pushrebase tests.
#if hgsql.false
$ initclient()
> {
> hg init "$1"
> ( cd "$1" && configure dummyssh )
> }
#endif
$ setupclient()
> {
> initclient "$1"
> ( \
> cd "$1" && enable memcommit pushrebase remotenames && \
> configure mutation-norecord
> )
> }
$ cd ..
$ setupclient client
$ cd client
$ hg -q pull ssh://user@dummy/originalrepo
- Test that the pushrebase succeeds when the commit parent is an ancestor of
destination bookmark.
$ hg -q up "tip^"
$ touch test2
$ hg commit -Aqm "file without content"
$ copycommit . ../mirroredrepo -d master --pushrebase > /dev/null
$ hg push -q ssh://user@dummy/originalrepo --to master
$ testreposimilarity ../originalrepo ../mirroredrepo
- Test that the pushrebase succeeds when the commit parent is a descendant of
destination bookmark.
$ cd ../originalrepo
$ hg -q up "master"
$ touch test3
$ hg commit -Aqm "file without content"
$ copycommit . ../mirroredrepo > /dev/null
$ hg mv test3 test4
$ hg commit -qm "renamed file"
$ copycommit . ../mirroredrepo > /dev/null
$ cd ../client
$ hg -q pull ssh://user@dummy/originalrepo
$ hg -q up "tip"
$ hg rm test4
$ hg commit -qm "deleted file"
$ copycommit . ../mirroredrepo -d master --pushrebase > /dev/null
$ hg -q push ssh://user@dummy/originalrepo --to master
$ testreposimilarity ../originalrepo ../mirroredrepo
- Test that the pushrebase fails when the commit parent is neither ancestor nor
descendent of destination bookmark.
$ cd ../originalrepo
$ hg -q up "master^"
$ touch test5
$ hg commit -Aqm "file without content"
$ copycommit . ../mirroredrepo > /dev/null
$ cd ../client
$ hg -q pull ssh://user@dummy/originalrepo
$ hg -q up "tip"
$ hg rm test5
$ hg commit -qm "deleted file"
$ copycommit . ../mirroredrepo -d master --pushrebase
{"error": "destination bookmark is not ancestor or descendant of commit parent"} (no-eol)
[255]
- Test that we fail to create merge commits.
$ cd ../originalrepo
$ copycommit . ../mirroredrepo --to ". + .^"
{"error": "merge commits are not supported"} (no-eol)
[255]
$ hg -q merge "master"
$ hg commit -qm "merge commit"
$ copycommit . ../mirroredrepo
{"error": "merge commits are not supported"} (no-eol)
[255]
#if hgsql.true
$ cd ../mirroredrepo
$ mysql -h $DBHOST -P $DBPORT -D $DBNAME -u $DBUSER $DBPASSOPT -e 'REPLACE INTO repo_lock(repo, state) VALUES ("mirroredrepo", 0)'
$ hg debugshell -c "ui.write('%s\n' % str(repo.sqlreporeadonlystate()))"
(True, 'no reason was provided')
$ cd ../originalrepo
$ hg up -q ".^"
$ echo "1" >> test
$ hg commit -Aqm "commit to fail"
$ copycommit . ../mirroredrepo
{"error": "repo is locked"} (no-eol)
[255]
#endif