| 1 |
#require hardlink |
| 2 |
|
| 3 |
$ echo "[extensions]" >> $HGRCPATH |
| 4 |
$ echo "relink=" >> $HGRCPATH |
| 5 |
|
| 6 |
$ fix_path() { |
| 7 |
> tr '\\' / |
| 8 |
> } |
| 9 |
|
| 10 |
$ cat > arelinked.py <<EOF |
| 11 |
> import os |
| 12 |
> import sys |
| 13 |
> from mercurial import ( |
| 14 |
> pycompat, |
| 15 |
> util, |
| 16 |
> ) |
| 17 |
> path1, path2 = sys.argv[1:3] |
| 18 |
> if util.samefile(pycompat.fsencode(path1), pycompat.fsencode(path2)): |
| 19 |
> print('%s == %s' % (path1, path2)) |
| 20 |
> else: |
| 21 |
> print('%s != %s' % (path1, path2)) |
| 22 |
> EOF |
| 23 |
|
| 24 |
|
| 25 |
create source repository |
| 26 |
|
| 27 |
$ hg init repo |
| 28 |
$ cd repo |
| 29 |
$ echo a > a |
| 30 |
$ echo b > b |
| 31 |
$ hg ci -Am addfile |
| 32 |
adding a |
| 33 |
adding b |
| 34 |
$ cat "$TESTDIR/binfile.bin" >> a |
| 35 |
$ cat "$TESTDIR/binfile.bin" >> b |
| 36 |
$ hg ci -Am changefiles |
| 37 |
|
| 38 |
make another commit to create files larger than 1 KB to test |
| 39 |
formatting of final byte count |
| 40 |
|
| 41 |
$ cat "$TESTDIR/binfile.bin" >> a |
| 42 |
$ cat "$TESTDIR/binfile.bin" >> b |
| 43 |
$ hg ci -m anotherchange |
| 44 |
|
| 45 |
don't sit forever trying to double-lock the source repo |
| 46 |
|
| 47 |
$ hg relink . |
| 48 |
relinking $TESTTMP/repo/.hg/store to $TESTTMP/repo/.hg/store |
| 49 |
there is nothing to relink |
| 50 |
|
| 51 |
|
| 52 |
Test files are read in binary mode |
| 53 |
|
| 54 |
$ "$PYTHON" -c "open('.hg/store/data/dummy.i', 'wb').write(b'a\r\nb\n')" |
| 55 |
$ cd .. |
| 56 |
|
| 57 |
|
| 58 |
clone and pull to break links |
| 59 |
|
| 60 |
$ hg clone --pull -r0 repo clone |
| 61 |
adding changesets |
| 62 |
adding manifests |
| 63 |
adding file changes |
| 64 |
added 1 changesets with 2 changes to 2 files |
| 65 |
new changesets 008c0c271c47 |
| 66 |
updating to branch default |
| 67 |
2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
| 68 |
$ cd clone |
| 69 |
$ hg pull -q |
| 70 |
$ echo b >> b |
| 71 |
$ hg ci -m changeb |
| 72 |
created new head |
| 73 |
$ "$PYTHON" -c "open('.hg/store/data/dummy.i', 'wb').write(b'a\nb\r\n')" |
| 74 |
|
| 75 |
|
| 76 |
relink |
| 77 |
|
| 78 |
$ hg relink --debug --config progress.debug=true | fix_path |
| 79 |
relinking $TESTTMP/repo/.hg/store to $TESTTMP/clone/.hg/store |
| 80 |
tip has 2 files, estimated total number of files: 3 |
| 81 |
collecting: 00changelog.d 1/3 files (33.33%) |
| 82 |
collecting: 00changelog.i 2/3 files (66.67%) |
| 83 |
collecting: 00manifest.i 3/3 files (100.00%) |
| 84 |
collecting: a.i 4/3 files (133.33%) |
| 85 |
collecting: b.i 5/3 files (166.67%) |
| 86 |
collecting: dummy.i 6/3 files (200.00%) |
| 87 |
collected 6 candidate storage files |
| 88 |
not linkable: 00changelog.d |
| 89 |
not linkable: 00changelog.i |
| 90 |
not linkable: 00manifest.i |
| 91 |
pruning: data/a.i 4/6 files (66.67%) |
| 92 |
not linkable: data/b.i |
| 93 |
pruning: data/dummy.i 6/6 files (100.00%) |
| 94 |
pruned down to 2 probably relinkable files |
| 95 |
relinking: data/a.i 1/2 files (50.00%) |
| 96 |
not linkable: data/dummy.i |
| 97 |
relinked 1 files (1.36 KB reclaimed) |
| 98 |
$ cd .. |
| 99 |
|
| 100 |
|
| 101 |
check hardlinks |
| 102 |
|
| 103 |
$ "$PYTHON" arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i |
| 104 |
repo/.hg/store/data/a.i == clone/.hg/store/data/a.i |
| 105 |
$ "$PYTHON" arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i |
| 106 |
repo/.hg/store/data/b.i != clone/.hg/store/data/b.i |