| 1 |
#require git |
| 2 |
|
| 3 |
$ git config -f $HOME/.gitconfig init.defaultBranch master |
| 4 |
$ git config -f $HOME/.gitconfig core.autocrlf false |
| 5 |
$ git config -f $HOME/.gitconfig protocol.file.allow always |
| 6 |
$ echo "[extensions]" >> $HGRCPATH |
| 7 |
$ echo "convert=" >> $HGRCPATH |
| 8 |
$ cat >> $HGRCPATH <<EOF |
| 9 |
> [subrepos] |
| 10 |
> git:allowed = true |
| 11 |
> EOF |
| 12 |
$ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME |
| 13 |
$ GIT_AUTHOR_EMAIL='[email protected]'; export GIT_AUTHOR_EMAIL |
| 14 |
$ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE |
| 15 |
$ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME |
| 16 |
$ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL |
| 17 |
$ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE |
| 18 |
$ INVALIDID1=afd12345af |
| 19 |
$ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86 |
| 20 |
$ VALIDID1=39b3d83f9a69a9ba4ebb111461071a0af0027357 |
| 21 |
$ VALIDID2=8dd6476bd09d9c7776355dc454dafe38efaec5da |
| 22 |
$ count=10 |
| 23 |
$ commit() |
| 24 |
> { |
| 25 |
> GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000" |
| 26 |
> GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" |
| 27 |
> git commit "$@" >/dev/null 2>/dev/null || echo "git commit error" |
| 28 |
> count=`expr $count + 1` |
| 29 |
> } |
| 30 |
$ mkdir git-repo |
| 31 |
$ cd git-repo |
| 32 |
$ git init >/dev/null 2>/dev/null |
| 33 |
$ echo a > a |
| 34 |
$ mkdir d |
| 35 |
$ echo b > d/b |
| 36 |
$ git add a d |
| 37 |
$ commit -a -m t1 |
| 38 |
|
| 39 |
Remove the directory, then try to replace it with a file (issue754) |
| 40 |
|
| 41 |
$ git rm -f d/b |
| 42 |
rm 'd/b' |
| 43 |
$ commit -m t2 |
| 44 |
$ echo d > d |
| 45 |
$ git add d |
| 46 |
$ commit -m t3 |
| 47 |
$ echo b >> a |
| 48 |
$ commit -a -m t4.1 |
| 49 |
$ git checkout -b other HEAD~ >/dev/null 2>/dev/null |
| 50 |
$ echo c > a |
| 51 |
$ echo a >> a |
| 52 |
$ commit -a -m t4.2 |
| 53 |
$ git checkout master >/dev/null 2>/dev/null |
| 54 |
$ git pull --no-commit . other --no-rebase > /dev/null 2>/dev/null |
| 55 |
$ commit -m 'Merge branch other' |
| 56 |
$ cd .. |
| 57 |
$ hg convert --config extensions.progress= --config progress.assume-tty=1 \ |
| 58 |
> --config progress.delay=0 --config progress.changedelay=0 \ |
| 59 |
> --config progress.refresh=0 --config progress.width=60 \ |
| 60 |
> --config progress.format='topic, bar, number' --datesort git-repo |
| 61 |
\r (no-eol) (esc) |
| 62 |
scanning [======> ] 1/6\r (no-eol) (esc) |
| 63 |
scanning [=============> ] 2/6\r (no-eol) (esc) |
| 64 |
scanning [=====================> ] 3/6\r (no-eol) (esc) |
| 65 |
scanning [============================> ] 4/6\r (no-eol) (esc) |
| 66 |
scanning [===================================> ] 5/6\r (no-eol) (esc) |
| 67 |
scanning [===========================================>] 6/6\r (no-eol) (esc) |
| 68 |
\r (no-eol) (esc) |
| 69 |
\r (no-eol) (esc) |
| 70 |
converting [ ] 0/6\r (no-eol) (esc) |
| 71 |
getting files [==================> ] 1/2\r (no-eol) (esc) |
| 72 |
getting files [======================================>] 2/2\r (no-eol) (esc) |
| 73 |
\r (no-eol) (esc) |
| 74 |
\r (no-eol) (esc) |
| 75 |
converting [======> ] 1/6\r (no-eol) (esc) |
| 76 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 77 |
\r (no-eol) (esc) |
| 78 |
\r (no-eol) (esc) |
| 79 |
converting [=============> ] 2/6\r (no-eol) (esc) |
| 80 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 81 |
\r (no-eol) (esc) |
| 82 |
\r (no-eol) (esc) |
| 83 |
converting [====================> ] 3/6\r (no-eol) (esc) |
| 84 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 85 |
\r (no-eol) (esc) |
| 86 |
\r (no-eol) (esc) |
| 87 |
converting [===========================> ] 4/6\r (no-eol) (esc) |
| 88 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 89 |
\r (no-eol) (esc) |
| 90 |
\r (no-eol) (esc) |
| 91 |
converting [==================================> ] 5/6\r (no-eol) (esc) |
| 92 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 93 |
\r (no-eol) (esc) |
| 94 |
assuming destination git-repo-hg |
| 95 |
initializing destination git-repo-hg repository |
| 96 |
scanning source... |
| 97 |
sorting... |
| 98 |
converting... |
| 99 |
5 t1 |
| 100 |
4 t2 |
| 101 |
3 t3 |
| 102 |
2 t4.1 |
| 103 |
1 t4.2 |
| 104 |
0 Merge branch other |
| 105 |
updating bookmarks |
| 106 |
$ hg up -q -R git-repo-hg |
| 107 |
$ hg -R git-repo-hg tip -v |
| 108 |
changeset: 5:c78094926be2 |
| 109 |
bookmark: master |
| 110 |
tag: tip |
| 111 |
parent: 3:f5f5cb45432b |
| 112 |
parent: 4:4e174f80c67c |
| 113 |
user: test <[email protected]> |
| 114 |
date: Mon Jan 01 00:00:15 2007 +0000 |
| 115 |
files: a |
| 116 |
description: |
| 117 |
Merge branch other |
| 118 |
|
| 119 |
|
| 120 |
$ count=10 |
| 121 |
$ mkdir git-repo2 |
| 122 |
$ cd git-repo2 |
| 123 |
$ git init >/dev/null 2>/dev/null |
| 124 |
$ echo foo > foo |
| 125 |
$ git add foo |
| 126 |
$ commit -a -m 'add foo' |
| 127 |
$ echo >> foo |
| 128 |
$ commit -a -m 'change foo' |
| 129 |
$ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null |
| 130 |
$ echo quux >> quux |
| 131 |
$ git add quux |
| 132 |
$ commit -a -m 'add quux' |
| 133 |
$ echo bar > bar |
| 134 |
$ git add bar |
| 135 |
$ commit -a -m 'add bar' |
| 136 |
$ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null |
| 137 |
$ echo baz > baz |
| 138 |
$ git add baz |
| 139 |
$ commit -a -m 'add baz' |
| 140 |
$ git checkout master >/dev/null 2>/dev/null |
| 141 |
$ git pull --no-commit . Bar Baz --no-rebase > /dev/null 2>/dev/null |
| 142 |
$ commit -m 'Octopus merge' |
| 143 |
$ echo bar >> bar |
| 144 |
$ commit -a -m 'change bar' |
| 145 |
$ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null |
| 146 |
$ echo >> foo |
| 147 |
$ commit -a -m 'change foo' |
| 148 |
$ git checkout master >/dev/null 2>/dev/null |
| 149 |
$ git pull --no-commit -s ours . Foo --no-rebase > /dev/null 2>/dev/null |
| 150 |
$ commit -m 'Discard change to foo' |
| 151 |
$ cd .. |
| 152 |
$ glog() |
| 153 |
> { |
| 154 |
> hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@" |
| 155 |
> } |
| 156 |
$ splitrepo() |
| 157 |
> { |
| 158 |
> msg="$1" |
| 159 |
> files="$2" |
| 160 |
> opts=$3 |
| 161 |
> echo "% $files: $msg" |
| 162 |
> prefix=`echo "$files" | sed -e 's/ /-/g'` |
| 163 |
> fmap="$prefix.fmap" |
| 164 |
> repo="$prefix.repo" |
| 165 |
> for i in $files; do |
| 166 |
> echo "include $i" >> "$fmap" |
| 167 |
> done |
| 168 |
> hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo" |
| 169 |
> hg up -q -R "$repo" |
| 170 |
> glog -R "$repo" |
| 171 |
> hg -R "$repo" manifest --debug |
| 172 |
> } |
| 173 |
|
| 174 |
full conversion |
| 175 |
|
| 176 |
$ hg convert --datesort git-repo2 fullrepo \ |
| 177 |
> --config extensions.progress= --config progress.assume-tty=1 \ |
| 178 |
> --config progress.delay=0 --config progress.changedelay=0 \ |
| 179 |
> --config progress.refresh=0 --config progress.width=60 \ |
| 180 |
> --config progress.format='topic, bar, number' |
| 181 |
\r (no-eol) (esc) |
| 182 |
scanning [===> ] 1/9\r (no-eol) (esc) |
| 183 |
scanning [========> ] 2/9\r (no-eol) (esc) |
| 184 |
scanning [=============> ] 3/9\r (no-eol) (esc) |
| 185 |
scanning [==================> ] 4/9\r (no-eol) (esc) |
| 186 |
scanning [=======================> ] 5/9\r (no-eol) (esc) |
| 187 |
scanning [============================> ] 6/9\r (no-eol) (esc) |
| 188 |
scanning [=================================> ] 7/9\r (no-eol) (esc) |
| 189 |
scanning [======================================> ] 8/9\r (no-eol) (esc) |
| 190 |
scanning [===========================================>] 9/9\r (no-eol) (esc) |
| 191 |
\r (no-eol) (esc) |
| 192 |
\r (no-eol) (esc) |
| 193 |
converting [ ] 0/9\r (no-eol) (esc) |
| 194 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 195 |
\r (no-eol) (esc) |
| 196 |
\r (no-eol) (esc) |
| 197 |
converting [===> ] 1/9\r (no-eol) (esc) |
| 198 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 199 |
\r (no-eol) (esc) |
| 200 |
\r (no-eol) (esc) |
| 201 |
converting [========> ] 2/9\r (no-eol) (esc) |
| 202 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 203 |
\r (no-eol) (esc) |
| 204 |
\r (no-eol) (esc) |
| 205 |
converting [=============> ] 3/9\r (no-eol) (esc) |
| 206 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 207 |
\r (no-eol) (esc) |
| 208 |
\r (no-eol) (esc) |
| 209 |
converting [=================> ] 4/9\r (no-eol) (esc) |
| 210 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 211 |
\r (no-eol) (esc) |
| 212 |
\r (no-eol) (esc) |
| 213 |
converting [======================> ] 5/9\r (no-eol) (esc) |
| 214 |
getting files [===> ] 1/8\r (no-eol) (esc) |
| 215 |
getting files [========> ] 2/8\r (no-eol) (esc) |
| 216 |
getting files [=============> ] 3/8\r (no-eol) (esc) |
| 217 |
getting files [==================> ] 4/8\r (no-eol) (esc) |
| 218 |
getting files [=======================> ] 5/8\r (no-eol) (esc) |
| 219 |
getting files [============================> ] 6/8\r (no-eol) (esc) |
| 220 |
getting files [=================================> ] 7/8\r (no-eol) (esc) |
| 221 |
getting files [======================================>] 8/8\r (no-eol) (esc) |
| 222 |
\r (no-eol) (esc) |
| 223 |
\r (no-eol) (esc) |
| 224 |
converting [===========================> ] 6/9\r (no-eol) (esc) |
| 225 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 226 |
\r (no-eol) (esc) |
| 227 |
\r (no-eol) (esc) |
| 228 |
converting [===============================> ] 7/9\r (no-eol) (esc) |
| 229 |
getting files [======================================>] 1/1\r (no-eol) (esc) |
| 230 |
\r (no-eol) (esc) |
| 231 |
\r (no-eol) (esc) |
| 232 |
converting [====================================> ] 8/9\r (no-eol) (esc) |
| 233 |
getting files [==================> ] 1/2\r (no-eol) (esc) |
| 234 |
getting files [======================================>] 2/2\r (no-eol) (esc) |
| 235 |
\r (no-eol) (esc) |
| 236 |
initializing destination fullrepo repository |
| 237 |
scanning source... |
| 238 |
sorting... |
| 239 |
converting... |
| 240 |
8 add foo |
| 241 |
7 change foo |
| 242 |
6 add quux |
| 243 |
5 add bar |
| 244 |
4 add baz |
| 245 |
3 Octopus merge |
| 246 |
2 change bar |
| 247 |
1 change foo |
| 248 |
0 Discard change to foo |
| 249 |
updating bookmarks |
| 250 |
$ hg up -q -R fullrepo |
| 251 |
$ glog -R fullrepo |
| 252 |
@ 9 "Discard change to foo" files: foo |
| 253 |
|\ |
| 254 |
| o 8 "change foo" files: foo |
| 255 |
| | |
| 256 |
o | 7 "change bar" files: bar |
| 257 |
|/ |
| 258 |
o 6 "(octopus merge fixup)" files: |
| 259 |
|\ |
| 260 |
| o 5 "Octopus merge" files: baz |
| 261 |
| |\ |
| 262 |
o | | 4 "add baz" files: baz |
| 263 |
| | | |
| 264 |
+---o 3 "add bar" files: bar |
| 265 |
| | |
| 266 |
o | 2 "add quux" files: quux |
| 267 |
| | |
| 268 |
| o 1 "change foo" files: foo |
| 269 |
|/ |
| 270 |
o 0 "add foo" files: foo |
| 271 |
|
| 272 |
$ hg -R fullrepo manifest --debug |
| 273 |
245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
| 274 |
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
| 275 |
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
| 276 |
88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
| 277 |
$ splitrepo 'octopus merge' 'foo bar baz' |
| 278 |
% foo bar baz: octopus merge |
| 279 |
@ 8 "Discard change to foo" files: foo |
| 280 |
|\ |
| 281 |
| o 7 "change foo" files: foo |
| 282 |
| | |
| 283 |
o | 6 "change bar" files: bar |
| 284 |
|/ |
| 285 |
o 5 "(octopus merge fixup)" files: |
| 286 |
|\ |
| 287 |
| o 4 "Octopus merge" files: baz |
| 288 |
| |\ |
| 289 |
o | | 3 "add baz" files: baz |
| 290 |
| | | |
| 291 |
+---o 2 "add bar" files: bar |
| 292 |
| | |
| 293 |
| o 1 "change foo" files: foo |
| 294 |
|/ |
| 295 |
o 0 "add foo" files: foo |
| 296 |
|
| 297 |
245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar |
| 298 |
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
| 299 |
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
| 300 |
$ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux' |
| 301 |
% foo baz quux: only some parents of an octopus merge; "discard" a head |
| 302 |
@ 6 "Discard change to foo" files: foo |
| 303 |
| |
| 304 |
o 5 "change foo" files: foo |
| 305 |
| |
| 306 |
o 4 "Octopus merge" files: |
| 307 |
|\ |
| 308 |
| o 3 "add baz" files: baz |
| 309 |
| | |
| 310 |
| o 2 "add quux" files: quux |
| 311 |
| | |
| 312 |
o | 1 "change foo" files: foo |
| 313 |
|/ |
| 314 |
o 0 "add foo" files: foo |
| 315 |
|
| 316 |
354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz |
| 317 |
9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo |
| 318 |
88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux |
| 319 |
|
| 320 |
test importing git renames and copies |
| 321 |
|
| 322 |
$ cd git-repo2 |
| 323 |
$ git mv foo foo-renamed |
| 324 |
since bar is not touched in this commit, this copy will not be detected |
| 325 |
$ cp bar bar-copied |
| 326 |
$ cp baz baz-copied |
| 327 |
$ cp baz baz-copied2 |
| 328 |
$ cp baz ba-copy |
| 329 |
$ echo baz2 >> baz |
| 330 |
$ git add bar-copied baz-copied baz-copied2 ba-copy |
| 331 |
$ commit -a -m 'rename and copy' |
| 332 |
$ cd .. |
| 333 |
|
| 334 |
input validation |
| 335 |
$ hg convert --config convert.git.similarity=foo --datesort git-repo2 fullrepo |
| 336 |
config error: convert.git.similarity is not a valid integer ('foo') |
| 337 |
[30] |
| 338 |
$ hg convert --config convert.git.similarity=-1 --datesort git-repo2 fullrepo |
| 339 |
abort: similarity must be between 0 and 100 |
| 340 |
[255] |
| 341 |
$ hg convert --config convert.git.similarity=101 --datesort git-repo2 fullrepo |
| 342 |
abort: similarity must be between 0 and 100 |
| 343 |
[255] |
| 344 |
|
| 345 |
$ hg -q convert --config convert.git.similarity=100 --datesort git-repo2 fullrepo |
| 346 |
$ hg -R fullrepo status -C --change master |
| 347 |
M baz |
| 348 |
A ba-copy |
| 349 |
baz |
| 350 |
A bar-copied |
| 351 |
A baz-copied |
| 352 |
baz |
| 353 |
A baz-copied2 |
| 354 |
baz |
| 355 |
A foo-renamed |
| 356 |
foo |
| 357 |
R foo |
| 358 |
|
| 359 |
Ensure that the modification to the copy source was preserved |
| 360 |
(there was a bug where if the copy dest was alphabetically prior to the copy |
| 361 |
source, the copy source took the contents of the copy dest) |
| 362 |
$ hg cat -r tip fullrepo/baz |
| 363 |
baz |
| 364 |
baz2 |
| 365 |
|
| 366 |
$ cd git-repo2 |
| 367 |
$ echo bar2 >> bar |
| 368 |
$ commit -a -m 'change bar' |
| 369 |
$ cp bar bar-copied2 |
| 370 |
$ git add bar-copied2 |
| 371 |
$ commit -a -m 'copy with no changes' |
| 372 |
$ cd .. |
| 373 |
|
| 374 |
$ hg -q convert --config convert.git.similarity=100 \ |
| 375 |
> --config convert.git.findcopiesharder=1 --datesort git-repo2 fullrepo |
| 376 |
$ hg -R fullrepo status -C --change master |
| 377 |
A bar-copied2 |
| 378 |
bar |
| 379 |
|
| 380 |
renamelimit config option works |
| 381 |
|
| 382 |
$ cd git-repo2 |
| 383 |
$ cat >> copy-source << EOF |
| 384 |
> sc0 |
| 385 |
> sc1 |
| 386 |
> sc2 |
| 387 |
> sc3 |
| 388 |
> sc4 |
| 389 |
> sc5 |
| 390 |
> sc6 |
| 391 |
> EOF |
| 392 |
$ git add copy-source |
| 393 |
$ commit -m 'add copy-source' |
| 394 |
$ cp copy-source source-copy0 |
| 395 |
$ echo 0 >> source-copy0 |
| 396 |
$ cp copy-source source-copy1 |
| 397 |
$ echo 1 >> source-copy1 |
| 398 |
$ git add source-copy0 source-copy1 |
| 399 |
$ commit -a -m 'copy copy-source 2 times' |
| 400 |
$ cd .. |
| 401 |
|
| 402 |
$ hg -q convert --config convert.git.renamelimit=1 \ |
| 403 |
> --config convert.git.findcopiesharder=true --datesort git-repo2 fullrepo2 |
| 404 |
$ hg -R fullrepo2 status -C --change master |
| 405 |
A source-copy0 |
| 406 |
A source-copy1 |
| 407 |
|
| 408 |
$ hg -q convert --config convert.git.renamelimit=100 \ |
| 409 |
> --config convert.git.findcopiesharder=true --datesort git-repo2 fullrepo3 |
| 410 |
$ hg -R fullrepo3 status -C --change master |
| 411 |
A source-copy0 |
| 412 |
copy-source |
| 413 |
A source-copy1 |
| 414 |
copy-source |
| 415 |
|
| 416 |
test binary conversion (issue1359) |
| 417 |
|
| 418 |
$ count=19 |
| 419 |
$ mkdir git-repo3 |
| 420 |
$ cd git-repo3 |
| 421 |
$ git init >/dev/null 2>/dev/null |
| 422 |
$ "$PYTHON" -c 'import struct; open("b", "wb").write(b"".join([struct.Struct(">B").pack(i) for i in range(256)])*16)' |
| 423 |
$ git add b |
| 424 |
$ commit -a -m addbinary |
| 425 |
$ cd .. |
| 426 |
|
| 427 |
convert binary file |
| 428 |
|
| 429 |
$ hg convert git-repo3 git-repo3-hg |
| 430 |
initializing destination git-repo3-hg repository |
| 431 |
scanning source... |
| 432 |
sorting... |
| 433 |
converting... |
| 434 |
0 addbinary |
| 435 |
updating bookmarks |
| 436 |
$ cd git-repo3-hg |
| 437 |
$ hg up -C |
| 438 |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 439 |
$ "$PYTHON" -c 'print(len(open("b", "rb").read()))' |
| 440 |
4096 |
| 441 |
$ cd .. |
| 442 |
|
| 443 |
test author vs committer |
| 444 |
|
| 445 |
$ mkdir git-repo4 |
| 446 |
$ cd git-repo4 |
| 447 |
$ git init >/dev/null 2>/dev/null |
| 448 |
$ echo >> foo |
| 449 |
$ git add foo |
| 450 |
$ commit -a -m addfoo |
| 451 |
$ echo >> foo |
| 452 |
$ GIT_AUTHOR_NAME="nottest" |
| 453 |
$ commit -a -m addfoo2 |
| 454 |
$ cd .. |
| 455 |
|
| 456 |
convert author committer |
| 457 |
|
| 458 |
$ hg convert git-repo4 git-repo4-hg |
| 459 |
initializing destination git-repo4-hg repository |
| 460 |
scanning source... |
| 461 |
sorting... |
| 462 |
converting... |
| 463 |
1 addfoo |
| 464 |
0 addfoo2 |
| 465 |
updating bookmarks |
| 466 |
$ hg -R git-repo4-hg log -v |
| 467 |
changeset: 1:d63e967f93da |
| 468 |
bookmark: master |
| 469 |
tag: tip |
| 470 |
user: nottest <[email protected]> |
| 471 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 472 |
files: foo |
| 473 |
description: |
| 474 |
addfoo2 |
| 475 |
|
| 476 |
committer: test <[email protected]> |
| 477 |
|
| 478 |
|
| 479 |
changeset: 0:0735477b0224 |
| 480 |
user: test <[email protected]> |
| 481 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 482 |
files: foo |
| 483 |
description: |
| 484 |
addfoo |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
Various combinations of committeractions fail |
| 489 |
|
| 490 |
$ hg --config convert.git.committeractions=messagedifferent,messagealways convert git-repo4 bad-committer |
| 491 |
initializing destination bad-committer repository |
| 492 |
abort: committeractions cannot define both messagedifferent and messagealways |
| 493 |
[255] |
| 494 |
|
| 495 |
$ hg --config convert.git.committeractions=dropcommitter,replaceauthor convert git-repo4 bad-committer |
| 496 |
initializing destination bad-committer repository |
| 497 |
abort: committeractions cannot define both dropcommitter and replaceauthor |
| 498 |
[255] |
| 499 |
|
| 500 |
$ hg --config convert.git.committeractions=dropcommitter,messagealways convert git-repo4 bad-committer |
| 501 |
initializing destination bad-committer repository |
| 502 |
abort: committeractions cannot define both dropcommitter and messagealways |
| 503 |
[255] |
| 504 |
|
| 505 |
custom prefix on messagedifferent works |
| 506 |
|
| 507 |
$ hg --config convert.git.committeractions=messagedifferent=different: convert git-repo4 git-repo4-hg-messagedifferentprefix |
| 508 |
initializing destination git-repo4-hg-messagedifferentprefix repository |
| 509 |
scanning source... |
| 510 |
sorting... |
| 511 |
converting... |
| 512 |
1 addfoo |
| 513 |
0 addfoo2 |
| 514 |
updating bookmarks |
| 515 |
|
| 516 |
$ hg -R git-repo4-hg-messagedifferentprefix log -v |
| 517 |
changeset: 1:2fe0c98a109d |
| 518 |
bookmark: master |
| 519 |
tag: tip |
| 520 |
user: nottest <[email protected]> |
| 521 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 522 |
files: foo |
| 523 |
description: |
| 524 |
addfoo2 |
| 525 |
|
| 526 |
different: test <[email protected]> |
| 527 |
|
| 528 |
|
| 529 |
changeset: 0:0735477b0224 |
| 530 |
user: test <[email protected]> |
| 531 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 532 |
files: foo |
| 533 |
description: |
| 534 |
addfoo |
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
messagealways will always add the "committer: " line even if committer identical |
| 539 |
|
| 540 |
$ hg --config convert.git.committeractions=messagealways convert git-repo4 git-repo4-hg-messagealways |
| 541 |
initializing destination git-repo4-hg-messagealways repository |
| 542 |
scanning source... |
| 543 |
sorting... |
| 544 |
converting... |
| 545 |
1 addfoo |
| 546 |
0 addfoo2 |
| 547 |
updating bookmarks |
| 548 |
|
| 549 |
$ hg -R git-repo4-hg-messagealways log -v |
| 550 |
changeset: 1:8db057d8cd37 |
| 551 |
bookmark: master |
| 552 |
tag: tip |
| 553 |
user: nottest <[email protected]> |
| 554 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 555 |
files: foo |
| 556 |
description: |
| 557 |
addfoo2 |
| 558 |
|
| 559 |
committer: test <[email protected]> |
| 560 |
|
| 561 |
|
| 562 |
changeset: 0:8f71fe9c98be |
| 563 |
user: test <[email protected]> |
| 564 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 565 |
files: foo |
| 566 |
description: |
| 567 |
addfoo |
| 568 |
|
| 569 |
committer: test <[email protected]> |
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
custom prefix on messagealways works |
| 574 |
|
| 575 |
$ hg --config convert.git.committeractions=messagealways=always: convert git-repo4 git-repo4-hg-messagealwaysprefix |
| 576 |
initializing destination git-repo4-hg-messagealwaysprefix repository |
| 577 |
scanning source... |
| 578 |
sorting... |
| 579 |
converting... |
| 580 |
1 addfoo |
| 581 |
0 addfoo2 |
| 582 |
updating bookmarks |
| 583 |
|
| 584 |
$ hg -R git-repo4-hg-messagealwaysprefix log -v |
| 585 |
changeset: 1:83c17174de79 |
| 586 |
bookmark: master |
| 587 |
tag: tip |
| 588 |
user: nottest <[email protected]> |
| 589 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 590 |
files: foo |
| 591 |
description: |
| 592 |
addfoo2 |
| 593 |
|
| 594 |
always: test <[email protected]> |
| 595 |
|
| 596 |
|
| 597 |
changeset: 0:2ac9bcb3534a |
| 598 |
user: test <[email protected]> |
| 599 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 600 |
files: foo |
| 601 |
description: |
| 602 |
addfoo |
| 603 |
|
| 604 |
always: test <[email protected]> |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
replaceauthor replaces author with committer |
| 609 |
|
| 610 |
$ hg --config convert.git.committeractions=replaceauthor convert git-repo4 git-repo4-hg-replaceauthor |
| 611 |
initializing destination git-repo4-hg-replaceauthor repository |
| 612 |
scanning source... |
| 613 |
sorting... |
| 614 |
converting... |
| 615 |
1 addfoo |
| 616 |
0 addfoo2 |
| 617 |
updating bookmarks |
| 618 |
|
| 619 |
$ hg -R git-repo4-hg-replaceauthor log -v |
| 620 |
changeset: 1:122c1d8999ea |
| 621 |
bookmark: master |
| 622 |
tag: tip |
| 623 |
user: test <[email protected]> |
| 624 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 625 |
files: foo |
| 626 |
description: |
| 627 |
addfoo2 |
| 628 |
|
| 629 |
|
| 630 |
changeset: 0:0735477b0224 |
| 631 |
user: test <[email protected]> |
| 632 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 633 |
files: foo |
| 634 |
description: |
| 635 |
addfoo |
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
dropcommitter removes the committer |
| 640 |
|
| 641 |
$ hg --config convert.git.committeractions=dropcommitter convert git-repo4 git-repo4-hg-dropcommitter |
| 642 |
initializing destination git-repo4-hg-dropcommitter repository |
| 643 |
scanning source... |
| 644 |
sorting... |
| 645 |
converting... |
| 646 |
1 addfoo |
| 647 |
0 addfoo2 |
| 648 |
updating bookmarks |
| 649 |
|
| 650 |
$ hg -R git-repo4-hg-dropcommitter log -v |
| 651 |
changeset: 1:190b2da396cc |
| 652 |
bookmark: master |
| 653 |
tag: tip |
| 654 |
user: nottest <[email protected]> |
| 655 |
date: Mon Jan 01 00:00:21 2007 +0000 |
| 656 |
files: foo |
| 657 |
description: |
| 658 |
addfoo2 |
| 659 |
|
| 660 |
|
| 661 |
changeset: 0:0735477b0224 |
| 662 |
user: test <[email protected]> |
| 663 |
date: Mon Jan 01 00:00:20 2007 +0000 |
| 664 |
files: foo |
| 665 |
description: |
| 666 |
addfoo |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
--sourceorder should fail |
| 671 |
|
| 672 |
$ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg |
| 673 |
initializing destination git-repo4-sourcesort-hg repository |
| 674 |
abort: --sourcesort is not supported by this data source |
| 675 |
[255] |
| 676 |
|
| 677 |
test converting certain branches |
| 678 |
|
| 679 |
$ mkdir git-testrevs |
| 680 |
$ cd git-testrevs |
| 681 |
$ git init |
| 682 |
Initialized empty Git repository in $TESTTMP/git-testrevs/.git/ |
| 683 |
$ echo a >> a ; git add a > /dev/null; git commit -m 'first' > /dev/null |
| 684 |
$ echo a >> a ; git add a > /dev/null; git commit -m 'master commit' > /dev/null |
| 685 |
$ git checkout -b goodbranch 'HEAD^' |
| 686 |
Switched to a new branch 'goodbranch' |
| 687 |
$ echo a >> b ; git add b > /dev/null; git commit -m 'good branch commit' > /dev/null |
| 688 |
$ git checkout -b badbranch 'HEAD^' |
| 689 |
Switched to a new branch 'badbranch' |
| 690 |
$ echo a >> c ; git add c > /dev/null; git commit -m 'bad branch commit' > /dev/null |
| 691 |
$ cd .. |
| 692 |
$ hg convert git-testrevs hg-testrevs --rev master --rev goodbranch |
| 693 |
initializing destination hg-testrevs repository |
| 694 |
scanning source... |
| 695 |
sorting... |
| 696 |
converting... |
| 697 |
2 first |
| 698 |
1 good branch commit |
| 699 |
0 master commit |
| 700 |
updating bookmarks |
| 701 |
$ cd hg-testrevs |
| 702 |
$ hg log -G -T '{rev} {bookmarks}' |
| 703 |
o 2 master |
| 704 |
| |
| 705 |
| o 1 goodbranch |
| 706 |
|/ |
| 707 |
o 0 |
| 708 |
|
| 709 |
$ cd .. |
| 710 |
|
| 711 |
test sub modules |
| 712 |
|
| 713 |
$ mkdir git-repo5 |
| 714 |
$ cd git-repo5 |
| 715 |
$ git init >/dev/null 2>/dev/null |
| 716 |
$ echo 'sub' >> foo |
| 717 |
$ git add foo |
| 718 |
$ commit -a -m 'addfoo' |
| 719 |
$ BASE=`pwd` |
| 720 |
$ cd .. |
| 721 |
$ mkdir git-repo6 |
| 722 |
$ cd git-repo6 |
| 723 |
$ git init >/dev/null 2>/dev/null |
| 724 |
$ git submodule add ${BASE} >/dev/null 2>/dev/null |
| 725 |
$ commit -a -m 'addsubmodule' >/dev/null 2>/dev/null |
| 726 |
|
| 727 |
test non-tab whitespace .gitmodules |
| 728 |
|
| 729 |
$ cat >> .gitmodules <<EOF |
| 730 |
> [submodule "git-repo5"] |
| 731 |
> path = git-repo5 |
| 732 |
> url = git-repo5 |
| 733 |
> EOF |
| 734 |
$ git commit -q -a -m "weird white space submodule" |
| 735 |
$ cd .. |
| 736 |
$ hg convert git-repo6 hg-repo6 |
| 737 |
initializing destination hg-repo6 repository |
| 738 |
scanning source... |
| 739 |
sorting... |
| 740 |
converting... |
| 741 |
1 addsubmodule |
| 742 |
0 weird white space submodule |
| 743 |
updating bookmarks |
| 744 |
|
| 745 |
$ rm -rf hg-repo6 |
| 746 |
$ cd git-repo6 |
| 747 |
$ git reset --hard 'HEAD^' > /dev/null |
| 748 |
|
| 749 |
test missing .gitmodules |
| 750 |
|
| 751 |
$ git submodule add ../git-repo4 >/dev/null 2>/dev/null |
| 752 |
$ git checkout HEAD -- .gitmodules |
| 753 |
$ git rm .gitmodules |
| 754 |
rm '.gitmodules' |
| 755 |
$ git commit -q -m "remove .gitmodules" .gitmodules |
| 756 |
$ git commit -q -m "missing .gitmodules" |
| 757 |
$ cd .. |
| 758 |
$ hg convert git-repo6 hg-repo6 --traceback 2>&1 | grep -v "fatal: Path '.gitmodules' does not exist" |
| 759 |
initializing destination hg-repo6 repository |
| 760 |
scanning source... |
| 761 |
sorting... |
| 762 |
converting... |
| 763 |
2 addsubmodule |
| 764 |
1 remove .gitmodules |
| 765 |
0 missing .gitmodules |
| 766 |
warning: cannot read submodules config file in * (glob) |
| 767 |
updating bookmarks |
| 768 |
$ rm -rf hg-repo6 |
| 769 |
$ cd git-repo6 |
| 770 |
$ rm -rf git-repo4 |
| 771 |
$ git reset --hard 'HEAD^^' > /dev/null |
| 772 |
$ cd .. |
| 773 |
|
| 774 |
test invalid splicemap1 |
| 775 |
|
| 776 |
$ cat > splicemap <<EOF |
| 777 |
> $VALIDID1 |
| 778 |
> EOF |
| 779 |
$ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap1-hg |
| 780 |
initializing destination git-repo2-splicemap1-hg repository |
| 781 |
abort: syntax error in splicemap(1): child parent1[,parent2] expected |
| 782 |
[255] |
| 783 |
|
| 784 |
test invalid splicemap2 |
| 785 |
|
| 786 |
$ cat > splicemap <<EOF |
| 787 |
> $VALIDID1 $VALIDID2, $VALIDID2, $VALIDID2 |
| 788 |
> EOF |
| 789 |
$ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap2-hg |
| 790 |
initializing destination git-repo2-splicemap2-hg repository |
| 791 |
abort: syntax error in splicemap(1): child parent1[,parent2] expected |
| 792 |
[255] |
| 793 |
|
| 794 |
test invalid splicemap3 |
| 795 |
|
| 796 |
$ cat > splicemap <<EOF |
| 797 |
> $INVALIDID1 $INVALIDID2 |
| 798 |
> EOF |
| 799 |
$ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap3-hg |
| 800 |
initializing destination git-repo2-splicemap3-hg repository |
| 801 |
abort: splicemap entry afd12345af is not a valid revision identifier |
| 802 |
[255] |
| 803 |
|
| 804 |
convert sub modules |
| 805 |
$ hg convert git-repo6 git-repo6-hg |
| 806 |
initializing destination git-repo6-hg repository |
| 807 |
scanning source... |
| 808 |
sorting... |
| 809 |
converting... |
| 810 |
0 addsubmodule |
| 811 |
updating bookmarks |
| 812 |
$ hg -R git-repo6-hg log -v |
| 813 |
changeset: 0:* (glob) |
| 814 |
bookmark: master |
| 815 |
tag: tip |
| 816 |
user: nottest <[email protected]> |
| 817 |
date: Mon Jan 01 00:00:23 2007 +0000 |
| 818 |
files: .hgsub .hgsubstate |
| 819 |
description: |
| 820 |
addsubmodule |
| 821 |
|
| 822 |
committer: test <[email protected]> |
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
$ cd git-repo6-hg |
| 827 |
$ hg up >/dev/null 2>/dev/null |
| 828 |
$ cat .hgsubstate |
| 829 |
* git-repo5 (glob) |
| 830 |
$ cd git-repo5 |
| 831 |
$ cat foo |
| 832 |
sub |
| 833 |
|
| 834 |
$ cd ../.. |
| 835 |
|
| 836 |
make sure rename detection doesn't break removing and adding gitmodules |
| 837 |
|
| 838 |
$ cd git-repo6 |
| 839 |
$ git mv .gitmodules .gitmodules-renamed |
| 840 |
$ commit -a -m 'rename .gitmodules' |
| 841 |
$ git mv .gitmodules-renamed .gitmodules |
| 842 |
$ commit -a -m 'rename .gitmodules back' |
| 843 |
$ cd .. |
| 844 |
|
| 845 |
$ hg --config convert.git.similarity=100 convert -q git-repo6 git-repo6-hg |
| 846 |
$ hg -R git-repo6-hg log -r 'tip^' -T "{desc|firstline}\n" |
| 847 |
rename .gitmodules |
| 848 |
$ hg -R git-repo6-hg status -C --change 'tip^' |
| 849 |
A .gitmodules-renamed |
| 850 |
R .hgsub |
| 851 |
R .hgsubstate |
| 852 |
$ hg -R git-repo6-hg log -r tip -T "{desc|firstline}\n" |
| 853 |
rename .gitmodules back |
| 854 |
$ hg -R git-repo6-hg status -C --change tip |
| 855 |
A .hgsub |
| 856 |
A .hgsubstate |
| 857 |
R .gitmodules-renamed |
| 858 |
|
| 859 |
convert the revision removing '.gitmodules' itself (and related |
| 860 |
submodules) |
| 861 |
|
| 862 |
$ cd git-repo6 |
| 863 |
$ git rm .gitmodules |
| 864 |
rm '.gitmodules' |
| 865 |
$ git rm --cached git-repo5 |
| 866 |
rm 'git-repo5' |
| 867 |
$ commit -a -m 'remove .gitmodules and submodule git-repo5' |
| 868 |
$ cd .. |
| 869 |
|
| 870 |
$ hg convert -q git-repo6 git-repo6-hg |
| 871 |
$ hg -R git-repo6-hg tip -T "{desc|firstline}\n" |
| 872 |
remove .gitmodules and submodule git-repo5 |
| 873 |
$ hg -R git-repo6-hg tip -T "{file_dels}\n" |
| 874 |
.hgsub .hgsubstate |
| 875 |
|
| 876 |
skip submodules in the conversion |
| 877 |
|
| 878 |
$ hg convert -q git-repo6 no-submodules --config convert.git.skipsubmodules=True |
| 879 |
$ hg -R no-submodules manifest --all |
| 880 |
.gitmodules-renamed |
| 881 |
|
| 882 |
convert using a different remote prefix |
| 883 |
$ git init git-repo7 |
| 884 |
Initialized empty Git repository in $TESTTMP/git-repo7/.git/ |
| 885 |
$ cd git-repo7 |
| 886 |
TODO: it'd be nice to use (?) lines instead of grep -v to handle the |
| 887 |
git output variance, but that doesn't currently work in the middle of |
| 888 |
a block, so do this for now. |
| 889 |
$ touch a && git add a && git commit -am "commit a" | grep -v changed |
| 890 |
[master (root-commit) 8ae5f69] commit a |
| 891 |
Author: nottest <[email protected]> |
| 892 |
create mode 100644 a |
| 893 |
$ cd .. |
| 894 |
$ git clone git-repo7 git-repo7-client |
| 895 |
Cloning into 'git-repo7-client'... |
| 896 |
done. |
| 897 |
$ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
| 898 |
initializing destination hg-repo7 repository |
| 899 |
scanning source... |
| 900 |
sorting... |
| 901 |
converting... |
| 902 |
0 commit a |
| 903 |
updating bookmarks |
| 904 |
$ hg -R hg-repo7 bookmarks |
| 905 |
master 0:03bf38caa4c6 |
| 906 |
origin/master 0:03bf38caa4c6 |
| 907 |
|
| 908 |
Run convert when the remote branches have changed |
| 909 |
(there was an old bug where the local convert read branches from the server) |
| 910 |
|
| 911 |
$ cd git-repo7 |
| 912 |
$ echo a >> a |
| 913 |
$ git commit -q -am "move master forward" |
| 914 |
$ cd .. |
| 915 |
$ rm -rf hg-repo7 |
| 916 |
$ hg convert --config convert.git.remoteprefix=origin git-repo7-client hg-repo7 |
| 917 |
initializing destination hg-repo7 repository |
| 918 |
scanning source... |
| 919 |
sorting... |
| 920 |
converting... |
| 921 |
0 commit a |
| 922 |
updating bookmarks |
| 923 |
$ hg -R hg-repo7 bookmarks |
| 924 |
master 0:03bf38caa4c6 |
| 925 |
origin/master 0:03bf38caa4c6 |
| 926 |
|
| 927 |
damaged git repository tests: |
| 928 |
In case the hard-coded hashes change, the following commands can be used to |
| 929 |
list the hashes and their corresponding types in the repository: |
| 930 |
cd git-repo4/.git/objects |
| 931 |
find . -type f | cut -c 3- | sed 's_/__' | xargs -n 1 -t git cat-file -t |
| 932 |
cd ../../.. |
| 933 |
|
| 934 |
damage git repository by renaming a commit object |
| 935 |
$ COMMIT_OBJ=1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
| 936 |
$ mv git-repo4/.git/objects/$COMMIT_OBJ git-repo4/.git/objects/$COMMIT_OBJ.tmp |
| 937 |
$ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
| 938 |
abort: cannot retrieve number of commits in $TESTTMP/git-repo4/.git |
| 939 |
$ mv git-repo4/.git/objects/$COMMIT_OBJ.tmp git-repo4/.git/objects/$COMMIT_OBJ |
| 940 |
damage git repository by renaming a blob object |
| 941 |
|
| 942 |
$ BLOB_OBJ=8b/137891791fe96927ad78e64b0aad7bded08bdc |
| 943 |
$ mv git-repo4/.git/objects/$BLOB_OBJ git-repo4/.git/objects/$BLOB_OBJ.tmp |
| 944 |
$ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
| 945 |
abort: cannot read 'blob' object at 8b137891791fe96927ad78e64b0aad7bded08bdc |
| 946 |
$ mv git-repo4/.git/objects/$BLOB_OBJ.tmp git-repo4/.git/objects/$BLOB_OBJ |
| 947 |
damage git repository by renaming a tree object |
| 948 |
|
| 949 |
$ TREE_OBJ=72/49f083d2a63a41cc737764a86981eb5f3e4635 |
| 950 |
$ mv git-repo4/.git/objects/$TREE_OBJ git-repo4/.git/objects/$TREE_OBJ.tmp |
| 951 |
$ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:' |
| 952 |
abort: cannot read changes in 1c0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd |
| 953 |
|
| 954 |
#if no-windows git19 |
| 955 |
|
| 956 |
test for escaping the repo name (CVE-2016-3069) |
| 957 |
|
| 958 |
$ git init '`echo pwned >COMMAND-INJECTION`' |
| 959 |
Initialized empty Git repository in $TESTTMP/`echo pwned >COMMAND-INJECTION`/.git/ |
| 960 |
$ cd '`echo pwned >COMMAND-INJECTION`' |
| 961 |
$ git commit -q --allow-empty -m 'empty' |
| 962 |
$ cd .. |
| 963 |
$ hg convert '`echo pwned >COMMAND-INJECTION`' 'converted' |
| 964 |
initializing destination converted repository |
| 965 |
scanning source... |
| 966 |
sorting... |
| 967 |
converting... |
| 968 |
0 empty |
| 969 |
updating bookmarks |
| 970 |
$ test -f COMMAND-INJECTION |
| 971 |
[1] |
| 972 |
|
| 973 |
test for safely passing paths to git (CVE-2016-3105) |
| 974 |
|
| 975 |
$ git init 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' |
| 976 |
Initialized empty Git repository in $TESTTMP/ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #/.git/ |
| 977 |
$ cd 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' |
| 978 |
$ git commit -q --allow-empty -m 'empty' |
| 979 |
$ cd .. |
| 980 |
$ hg convert 'ext::sh -c echo% pwned% >GIT-EXT-COMMAND-INJECTION% #' 'converted-git-ext' |
| 981 |
initializing destination converted-git-ext repository |
| 982 |
scanning source... |
| 983 |
sorting... |
| 984 |
converting... |
| 985 |
0 empty |
| 986 |
updating bookmarks |
| 987 |
$ test -f GIT-EXT-COMMAND-INJECTION |
| 988 |
[1] |
| 989 |
|
| 990 |
#endif |
| 991 |
|
| 992 |
Conversion of extra commit metadata to extras works |
| 993 |
|
| 994 |
$ git init gitextras >/dev/null 2>/dev/null |
| 995 |
$ cd gitextras |
| 996 |
$ touch foo |
| 997 |
$ git add foo |
| 998 |
$ commit -m initial |
| 999 |
$ echo 1 > foo |
| 1000 |
$ tree=`git write-tree` |
| 1001 |
|
| 1002 |
Git doesn't provider a user-facing API to write extra metadata into the |
| 1003 |
commit, so create the commit object by hand |
| 1004 |
|
| 1005 |
$ git hash-object -t commit -w --stdin << EOF |
| 1006 |
> tree ${tree} |
| 1007 |
> parent ba6b1344e977ece9e00958dbbf17f1f09384b2c1 |
| 1008 |
> author test <[email protected]> 1000000000 +0000 |
| 1009 |
> committer test <[email protected]> 1000000000 +0000 |
| 1010 |
> extra-1 extra-1 |
| 1011 |
> extra-2 extra-2 with space |
| 1012 |
> convert_revision 0000aaaabbbbccccddddeeee |
| 1013 |
> |
| 1014 |
> message with extras |
| 1015 |
> EOF |
| 1016 |
8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
| 1017 |
|
| 1018 |
$ git reset --hard 8123727c8361a4117d1a2d80e0c4e7d70c757f18 > /dev/null |
| 1019 |
|
| 1020 |
$ cd .. |
| 1021 |
|
| 1022 |
convert will not retain custom metadata keys by default |
| 1023 |
|
| 1024 |
$ hg convert gitextras hgextras1 |
| 1025 |
initializing destination hgextras1 repository |
| 1026 |
scanning source... |
| 1027 |
sorting... |
| 1028 |
converting... |
| 1029 |
1 initial |
| 1030 |
0 message with extras |
| 1031 |
updating bookmarks |
| 1032 |
|
| 1033 |
$ hg -R hgextras1 log --debug -r 1 |
| 1034 |
changeset: 1:e13a39880f68479127b2a80fa0b448cc8524aa09 |
| 1035 |
bookmark: master |
| 1036 |
tag: tip |
| 1037 |
phase: draft |
| 1038 |
parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
| 1039 |
parent: -1:0000000000000000000000000000000000000000 |
| 1040 |
manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
| 1041 |
user: test <[email protected]> |
| 1042 |
date: Sun Sep 09 01:46:40 2001 +0000 |
| 1043 |
extra: branch=default |
| 1044 |
extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
| 1045 |
description: |
| 1046 |
message with extras |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
Attempting to convert a banned extra is disallowed |
| 1051 |
|
| 1052 |
$ hg convert --config convert.git.extrakeys=tree,parent gitextras hgextras-banned |
| 1053 |
initializing destination hgextras-banned repository |
| 1054 |
abort: copying of extra key is forbidden: parent, tree |
| 1055 |
[255] |
| 1056 |
|
| 1057 |
Converting a specific extra works |
| 1058 |
|
| 1059 |
$ hg convert --config convert.git.extrakeys=extra-1 gitextras hgextras2 |
| 1060 |
initializing destination hgextras2 repository |
| 1061 |
scanning source... |
| 1062 |
sorting... |
| 1063 |
converting... |
| 1064 |
1 initial |
| 1065 |
0 message with extras |
| 1066 |
updating bookmarks |
| 1067 |
|
| 1068 |
$ hg -R hgextras2 log --debug -r 1 |
| 1069 |
changeset: 1:d40fb205d58597e6ecfd55b16f198be5bf436391 |
| 1070 |
bookmark: master |
| 1071 |
tag: tip |
| 1072 |
phase: draft |
| 1073 |
parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
| 1074 |
parent: -1:0000000000000000000000000000000000000000 |
| 1075 |
manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
| 1076 |
user: test <[email protected]> |
| 1077 |
date: Sun Sep 09 01:46:40 2001 +0000 |
| 1078 |
extra: branch=default |
| 1079 |
extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
| 1080 |
extra: extra-1=extra-1 |
| 1081 |
description: |
| 1082 |
message with extras |
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
Converting multiple extras works |
| 1087 |
|
| 1088 |
$ hg convert --config convert.git.extrakeys=extra-1,extra-2 gitextras hgextras3 |
| 1089 |
initializing destination hgextras3 repository |
| 1090 |
scanning source... |
| 1091 |
sorting... |
| 1092 |
converting... |
| 1093 |
1 initial |
| 1094 |
0 message with extras |
| 1095 |
updating bookmarks |
| 1096 |
|
| 1097 |
$ hg -R hgextras3 log --debug -r 1 |
| 1098 |
changeset: 1:0105af33379e7b6491501fd34141b7af700fe125 |
| 1099 |
bookmark: master |
| 1100 |
tag: tip |
| 1101 |
phase: draft |
| 1102 |
parent: 0:dcb68977c55cd02cbd13b901df65c4b6e7b9c4b9 |
| 1103 |
parent: -1:0000000000000000000000000000000000000000 |
| 1104 |
manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
| 1105 |
user: test <[email protected]> |
| 1106 |
date: Sun Sep 09 01:46:40 2001 +0000 |
| 1107 |
extra: branch=default |
| 1108 |
extra: convert_revision=8123727c8361a4117d1a2d80e0c4e7d70c757f18 |
| 1109 |
extra: extra-1=extra-1 |
| 1110 |
extra: extra-2=extra-2 with space |
| 1111 |
description: |
| 1112 |
message with extras |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
convert.git.saverev can be disabled to prevent convert_revision from being written |
| 1117 |
|
| 1118 |
$ hg convert --config convert.git.saverev=false gitextras hgextras4 |
| 1119 |
initializing destination hgextras4 repository |
| 1120 |
scanning source... |
| 1121 |
sorting... |
| 1122 |
converting... |
| 1123 |
1 initial |
| 1124 |
0 message with extras |
| 1125 |
updating bookmarks |
| 1126 |
|
| 1127 |
$ hg -R hgextras4 log --debug -r 1 |
| 1128 |
changeset: 1:1dcaf4ffe5bee43fa86db2800821f6f0af212c5c |
| 1129 |
bookmark: master |
| 1130 |
tag: tip |
| 1131 |
phase: draft |
| 1132 |
parent: 0:a13935fec4daf06a5a87a7307ccb0fc94f98d06d |
| 1133 |
parent: -1:0000000000000000000000000000000000000000 |
| 1134 |
manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
| 1135 |
user: test <[email protected]> |
| 1136 |
date: Sun Sep 09 01:46:40 2001 +0000 |
| 1137 |
extra: branch=default |
| 1138 |
description: |
| 1139 |
message with extras |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
convert.git.saverev and convert.git.extrakeys can be combined to preserve |
| 1144 |
convert_revision from source |
| 1145 |
|
| 1146 |
$ hg convert --config convert.git.saverev=false --config convert.git.extrakeys=convert_revision gitextras hgextras5 |
| 1147 |
initializing destination hgextras5 repository |
| 1148 |
scanning source... |
| 1149 |
sorting... |
| 1150 |
converting... |
| 1151 |
1 initial |
| 1152 |
0 message with extras |
| 1153 |
updating bookmarks |
| 1154 |
|
| 1155 |
$ hg -R hgextras5 log --debug -r 1 |
| 1156 |
changeset: 1:574d85931544d4542007664fee3747360e85ee28 |
| 1157 |
bookmark: master |
| 1158 |
tag: tip |
| 1159 |
phase: draft |
| 1160 |
parent: 0:a13935fec4daf06a5a87a7307ccb0fc94f98d06d |
| 1161 |
parent: -1:0000000000000000000000000000000000000000 |
| 1162 |
manifest: 0:6a3df4de388f3c4f8e28f4f9a814299a3cbb5f50 |
| 1163 |
user: test <[email protected]> |
| 1164 |
date: Sun Sep 09 01:46:40 2001 +0000 |
| 1165 |
extra: branch=default |
| 1166 |
extra: convert_revision=0000aaaabbbbccccddddeeee |
| 1167 |
description: |
| 1168 |
message with extras |
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
Test that date and timezone is converted correctly. |
| 1173 |
|
| 1174 |
$ git init --quiet git-repo8 |
| 1175 |
$ cd git-repo8 |
| 1176 |
$ echo a > a |
| 1177 |
$ git add a |
| 1178 |
$ GIT_COMMITTER_DATE='Wed May 07 23:41:27 2025 +0530' git commit --quiet -m a |
| 1179 |
$ cd .. |
| 1180 |
$ hg convert --quiet git-repo8 hg-repo8 |
| 1181 |
$ hg -R hg-repo8 log |
| 1182 |
changeset: 0:53e7aea86468 |
| 1183 |
bookmark: master |
| 1184 |
tag: tip |
| 1185 |
user: nottest <[email protected]> |
| 1186 |
date: Wed May 07 23:41:27 2025 +0530 |
| 1187 |
summary: a |
| 1188 |
|