sapling/eden/hg-server/tests/test-gitlookup-index.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

108 lines
3.1 KiB
Perl

#require py2
#chg-compatible
#require git
Test the gitlookup.useindex=True feature for fast git -> hg commit translation.
Repos:
- gitrepo: the source git repo
- hgrepo: sync from the hgrepo
- hgclient: a dummy repo that talks to hgrepo
Prepare the git repo:
$ . "$TESTDIR/hggit/testutil"
$ git init --quiet gitrepo
$ cd gitrepo
$ echo alpha > alpha
$ git add alpha
$ fn_git_commit -m 'add alpha'
$ git checkout --quiet -b beta
$ echo beta > beta
$ git add beta
$ fn_git_commit -m 'add beta'
$ cd $TESTTMP
Prepare the hg repo:
$ hg clone gitrepo hgrepo
importing git objects into hg
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd hgrepo
$ enable gitlookup
$ setconfig gitlookup.useindex=True gitlookup.mapfile=$TESTTMP/hgrepo/.hg/git-mapfile
$ hg log -Gr 'all()' -T '{node} {gitnode} {bookmarks}'
@ 3bb02b6794ddc0b498cdc15f59f2e6724cabfa2f 9497a4ee62e16ee641860d7677cdb2589ea15554 beta
o 69982ec78c6dd2f24b3b62f3e2baaa79ab48ed93 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 master
The gitlookup interface is exposed at the wireproto layer. Use another repo to test it:
$ newrepo hgclient
$ hg pull -r _gitlookup_git_7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 $TESTTMP/hgrepo
pulling from $TESTTMP/hgrepo
importing git nodemap from flat mapfile
building git nodemap for 2 commits
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
adding remote bookmark master
$ hg pull -r _gitlookup_git_9497a4ee62e16ee641860d7677cdb2589ea15554 $TESTTMP/hgrepo
pulling from $TESTTMP/hgrepo
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
adding remote bookmark beta
Add new commits to test the index can be incrementally built:
$ cd $TESTTMP/gitrepo
$ echo segma > segma
$ git add segma
$ fn_git_commit -m 'add segma'
Sync git to hg:
$ cd $TESTTMP/hgrepo
$ hg pull
pulling from $TESTTMP/gitrepo
importing git objects into hg
$ hg log -Gr 'all()' -T '{node} {gitnode} {bookmarks}'
o 146e4a0c333d21c93eefe6bf5c01a8d51c5918ab b6d676108afa31dc39efc9c5eb57f19ecbad837b beta
@ 3bb02b6794ddc0b498cdc15f59f2e6724cabfa2f 9497a4ee62e16ee641860d7677cdb2589ea15554
o 69982ec78c6dd2f24b3b62f3e2baaa79ab48ed93 7eeab2ea75ec1ac0ff3d500b5b6f8a3447dd7c03 master
Query the new commits:
$ cd $TESTTMP/hgclient
$ hg pull -r _gitlookup_git_b6d676108afa31dc39efc9c5eb57f19ecbad837b $TESTTMP/hgrepo
pulling from $TESTTMP/hgrepo
building git nodemap for 1 commits
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
updating bookmark beta
Test the debugbuildgitnodemap command. This runs the build explicitly instead of on-demand:
$ cd $TESTTMP/hgrepo
$ hg debugbuildgitnodemap
0 new commits are indexed
$ rm -rf .hg/git-nodemap .hg/git-nodemap-lastrev
$ hg debugbuildgitnodemap
importing git nodemap from flat mapfile
building git nodemap for 3 commits
3 new commits are indexed