Debian Codegraph @

tests/test-convert-identity.t

raw
1 Testing that convert.hg.preserve-hash=true can be used to make hg
2 convert from hg repo to hg repo preserve hashes, even if the
3 computation of the files list in commits change slightly between hg
4 versions.
5
6 $ cat <<'EOF' >> "$HGRCPATH"
7 > [extensions]
8 > convert =
9 > EOF
10 $ cat <<'EOF' > changefileslist.py
11 > from mercurial import (changelog, extensions, metadata)
12 > def wrap(orig, clog, manifest, files, *args, **kwargs):
13 > files = metadata.ChangingFiles(touched=[b"a"])
14 > return orig(clog, manifest, files, *args, **kwargs)
15 > def extsetup(ui):
16 > extensions.wrapfunction(changelog.changelog, 'add', wrap)
17 > EOF
18
19 $ hg init repo
20 $ cd repo
21 $ echo a > a; hg commit -qAm a
22 $ echo b > a; hg commit -qAm b
23 $ hg up -qr 0; echo c > c; hg commit -qAm c
24 $ hg merge -qr 1
25 $ hg commit -m_ --config extensions.x=../changefileslist.py
26 $ hg log -r . -T '{node|short} {files|json}\n'
27 c085bbe93d59 ["a"]
28
29 Now that we have a commit with a files list that's not what the
30 current hg version would create, check that convert either fixes it or
31 keeps it depending on config:
32
33 $ hg convert -q . ../convert
34 $ hg --cwd ../convert log -r tip -T '{node|short} {files|json}\n'
35 b7c4d4bbacd3 []
36 $ rm -rf ../convert
37
38 $ hg convert -q . ../convert --config convert.hg.preserve-hash=true
39 $ hg --cwd ../convert log -r tip -T '{node|short} {files|json}\n'
40 c085bbe93d59 ["a"]
41 $ rm -rf ../convert