##// END OF EJS Templates
test-convert: disable autocrlf for git...
Eduard-Cristian Stefan -
r16892:cfd892b7 default
parent child Browse files
Show More
@@ -1,293 +1,295 b''
1 1
2 2 $ "$TESTDIR/hghave" git || exit 80
3 $ echo "[core]" >> $HOME/.gitconfig
4 $ echo "autocrlf = false" >> $HOME/.gitconfig
3 5 $ echo "[extensions]" >> $HGRCPATH
4 6 $ echo "convert=" >> $HGRCPATH
5 7 $ echo 'hgext.graphlog =' >> $HGRCPATH
6 8 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
7 9 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
8 10 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
9 11 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
10 12 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
11 13 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
12 14 $ count=10
13 15 $ commit()
14 16 > {
15 17 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
16 18 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
17 19 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
18 20 > count=`expr $count + 1`
19 21 > }
20 22 $ mkdir git-repo
21 23 $ cd git-repo
22 24 $ git init-db >/dev/null 2>/dev/null
23 25 $ echo a > a
24 26 $ mkdir d
25 27 $ echo b > d/b
26 28 $ git add a d
27 29 $ commit -a -m t1
28 30
29 31 Remove the directory, then try to replace it with a file
30 32 (issue 754)
31 33
32 34 $ git rm -f d/b
33 35 rm 'd/b'
34 36 $ commit -m t2
35 37 $ echo d > d
36 38 $ git add d
37 39 $ commit -m t3
38 40 $ echo b >> a
39 41 $ commit -a -m t4.1
40 42 $ git checkout -b other HEAD~ >/dev/null 2>/dev/null
41 43 $ echo c > a
42 44 $ echo a >> a
43 45 $ commit -a -m t4.2
44 46 $ git checkout master >/dev/null 2>/dev/null
45 47 $ git pull --no-commit . other > /dev/null 2>/dev/null
46 48 $ commit -m 'Merge branch other'
47 49 $ cd ..
48 50 $ hg convert --datesort git-repo
49 51 assuming destination git-repo-hg
50 52 initializing destination git-repo-hg repository
51 53 scanning source...
52 54 sorting...
53 55 converting...
54 56 5 t1
55 57 4 t2
56 58 3 t3
57 59 2 t4.1
58 60 1 t4.2
59 61 0 Merge branch other
60 62 updating bookmarks
61 63 $ hg up -q -R git-repo-hg
62 64 $ hg -R git-repo-hg tip -v
63 65 changeset: 5:c78094926be2
64 66 bookmark: master
65 67 tag: tip
66 68 parent: 3:f5f5cb45432b
67 69 parent: 4:4e174f80c67c
68 70 user: test <test@example.org>
69 71 date: Mon Jan 01 00:00:15 2007 +0000
70 72 files: a
71 73 description:
72 74 Merge branch other
73 75
74 76
75 77 $ count=10
76 78 $ mkdir git-repo2
77 79 $ cd git-repo2
78 80 $ git init-db >/dev/null 2>/dev/null
79 81 $ echo foo > foo
80 82 $ git add foo
81 83 $ commit -a -m 'add foo'
82 84 $ echo >> foo
83 85 $ commit -a -m 'change foo'
84 86 $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null
85 87 $ echo quux >> quux
86 88 $ git add quux
87 89 $ commit -a -m 'add quux'
88 90 $ echo bar > bar
89 91 $ git add bar
90 92 $ commit -a -m 'add bar'
91 93 $ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null
92 94 $ echo baz > baz
93 95 $ git add baz
94 96 $ commit -a -m 'add baz'
95 97 $ git checkout master >/dev/null 2>/dev/null
96 98 $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
97 99 $ commit -m 'Octopus merge'
98 100 $ echo bar >> bar
99 101 $ commit -a -m 'change bar'
100 102 $ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null
101 103 $ echo >> foo
102 104 $ commit -a -m 'change foo'
103 105 $ git checkout master >/dev/null 2>/dev/null
104 106 $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
105 107 $ commit -m 'Discard change to foo'
106 108 $ cd ..
107 109 $ glog()
108 110 > {
109 111 > hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
110 112 > }
111 113 $ splitrepo()
112 114 > {
113 115 > msg="$1"
114 116 > files="$2"
115 117 > opts=$3
116 118 > echo "% $files: $msg"
117 119 > prefix=`echo "$files" | sed -e 's/ /-/g'`
118 120 > fmap="$prefix.fmap"
119 121 > repo="$prefix.repo"
120 122 > for i in $files; do
121 123 > echo "include $i" >> "$fmap"
122 124 > done
123 125 > hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
124 126 > hg up -q -R "$repo"
125 127 > glog -R "$repo"
126 128 > hg -R "$repo" manifest --debug
127 129 > }
128 130
129 131 full conversion
130 132
131 133 $ hg -q convert --datesort git-repo2 fullrepo
132 134 $ hg up -q -R fullrepo
133 135 $ glog -R fullrepo
134 136 @ 9 "Discard change to foo" files: foo
135 137 |\
136 138 | o 8 "change foo" files: foo
137 139 | |
138 140 o | 7 "change bar" files: bar
139 141 |/
140 142 o 6 "(octopus merge fixup)" files:
141 143 |\
142 144 | o 5 "Octopus merge" files: baz
143 145 | |\
144 146 o | | 4 "add baz" files: baz
145 147 | | |
146 148 +---o 3 "add bar" files: bar
147 149 | |
148 150 o | 2 "add quux" files: quux
149 151 | |
150 152 | o 1 "change foo" files: foo
151 153 |/
152 154 o 0 "add foo" files: foo
153 155
154 156 $ hg -R fullrepo manifest --debug
155 157 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
156 158 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
157 159 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
158 160 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
159 161 $ splitrepo 'octopus merge' 'foo bar baz'
160 162 % foo bar baz: octopus merge
161 163 @ 8 "Discard change to foo" files: foo
162 164 |\
163 165 | o 7 "change foo" files: foo
164 166 | |
165 167 o | 6 "change bar" files: bar
166 168 |/
167 169 o 5 "(octopus merge fixup)" files:
168 170 |\
169 171 | o 4 "Octopus merge" files: baz
170 172 | |\
171 173 o | | 3 "add baz" files: baz
172 174 | | |
173 175 +---o 2 "add bar" files: bar
174 176 | |
175 177 | o 1 "change foo" files: foo
176 178 |/
177 179 o 0 "add foo" files: foo
178 180
179 181 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
180 182 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
181 183 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
182 184 $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
183 185 % foo baz quux: only some parents of an octopus merge; "discard" a head
184 186 @ 6 "Discard change to foo" files: foo
185 187 |
186 188 o 5 "change foo" files: foo
187 189 |
188 190 o 4 "Octopus merge" files:
189 191 |\
190 192 | o 3 "add baz" files: baz
191 193 | |
192 194 | o 2 "add quux" files: quux
193 195 | |
194 196 o | 1 "change foo" files: foo
195 197 |/
196 198 o 0 "add foo" files: foo
197 199
198 200 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
199 201 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
200 202 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
201 203
202 204 test binary conversion (issue 1359)
203 205
204 206 $ mkdir git-repo3
205 207 $ cd git-repo3
206 208 $ git init-db >/dev/null 2>/dev/null
207 209 $ python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
208 210 $ git add b
209 211 $ commit -a -m addbinary
210 212 $ cd ..
211 213
212 214 convert binary file
213 215
214 216 $ hg convert git-repo3 git-repo3-hg
215 217 initializing destination git-repo3-hg repository
216 218 scanning source...
217 219 sorting...
218 220 converting...
219 221 0 addbinary
220 222 updating bookmarks
221 223 $ cd git-repo3-hg
222 224 $ hg up -C
223 225 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
224 226 $ python -c 'print len(file("b", "rb").read())'
225 227 4096
226 228 $ cd ..
227 229
228 230 test author vs committer
229 231
230 232 $ mkdir git-repo4
231 233 $ cd git-repo4
232 234 $ git init-db >/dev/null 2>/dev/null
233 235 $ echo >> foo
234 236 $ git add foo
235 237 $ commit -a -m addfoo
236 238 $ echo >> foo
237 239 $ GIT_AUTHOR_NAME="nottest"
238 240 $ commit -a -m addfoo2
239 241 $ cd ..
240 242
241 243 convert author committer
242 244
243 245 $ hg convert git-repo4 git-repo4-hg
244 246 initializing destination git-repo4-hg repository
245 247 scanning source...
246 248 sorting...
247 249 converting...
248 250 1 addfoo
249 251 0 addfoo2
250 252 updating bookmarks
251 253 $ hg -R git-repo4-hg log -v
252 254 changeset: 1:d63e967f93da
253 255 bookmark: master
254 256 tag: tip
255 257 user: nottest <test@example.org>
256 258 date: Mon Jan 01 00:00:21 2007 +0000
257 259 files: foo
258 260 description:
259 261 addfoo2
260 262
261 263 committer: test <test@example.org>
262 264
263 265
264 266 changeset: 0:0735477b0224
265 267 user: test <test@example.org>
266 268 date: Mon Jan 01 00:00:20 2007 +0000
267 269 files: foo
268 270 description:
269 271 addfoo
270 272
271 273
272 274
273 275 --sourceorder should fail
274 276
275 277 $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
276 278 initializing destination git-repo4-sourcesort-hg repository
277 279 abort: --sourcesort is not supported by this data source
278 280 [255]
279 281
280 282 damage git repository and convert again
281 283
282 284 $ cat > damage.py <<EOF
283 285 > import os
284 286 > for root, dirs, files in os.walk('git-repo4/.git/objects'):
285 287 > if files:
286 288 > path = os.path.join(root, files[0])
287 289 > os.remove(path)
288 290 > break
289 291 > EOF
290 292 $ python damage.py
291 293 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
292 294 > grep 'abort:' | sed 's/abort:.*/abort:/g'
293 295 abort:
@@ -1,84 +1,86 b''
1 1
2 2 $ "$TESTDIR/hghave" git || exit 80
3 $ echo "[core]" >> $HOME/.gitconfig
4 $ echo "autocrlf = false" >> $HOME/.gitconfig
3 5 $ echo "[extensions]" >> $HGRCPATH
4 6 $ echo "convert=" >> $HGRCPATH
5 7 $ echo 'hgext.graphlog =' >> $HGRCPATH
6 8 $ echo '[convert]' >> $HGRCPATH
7 9 $ echo 'hg.usebranchnames = True' >> $HGRCPATH
8 10 $ echo 'hg.tagsbranch = tags-update' >> $HGRCPATH
9 11 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
10 12 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
11 13 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
12 14 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
13 15 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
14 16 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
15 17 $ count=10
16 18 $ action()
17 19 > {
18 20 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
19 21 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
20 22 > git "$@" >/dev/null 2>/dev/null || echo "git command error"
21 23 > count=`expr $count + 1`
22 24 > }
23 25 $ glog()
24 26 > {
25 27 > hg glog --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
26 28 > }
27 29 $ convertrepo()
28 30 > {
29 31 > hg convert --datesort git-repo hg-repo
30 32 > }
31 33
32 34 Build a GIT repo with at least 1 tag
33 35
34 36 $ mkdir git-repo
35 37 $ cd git-repo
36 38 $ git init >/dev/null 2>&1
37 39 $ echo a > a
38 40 $ git add a
39 41 $ action commit -m "rev1"
40 42 $ action tag -m "tag1" tag1
41 43 $ cd ..
42 44
43 45 Do a first conversion
44 46
45 47 $ convertrepo
46 48 initializing destination hg-repo repository
47 49 scanning source...
48 50 sorting...
49 51 converting...
50 52 0 rev1
51 53 updating tags
52 54 updating bookmarks
53 55
54 56 Simulate upstream updates after first conversion
55 57
56 58 $ cd git-repo
57 59 $ echo b > a
58 60 $ git add a
59 61 $ action commit -m "rev2"
60 62 $ action tag -m "tag2" tag2
61 63 $ cd ..
62 64
63 65 Perform an incremental conversion
64 66
65 67 $ convertrepo
66 68 scanning source...
67 69 sorting...
68 70 converting...
69 71 0 rev2
70 72 updating tags
71 73 updating bookmarks
72 74
73 75 Print the log
74 76
75 77 $ cd hg-repo
76 78 $ glog
77 79 o 3 "update tags" files: .hgtags
78 80 |
79 81 | o 2 "rev2" files: a
80 82 | |
81 83 o | 1 "update tags" files: .hgtags
82 84 /
83 85 o 0 "rev1" files: a
84 86
General Comments 0
You need to be logged in to leave comments. Login now