tests/test-manifest.t
author Pierre-Yves David <pierre-yves.david@fb.com>
Tue, 23 Dec 2014 15:30:38 -0800
changeset 23702 c48924787eaa
parent 23348 bbe56e07e07a
child 35400 4441705b7111
permissions -rw-r--r--
filectx.parents: enforce changeid of parent to be in own changectx ancestors Because of the way filenodes are computed, you can have multiple changesets "introducing" the same file revision. For example, in the changeset graph below, changeset 2 and 3 both change a file -to- and -from- the same content. o 3: content = new | | o 2: content = new |/ o 1: content = old In such cases, the file revision is create once, when 2 is added, and just reused for 3. So the file change in '3' (from "old" to "new)" has no linkrev pointing to it). We'll call this situation "linkrev-shadowing". As the linkrev is used for optimization purposes when walking a file history, the linkrev-shadowing results in an unexpected jump to another branch during such a walk.. This leads to multiple bugs with log, annotate and rename detection. One element to fix such bugs is to ensure that walking the file history sticks on the same topology as the changeset's history. For this purpose, we extend the logic in 'basefilectx.parents' so that it always defines the proper changeset to associate the parent file revision with. This "proper" changeset has to be an ancestor of the changeset associated with the child file revision. This logic is performed in the '_adjustlinkrev' function. This function is given the starting changeset and all the information regarding the parent file revision. If the linkrev for the file revision is an ancestor of the starting changeset, the linkrev is valid and will be used. If it is not, we detected a topological jump caused by linkrev shadowing, we are going to walk the ancestors of the starting changeset until we find one setting the file to the revision we are trying to create. The performance impact appears acceptable: - We are walking the changelog once for each filelog traversal (as there should be no overlap between searches), - changelog traversal itself is fairly cheap, compared to what is likely going to be perform on the result on the filelog traversal, - We only touch the manifest for ancestors touching the file, And such changesets are likely to be the one introducing the file. (except in pathological cases involving merge), - We use manifest diff instead of full manifest unpacking to check manifest content, so it does not involve applying multiple diffs in most case. - linkrev shadowing is not the common case. Tests for fixed issues in log, annotate and rename detection have been added. But this changeset does not solve all problems. It fixes -ancestry- computation, but if the linkrev-shadowed changesets is the starting one, we'll still get things wrong. We'll have to fix the bootstrapping of such operations in a later changeset. Also, the usage of `hg log FILE` without --follow still has issues with linkrev pointing to hidden changesets, because it relies on the `filelog` revset which implement its own traversal logic that is still to be fixed. Thanks goes to: - Matt Mackall: for nudging me in the right direction - Julien Cristau and RĂ©mi Cardona: for keep telling me linkrev bug were an evolution show stopper for 3 years. - Durham Goode: for finding a new linkrev issue every few weeks - Mads Kiilerich: for that last rename bug who raise this topic over my anoyance limit.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
     1
Source bundle was generated with the following script:
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
     2
5406
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     3
# hg init
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     4
# echo a > a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     5
# ln -s a l
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     6
# hg ci -Ama -d'0 0'
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     7
# mkdir b
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     8
# echo a > b/a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
     9
# chmod +x b/a
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
    10
# hg ci -Amb -d'1 0'
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
    11
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    12
  $ hg init
14116
cd3032437064 tests: move test bundles in a bundles/ subdirectory
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 12346
diff changeset
    13
  $ hg -q pull "$TESTDIR/bundles/test-manifest.hg"
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    14
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    15
The next call is expected to return nothing:
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    16
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    17
  $ hg manifest
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    18
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    19
  $ hg co
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    20
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
5406
f11554a097c8 test-manifest: test symlink and exec bit display
Patrick Mezard <pmezard@gmail.com>
parents: 5155
diff changeset
    21
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    22
  $ hg manifest
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    23
  a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    24
  b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    25
  l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    26
22423
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    27
  $ hg files -vr .
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    28
           2   a
23348
bbe56e07e07a tests: fix globs for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents: 22423
diff changeset
    29
           2 x b/a (glob)
22423
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    30
           1 l l
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    31
  $ hg files -r . -X b
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    32
  a
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    33
  l
edf07a804ac4 files: add new command unifying locate and manifest functionality
Matt Mackall <mpm@selenic.com>
parents: 16907
diff changeset
    34
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    35
  $ hg manifest -v
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    36
  644   a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    37
  755 * b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    38
  644 @ l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    39
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    40
  $ hg manifest --debug
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    41
  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 644   a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    42
  b789fdd96dc2f3bd229c1dd8eedf0fc60e2b68e3 755 * b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    43
  047b75c6d7a3ef6a2243bd0e99f94f6ea6683597 644 @ l
6737
7239e06e58e9 context: consistently return p1 context for None
Matt Mackall <mpm@selenic.com>
parents: 5406
diff changeset
    44
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    45
  $ hg manifest -r 0
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    46
  a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    47
  l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    48
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    49
  $ hg manifest -r 1
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    50
  a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    51
  b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    52
  l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    53
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    54
  $ hg manifest -r tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    55
  a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    56
  b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    57
  l
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    58
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    59
  $ hg manifest tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    60
  a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    61
  b/a
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    62
  l
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    63
14399
71938479eff9 add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents: 14116
diff changeset
    64
  $ hg manifest --all
71938479eff9 add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents: 14116
diff changeset
    65
  a
71938479eff9 add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents: 14116
diff changeset
    66
  b/a
71938479eff9 add new option --all to manifest command
Adrian Buehlmann <adrian@cadifra.com>
parents: 14116
diff changeset
    67
  l
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    68
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    69
The next two calls are expected to abort:
5155
13d23d66a6cd manifest: accept -r for rev specification
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
    70
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    71
  $ hg manifest -r 2
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    72
  abort: unknown revision '2'!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12253
diff changeset
    73
  [255]
12253
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    74
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    75
  $ hg manifest -r tip tip
e5aee120287b tests: unify test-manifest*
Adrian Buehlmann <adrian@cadifra.com>
parents: 6737
diff changeset
    76
  abort: please specify just one revision
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12253
diff changeset
    77
  [255]