tests/test-relink.t
author Matt Mackall <mpm@selenic.com>
Mon, 20 Sep 2010 16:14:05 -0500
changeset 12347 6277a9469dff
parent 12115 a0dcbcbd1590
child 12372 5163e3c8aa52
permissions -rw-r--r--
bundlerepo: restore close() method
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     1
  $ echo "[extensions]" >> $HGRCPATH
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     2
  $ echo "relink=" >> $HGRCPATH
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     3
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     4
  $ fix_path() {
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     5
  >     tr '\\' /
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     6
  > }
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     7
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     8
  $ cat > arelinked.py <<EOF
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
     9
  > import sys, os
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    10
  > from mercurial import util
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    11
  > path1, path2 = sys.argv[1:3]
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    12
  > if util.samefile(path1, path2):
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    13
  >     print '%s == %s' % (path1, path2)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    14
  > else:
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    15
  >     print '%s != %s' % (path1, path2)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    16
  > EOF
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    17
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    18
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    19
create source repository
10218
750b7a4f01f6 Add support for relinking on Windows.
Siddharth Agarwal <sid.bugzilla@gmail.com>
parents: 10217
diff changeset
    20
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    21
  $ hg init repo
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    22
  $ cd repo
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    23
  $ echo '[ui]' > .hg/hgrc
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    24
  $ echo 'username= A. Foo <a.foo@bar.com>' >> .hg/hgrc
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    25
  $ echo a > a
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    26
  $ echo b > b
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    27
  $ hg ci -Am addfile
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    28
  adding a
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    29
  adding b
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    30
  $ echo a >> a
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    31
  $ echo a >> b
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    32
  $ hg ci -Am changefiles
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    33
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    34
Test files are read in binary mode
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    35
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    36
  $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    37
  $ cd ..
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    38
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    39
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    40
clone and pull to break links
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    41
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    42
  $ hg clone --pull -r0 repo clone
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    43
  requesting all changes
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    44
  adding changesets
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    45
  adding manifests
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    46
  adding file changes
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    47
  added 1 changesets with 2 changes to 2 files
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    48
  updating to branch default
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    49
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    50
  $ cd clone
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    51
  $ echo '[ui]' >> .hg/hgrc
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    52
  $ echo 'username= A. Baz <a.baz@bar.com>' >> .hg/hgrc
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    53
  $ hg pull -q
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    54
  $ echo b >> b
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    55
  $ hg ci -m changeb
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    56
  created new head
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    57
  $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\nb\r\n')"
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    58
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    59
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    60
relink
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    61
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    62
  $ hg relink --debug | fix_path
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    63
  relinking .*/.hg/store
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    64
  tip has 2 files, estimated total number of files: 3
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    65
  collecting: 00changelog.i 1/3 files (33.33%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    66
  collecting: 00manifest.i 2/3 files (66.67%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    67
  collecting: a.i 3/3 files (100.00%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    68
  collecting: b.i 4/3 files (133.33%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    69
  collecting: dummy.i 5/3 files (166.67%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    70
  collected 5 candidate storage files
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    71
  not linkable: 00changelog.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    72
  not linkable: 00manifest.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    73
  pruning: data/a.i 3/5  files (60.00%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    74
  not linkable: data/b.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    75
  pruning: data/dummy.i 5/5  files (100.00%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    76
  pruned down to 2 probably relinkable files
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    77
  relinking: data/a.i 1/2  files (50.00%)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    78
  not linkable: data/dummy.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    79
  relinked 1 files (136 bytes reclaimed)
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    80
  $ cd ..
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    81
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    82
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    83
check hardlinks
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    84
12115
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    85
  $ python arelinked.py repo/.hg/store/data/a.i clone/.hg/store/data/a.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    86
  repo/.hg/store/data/a.i == clone/.hg/store/data/a.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    87
  $ python arelinked.py repo/.hg/store/data/b.i clone/.hg/store/data/b.i
a0dcbcbd1590 tests: unify test-relink
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 10218
diff changeset
    88
  repo/.hg/store/data/b.i != clone/.hg/store/data/b.i
10217
2bbb4c8eb27e Add test for relink extension
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    89