2012-10-31 04:03:26 +04:00
|
|
|
Load commonly used test logic
|
2018-01-09 17:08:01 +03:00
|
|
|
$ . "$TESTDIR/hggit/testutil"
|
2012-10-31 04:03:26 +04:00
|
|
|
|
2012-10-31 08:01:03 +04:00
|
|
|
$ git init gitsubrepo
|
2012-09-15 03:10:05 +04:00
|
|
|
Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
|
2012-10-31 08:01:03 +04:00
|
|
|
$ cd gitsubrepo
|
2012-09-15 03:08:51 +04:00
|
|
|
$ echo beta > beta
|
|
|
|
$ git add beta
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m 'add beta'
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ..
|
|
|
|
|
2012-10-31 08:01:03 +04:00
|
|
|
$ git init gitrepo1
|
2012-09-15 03:10:05 +04:00
|
|
|
Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
|
2012-10-31 08:01:03 +04:00
|
|
|
$ cd gitrepo1
|
2012-09-15 03:08:51 +04:00
|
|
|
$ echo alpha > alpha
|
|
|
|
$ git add alpha
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m 'add alpha'
|
2012-09-15 03:08:51 +04:00
|
|
|
$ git submodule add ../gitsubrepo subrepo1
|
2016-09-12 17:40:42 +03:00
|
|
|
Cloning into '*subrepo1'... (glob)
|
2012-09-15 03:08:51 +04:00
|
|
|
done.
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m 'add subrepo1'
|
2012-09-15 03:08:51 +04:00
|
|
|
$ git submodule add ../gitsubrepo xyz/subrepo2
|
2016-09-12 17:40:42 +03:00
|
|
|
Cloning into '*xyz/subrepo2'... (glob)
|
2012-09-15 03:08:51 +04:00
|
|
|
done.
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m 'add subrepo2'
|
2012-09-15 03:08:51 +04:00
|
|
|
we are going to push to this repo from our hg clone,
|
|
|
|
allow commits despite working copy presense
|
|
|
|
$ git config receive.denyCurrentBranch ignore
|
|
|
|
$ cd ..
|
2012-11-04 03:14:17 +04:00
|
|
|
Ensure gitlinks are transformed to .hgsubstate on hg pull from git
|
2014-03-25 23:04:11 +04:00
|
|
|
$ hg clone gitrepo1 hgrepo 2>&1 | egrep -v '^(Cloning into|done)'
|
2012-09-15 03:08:51 +04:00
|
|
|
importing git objects into hg
|
|
|
|
updating to branch default
|
2012-09-15 03:10:18 +04:00
|
|
|
cloning subrepo subrepo1 from $TESTTMP/gitsubrepo
|
|
|
|
cloning subrepo xyz/subrepo2 from $TESTTMP/gitsubrepo
|
2012-09-15 03:08:51 +04:00
|
|
|
4 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ cd hgrepo
|
|
|
|
$ hg bookmarks -f -r default master
|
|
|
|
1. Ensure gitlinks are transformed to .hgsubstate on hg <- git pull
|
2012-11-04 03:14:17 +04:00
|
|
|
.hgsub shall list two [git] subrepos
|
2013-08-28 21:52:38 +04:00
|
|
|
$ cat .hgsub | sort
|
2013-08-28 21:41:22 +04:00
|
|
|
subrepo1 = [git]../gitsubrepo
|
2013-08-28 21:52:38 +04:00
|
|
|
xyz/subrepo2 = [git]../gitsubrepo
|
2012-11-04 03:14:17 +04:00
|
|
|
.hgsubstate shall list two idenitcal revisions
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cat .hgsubstate
|
|
|
|
56f0304c5250308f14cfbafdc27bd12d40154d17 subrepo1
|
|
|
|
56f0304c5250308f14cfbafdc27bd12d40154d17 xyz/subrepo2
|
2012-11-04 03:14:17 +04:00
|
|
|
hg status shall NOT report .hgsub and .hgsubstate as untracked - either ignored or unmodified
|
2012-09-15 03:08:51 +04:00
|
|
|
$ hg status --unknown .hgsub .hgsubstate
|
|
|
|
$ hg status --modified .hgsub .hgsubstate
|
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
2. Check gitmodules are preserved during hg -> git push
|
|
|
|
$ cd gitsubrepo
|
|
|
|
$ echo gamma > gamma
|
|
|
|
$ git add gamma
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m 'add gamma'
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ..
|
|
|
|
$ cd hgrepo
|
|
|
|
$ cd xyz/subrepo2
|
|
|
|
$ git pull | sed 's/files/file/;s/insertions/insertion/;s/, 0 deletions.*//' | sed 's/| */| /'
|
2012-09-15 03:10:18 +04:00
|
|
|
From $TESTTMP/gitsubrepo
|
2012-09-15 03:08:51 +04:00
|
|
|
56f0304..aabf7cd master -> origin/master
|
|
|
|
Updating 56f0304..aabf7cd
|
|
|
|
Fast-forward
|
|
|
|
gamma | 1 +
|
|
|
|
1 file changed, 1 insertion(+)
|
|
|
|
create mode 100644 gamma
|
|
|
|
$ cd ../..
|
|
|
|
$ echo xxx >> alpha
|
|
|
|
$ hg commit -m 'Update subrepo2 from hg' | grep -v "committing subrepository" || true
|
|
|
|
$ hg push
|
2012-09-15 03:10:18 +04:00
|
|
|
pushing to $TESTTMP/gitrepo1
|
2012-10-08 04:11:27 +04:00
|
|
|
searching for changes
|
2013-01-06 10:46:57 +04:00
|
|
|
adding objects
|
2013-12-13 21:41:41 +04:00
|
|
|
added 1 commits with 2 trees and 1 blobs
|
2013-01-06 11:31:37 +04:00
|
|
|
updating reference refs/heads/master
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ..
|
|
|
|
$ cd gitrepo1
|
2012-11-04 03:14:17 +04:00
|
|
|
there shall be two gitlink entries, with values matching that in .hgsubstate
|
2018-01-09 16:53:20 +03:00
|
|
|
$ git ls-tree -r "HEAD^{tree}" | grep 'commit'
|
2012-09-15 03:08:51 +04:00
|
|
|
160000 commit 56f0304c5250308f14cfbafdc27bd12d40154d17 subrepo1
|
|
|
|
160000 commit aabf7cd015089aff0b84596e69aa37b24a3d090a xyz/subrepo2
|
|
|
|
bring working copy to HEAD state (it's not bare repo)
|
|
|
|
$ git reset --hard
|
2014-12-03 01:17:09 +03:00
|
|
|
HEAD is now at ae335e3 Update subrepo2 from hg
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
3. Check .hgsub and .hgsubstate from git repository are merged, not overwritten
|
|
|
|
$ hg init hgsub
|
|
|
|
$ cd hgsub
|
|
|
|
$ echo delta > delta
|
|
|
|
$ hg add delta
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_hg_commit -m "add delta"
|
2012-09-15 03:08:51 +04:00
|
|
|
$ echo "`hg tip --template '{node}'` hgsub" > ../gitrepo1/.hgsubstate
|
2018-01-09 16:53:20 +03:00
|
|
|
$ echo "hgsub = `pwd`" > ../gitrepo1/.hgsub
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ../gitrepo1
|
|
|
|
$ git add .hgsubstate .hgsub
|
2012-10-31 06:59:20 +04:00
|
|
|
$ fn_git_commit -m "Test3. Prepare .hgsub and .hgsubstate sources"
|
2012-09-15 03:08:51 +04:00
|
|
|
$ cd ../hgrepo
|
|
|
|
$ hg pull
|
2012-09-15 03:10:18 +04:00
|
|
|
pulling from $TESTTMP/gitrepo1
|
2012-09-15 03:08:51 +04:00
|
|
|
importing git objects into hg
|
|
|
|
(run 'hg update' to get a working copy)
|
2016-01-01 00:01:03 +03:00
|
|
|
$ hg checkout -C | egrep -v '^\(activating bookmark master\)$'
|
|
|
|
updating to active bookmark master
|
2012-10-08 03:37:59 +04:00
|
|
|
cloning subrepo hgsub from $TESTTMP/hgsub
|
2012-09-15 03:08:51 +04:00
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ cd ..
|
2012-11-04 03:14:17 +04:00
|
|
|
pull shall bring .hgsub entry which was added to the git repo
|
2013-08-28 21:52:38 +04:00
|
|
|
$ cat hgrepo/.hgsub | sort
|
2012-10-08 03:37:59 +04:00
|
|
|
hgsub = $TESTTMP/hgsub
|
2013-08-28 21:41:22 +04:00
|
|
|
subrepo1 = [git]../gitsubrepo
|
2013-08-28 21:52:38 +04:00
|
|
|
xyz/subrepo2 = [git]../gitsubrepo
|
2012-11-04 03:14:17 +04:00
|
|
|
.hgsubstate shall list revision of the subrepo added through git repo
|
2012-10-08 03:37:59 +04:00
|
|
|
$ cat hgrepo/.hgsubstate
|
2012-09-15 03:08:51 +04:00
|
|
|
481ec30d580f333ae3a77f94c973ce37b69d5bda hgsub
|
|
|
|
56f0304c5250308f14cfbafdc27bd12d40154d17 subrepo1
|
|
|
|
aabf7cd015089aff0b84596e69aa37b24a3d090a xyz/subrepo2
|