comparison tests/test-convert-git @ 6042:2da5b19a6460

Merge with crew
author Bryan O'Sullivan <bos@serpentine.com>
date Wed, 06 Feb 2008 19:57:52 -0800
parents a5a7f7fd5554
children 7239e06e58e9 c1dc903dc7b6
comparison
equal deleted inserted replaced
6041:dd714452c26e 6042:2da5b19a6460
1 #!/bin/sh
2
3 "$TESTDIR/hghave" git || exit 80
4
5 echo "[extensions]" >> $HGRCPATH
6 echo "convert=" >> $HGRCPATH
7 echo 'hgext.graphlog =' >> $HGRCPATH
8
9 GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
10 GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
11 GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
12 GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
13 GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
14 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
15
16 count=10
17 commit()
18 {
19 GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
20 GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
21 git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
22 count=`expr $count + 1`
23 }
24
25 mkdir git-repo
26 cd git-repo
27 git init-db >/dev/null 2>/dev/null
28 echo a > a
29 mkdir d
30 echo b > d/b
31 git add a d
32 commit -a -m t1
33
34 # Remove the directory, then try to replace it with a file
35 # (issue 754)
36 git rm -f d/b
37 commit -m t2
38 echo d > d
39 git add d
40 commit -m t3
41
42 echo b >> a
43 commit -a -m t4.1
44
45 git checkout -b other HEAD^ >/dev/null 2>/dev/null
46 echo c > a
47 echo a >> a
48 commit -a -m t4.2
49
50 git checkout master >/dev/null 2>/dev/null
51 git pull --no-commit . other > /dev/null 2>/dev/null
52 commit -m 'Merge branch other'
53 cd ..
54
55 hg convert --datesort git-repo
56
57 hg -R git-repo-hg tip -v
58
59 count=10
60 mkdir git-repo2
61 cd git-repo2
62 git init-db >/dev/null 2>/dev/null
63
64 echo foo > foo
65 git add foo
66 commit -a -m 'add foo'
67
68 echo >> foo
69 commit -a -m 'change foo'
70
71 git checkout -b Bar HEAD^ >/dev/null 2>/dev/null
72 echo quux >> quux
73 git add quux
74 commit -a -m 'add quux'
75
76 echo bar > bar
77 git add bar
78 commit -a -m 'add bar'
79
80 git checkout -b Baz HEAD^ >/dev/null 2>/dev/null
81 echo baz > baz
82 git add baz
83 commit -a -m 'add baz'
84
85 git checkout master >/dev/null 2>/dev/null
86 git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
87 commit -m 'Octopus merge'
88
89 echo bar >> bar
90 commit -a -m 'change bar'
91
92 git checkout -b Foo HEAD^ >/dev/null 2>/dev/null
93 echo >> foo
94 commit -a -m 'change foo'
95
96 git checkout master >/dev/null 2>/dev/null
97 git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
98 commit -m 'Discard change to foo'
99
100 cd ..
101
102 glog()
103 {
104 hg glog --template '#rev# "#desc|firstline#" files: #files#\n' "$@"
105 }
106
107 splitrepo()
108 {
109 msg="$1"
110 files="$2"
111 opts=$3
112 echo "% $files: $msg"
113 prefix=`echo "$files" | sed -e 's/ /-/g'`
114 fmap="$prefix.fmap"
115 repo="$prefix.repo"
116 for i in $files; do
117 echo "include $i" >> "$fmap"
118 done
119 hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
120 glog -R "$repo"
121 hg -R "$repo" manifest --debug
122 }
123
124 echo '% full conversion'
125 hg -q convert --datesort git-repo2 fullrepo
126 glog -R fullrepo
127 hg -R fullrepo manifest --debug
128
129 splitrepo 'octopus merge' 'foo bar baz'
130
131 splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
132