tests/test-convert-hg-sink
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Thu, 04 Oct 2007 23:21:37 -0300
changeset 5378 8a2915f57dfc
parent 5279 2dbd750b3ddd
permissions -rwxr-xr-x
convert: add a mode where mercurial_sink skips empty revisions. The getchanges function of some converter_source classes can return some false positives. I.e. they sometimes claim that a file "foo" was changed in some revision, even though its contents are still the same. convert_svn is particularly bad, but I think this can also happen with convert_cvs and, at least in theory, with mercurial_source. For regular conversions this is not really a problem - as long as getfile returns the right contents, we'll get a converted revision with the right contents. But when we use --filemap, this could lead to superfluous revisions being converted. Instead of fixing every converter_source, I decided to change mercurial_sink to work around this problem. When --filemap is used, we're interested only in revisions that touch some specific files. If a revision doesn't change any of these files, then we're not interested in it (at least for revisions with a single parent; merges are special). For mercurial_sink, we abuse this property and rollback a commit if the manifest text hasn't changed. This avoids duplicating the logic from localrepo.filecommit to detect unchanged files.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5278
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     1
#!/bin/sh
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     2
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     3
echo "[extensions]" >> $HGRCPATH
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     4
echo "hgext.convert=" >> $HGRCPATH
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     5
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     6
hg init orig
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     7
cd orig
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     8
echo foo > foo
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
     9
echo bar > bar
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    10
hg ci -qAm 'add foo and bar' -d '0 0'
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    11
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    12
hg rm foo
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    13
hg ci -m 'remove foo' -d '0 0'
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    14
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    15
mkdir foo
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    16
echo file > foo/file
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    17
hg ci -qAm 'add foo/file' -d '0 0'
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    18
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    19
hg tag -d '0 0' some-tag
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    20
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    21
hg log
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    22
cd ..
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    23
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    24
hg convert orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    25
cd new
70e9a527cc61 convert: avoid dirstate checks; add a test
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff changeset
    26
hg out ../orig
5279
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    27
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    28
echo '% dirstate should be empty:'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    29
hg debugstate
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    30
hg parents -q
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    31
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    32
hg up -C
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    33
hg copy bar baz
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    34
echo '% put something in the dirstate:'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    35
hg debugstate > debugstate
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    36
grep baz debugstate
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    37
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    38
echo '% add a new revision in the original repo'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    39
cd ../orig
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    40
echo baz > baz
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    41
hg ci -qAm 'add baz'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    42
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    43
cd ..
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    44
hg convert orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    45
cd new
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    46
hg out ../orig
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    47
echo '% dirstate should be the same (no output below):'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    48
hg debugstate > new-debugstate
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    49
diff debugstate new-debugstate
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    50
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    51
echo '% no copies'
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    52
hg up -C
2dbd750b3ddd convert: clear the dirstate before a conversion, invalidate it afterwards
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 5278
diff changeset
    53
hg debugrename baz