2014-08-06 20:43:59 +04:00
|
|
|
#require hardlink
|
2012-06-15 02:02:27 +04:00
|
|
|
|
2010-08-30 09:01:57 +04:00
|
|
|
$ echo "[extensions]" >> $HGRCPATH
|
|
|
|
$ echo "relink=" >> $HGRCPATH
|
|
|
|
|
|
|
|
$ fix_path() {
|
|
|
|
> tr '\\' /
|
|
|
|
> }
|
|
|
|
|
|
|
|
$ cat > arelinked.py <<EOF
|
2017-08-23 00:11:30 +03:00
|
|
|
> from __future__ import absolute_import, print_function
|
|
|
|
> import os
|
|
|
|
> import sys
|
2010-08-30 09:01:57 +04:00
|
|
|
> from mercurial import util
|
|
|
|
> path1, path2 = sys.argv[1:3]
|
|
|
|
> if util.samefile(path1, path2):
|
2017-08-23 00:11:30 +03:00
|
|
|
> print('%s == %s' % (path1, path2))
|
2010-08-30 09:01:57 +04:00
|
|
|
> else:
|
2017-08-23 00:11:30 +03:00
|
|
|
> print('%s != %s' % (path1, path2))
|
2010-08-30 09:01:57 +04:00
|
|
|
> EOF
|
|
|
|
|
|
|
|
|
|
|
|
create source repository
|
|
|
|
|
|
|
|
$ hg init repo
|
|
|
|
$ cd repo
|
|
|
|
$ echo a > a
|
|
|
|
$ echo b > b
|
|
|
|
$ hg ci -Am addfile
|
|
|
|
adding a
|
|
|
|
adding b
|
2012-04-03 21:06:35 +04:00
|
|
|
$ cat "$TESTDIR/binfile.bin" >> a
|
|
|
|
$ cat "$TESTDIR/binfile.bin" >> b
|
2010-08-30 09:01:57 +04:00
|
|
|
$ hg ci -Am changefiles
|
|
|
|
|
2011-03-16 15:51:47 +03:00
|
|
|
make another commit to create files larger than 1 KB to test
|
|
|
|
formatting of final byte count
|
|
|
|
|
2012-04-03 21:06:35 +04:00
|
|
|
$ cat "$TESTDIR/binfile.bin" >> a
|
|
|
|
$ cat "$TESTDIR/binfile.bin" >> b
|
2011-03-16 15:51:47 +03:00
|
|
|
$ hg ci -m anotherchange
|
|
|
|
|
2011-03-16 17:34:10 +03:00
|
|
|
don't sit forever trying to double-lock the source repo
|
|
|
|
|
|
|
|
$ hg relink .
|
2017-12-11 06:50:57 +03:00
|
|
|
relinking $TESTTMP/repo/.hg/store to $TESTTMP/repo/.hg/store
|
2011-03-16 17:34:10 +03:00
|
|
|
there is nothing to relink
|
|
|
|
|
2011-03-16 18:07:06 +03:00
|
|
|
|
2010-08-30 09:01:57 +04:00
|
|
|
Test files are read in binary mode
|
|
|
|
|
2014-10-15 23:35:59 +04:00
|
|
|
$ $PYTHON -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
|
2010-08-30 09:01:57 +04:00
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
|
|
|
|
clone and pull to break links
|
|
|
|
|
|
|
|
$ hg clone --pull -r0 repo clone
|
|
|
|
adding changesets
|
|
|
|
adding manifests
|
|
|
|
adding file changes
|
|
|
|
added 1 changesets with 2 changes to 2 files
|
2017-10-12 10:39:50 +03:00
|
|
|
new changesets 008c0c271c47
|
2010-08-30 09:01:57 +04:00
|
|
|
updating to branch default
|
|
|
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ cd clone
|
|
|
|
$ hg pull -q
|
|
|
|
$ echo b >> b
|
|
|
|
$ hg ci -m changeb
|
2014-10-15 23:35:59 +04:00
|
|
|
$ $PYTHON -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
|
2010-08-30 09:01:57 +04:00
|
|
|
|
|
|
|
|
|
|
|
relink
|
|
|
|
|
2015-05-10 09:40:40 +03:00
|
|
|
$ hg relink --debug --config progress.debug=true | fix_path
|
2010-10-09 07:36:10 +04:00
|
|
|
relinking $TESTTMP/repo/.hg/store to $TESTTMP/clone/.hg/store
|
2010-08-30 09:01:57 +04:00
|
|
|
tip has 2 files, estimated total number of files: 3
|
2018-03-21 23:49:51 +03:00
|
|
|
progress: collecting: 00changelog.i 1/3 files (33.33%)
|
|
|
|
progress: collecting: 00manifest.i 2/3 files (66.67%)
|
|
|
|
progress: collecting: a.i 3/3 files (100.00%)
|
|
|
|
progress: collecting: b.i 4/3 files (133.33%)
|
|
|
|
progress: collecting: dummy.i 5/3 files (166.67%)
|
|
|
|
progress: collecting (end)
|
2010-08-30 09:01:57 +04:00
|
|
|
collected 5 candidate storage files
|
|
|
|
not linkable: 00changelog.i
|
|
|
|
not linkable: 00manifest.i
|
2018-03-21 23:49:51 +03:00
|
|
|
progress: pruning: data/a.i 3/5 files (60.00%)
|
2010-08-30 09:01:57 +04:00
|
|
|
not linkable: data/b.i
|
2018-03-21 23:49:51 +03:00
|
|
|
progress: pruning: data/dummy.i 5/5 files (100.00%)
|
|
|
|
progress: pruning (end)
|
2010-08-30 09:01:57 +04:00
|
|
|
pruned down to 2 probably relinkable files
|
2018-03-21 23:49:51 +03:00
|
|
|
progress: relinking: data/a.i 1/2 files (50.00%)
|
2010-08-30 09:01:57 +04:00
|
|
|
not linkable: data/dummy.i
|
2018-03-21 23:49:51 +03:00
|
|
|
progress: relinking (end)
|
2014-11-12 08:41:12 +03:00
|
|
|
relinked 1 files (1.36 KB reclaimed)
|
2010-08-30 09:01:57 +04:00
|
|
|
$ cd ..
|
|
|
|
|
|
|
|
|
|
|
|
check hardlinks
|
|
|
|
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
|
2010-08-30 09:01:57 +04:00
|
|
|
repo/.hg/store/data/a.i == clone/.hg/store/data/a.i
|
2017-06-20 16:45:02 +03:00
|
|
|
$ $PYTHON arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
|
2010-08-30 09:01:57 +04:00
|
|
|
repo/.hg/store/data/b.i != clone/.hg/store/data/b.i
|
|
|
|
|