view tests/test-debugbuilddag.t @ 23702:c48924787eaa

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 23 Dec 2014 15:30:38 -0800
parents aa9385f983fa
children 95f490136e75
line wrap: on
line source


plain

  $ hg init
  $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' \
  > --config extensions.progress= --config progress.assume-tty=1 \
  > --config progress.delay=0 --config progress.refresh=0 \
  > --config progress.format=topic,bar,number \
  > --config progress.width=60
  \r (no-eol) (esc)
  building [                                          ]  0/12\r (no-eol) (esc)
  building [                                          ]  0/12\r (no-eol) (esc)
  building [                                          ]  0/12\r (no-eol) (esc)
  building [                                          ]  0/12\r (no-eol) (esc)
  building [==>                                       ]  1/12\r (no-eol) (esc)
  building [==>                                       ]  1/12\r (no-eol) (esc)
  building [==>                                       ]  1/12\r (no-eol) (esc)
  building [==>                                       ]  1/12\r (no-eol) (esc)
  building [======>                                   ]  2/12\r (no-eol) (esc)
  building [======>                                   ]  2/12\r (no-eol) (esc)
  building [=========>                                ]  3/12\r (no-eol) (esc)
  building [=========>                                ]  3/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [=============>                            ]  4/12\r (no-eol) (esc)
  building [================>                         ]  5/12\r (no-eol) (esc)
  building [================>                         ]  5/12\r (no-eol) (esc)
  building [====================>                     ]  6/12\r (no-eol) (esc)
  building [====================>                     ]  6/12\r (no-eol) (esc)
  building [=======================>                  ]  7/12\r (no-eol) (esc)
  building [=======================>                  ]  7/12\r (no-eol) (esc)
  building [===========================>              ]  8/12\r (no-eol) (esc)
  building [===========================>              ]  8/12\r (no-eol) (esc)
  building [===========================>              ]  8/12\r (no-eol) (esc)
  building [===========================>              ]  8/12\r (no-eol) (esc)
  building [==============================>           ]  9/12\r (no-eol) (esc)
  building [==============================>           ]  9/12\r (no-eol) (esc)
  building [==================================>       ] 10/12\r (no-eol) (esc)
  building [==================================>       ] 10/12\r (no-eol) (esc)
  building [=====================================>    ] 11/12\r (no-eol) (esc)
  building [=====================================>    ] 11/12\r (no-eol) (esc)
                                                              \r (no-eol) (esc)

tags
  $ cat .hg/localtags
  66f7d451a68b85ed82ff5fcc254daf50c74144bd f
  bebd167eb94d257ace0e814aeb98e6972ed2970d p2
dag
  $ hg debugdag -t -b
  +2:f
  +3:p2
  @temp*f+3
  @default*/p2+2:tip
tip
  $ hg id
  000000000000
glog
  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
  o  11: r11 [] @ 11.00
  |
  o  10: r10 [] @ 10.00
  |
  o    9: r9 [] @ 9.00
  |\
  | o  8: r8 [temp] @ 8.00
  | |
  | o  7: r7 [temp] @ 7.00
  | |
  | o  6: r6 [temp] @ 6.00
  | |
  | o  5: r5 [temp] @ 5.00
  | |
  o |  4: r4 [] @ 4.00
  | |
  o |  3: r3 [] @ 3.00
  | |
  o |  2: r2 [] @ 2.00
  |/
  o  1: r1 [] @ 1.00
  |
  o  0: r0 [] @ 0.00
  

overwritten files, starting on a non-default branch

  $ rm -r .hg
  $ hg init
  $ hg debugbuilddag '@start.@default.:f +3:p2 @temp <f+4 @default /p2 +2' -q -o
tags
  $ cat .hg/localtags
  f778700ebd50fcf282b23a4446bd155da6453eb6 f
  bbccf169769006e2490efd2a02f11c3d38d462bd p2
dag
  $ hg debugdag -t -b
  @start+1
  @default+1:f
  +3:p2
  @temp*f+3
  @default*/p2+2:tip
tip
  $ hg id
  000000000000
glog
  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
  o  11: r11 [] @ 11.00
  |
  o  10: r10 [] @ 10.00
  |
  o    9: r9 [] @ 9.00
  |\
  | o  8: r8 [temp] @ 8.00
  | |
  | o  7: r7 [temp] @ 7.00
  | |
  | o  6: r6 [temp] @ 6.00
  | |
  | o  5: r5 [temp] @ 5.00
  | |
  o |  4: r4 [] @ 4.00
  | |
  o |  3: r3 [] @ 3.00
  | |
  o |  2: r2 [] @ 2.00
  |/
  o  1: r1 [] @ 1.00
  |
  o  0: r0 [start] @ 0.00
  
glog of
  $ hg log -G --template '{rev}: {desc} [{branches}]\n' of
  o  11: r11 []
  |
  o  10: r10 []
  |
  o    9: r9 []
  |\
  | o  8: r8 [temp]
  | |
  | o  7: r7 [temp]
  | |
  | o  6: r6 [temp]
  | |
  | o  5: r5 [temp]
  | |
  o |  4: r4 []
  | |
  o |  3: r3 []
  | |
  o |  2: r2 []
  |/
  o  1: r1 []
  |
  o  0: r0 [start]
  
tags
  $ hg tags -v
  tip                               11:9ffe238a67a2
  p2                                 4:bbccf1697690 local
  f                                  1:f778700ebd50 local
cat of
  $ hg cat of --rev tip
  r11


new and mergeable files

  $ rm -r .hg
  $ hg init
  $ hg debugbuilddag '+2:f +3:p2 @temp <f+4 @default /p2 +2' -q -mn
dag
  $ hg debugdag -t -b
  +2:f
  +3:p2
  @temp*f+3
  @default*/p2+2:tip
tip
  $ hg id
  000000000000
glog
  $ hg log -G --template '{rev}: {desc} [{branches}] @ {date}\n'
  o  11: r11 [] @ 11.00
  |
  o  10: r10 [] @ 10.00
  |
  o    9: r9 [] @ 9.00
  |\
  | o  8: r8 [temp] @ 8.00
  | |
  | o  7: r7 [temp] @ 7.00
  | |
  | o  6: r6 [temp] @ 6.00
  | |
  | o  5: r5 [temp] @ 5.00
  | |
  o |  4: r4 [] @ 4.00
  | |
  o |  3: r3 [] @ 3.00
  | |
  o |  2: r2 [] @ 2.00
  |/
  o  1: r1 [] @ 1.00
  |
  o  0: r0 [] @ 0.00
  
glog mf
  $ hg log -G --template '{rev}: {desc} [{branches}]\n' mf
  o  11: r11 []
  |
  o  10: r10 []
  |
  o    9: r9 []
  |\
  | o  8: r8 [temp]
  | |
  | o  7: r7 [temp]
  | |
  | o  6: r6 [temp]
  | |
  | o  5: r5 [temp]
  | |
  o |  4: r4 []
  | |
  o |  3: r3 []
  | |
  o |  2: r2 []
  |/
  o  1: r1 []
  |
  o  0: r0 []
  

man r4
  $ hg manifest -r4
  mf
  nf0
  nf1
  nf2
  nf3
  nf4
cat r4 mf
  $ hg cat -r4 mf
  0 r0
  1
  2 r1
  3
  4 r2
  5
  6 r3
  7
  8 r4
  9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
man r8
  $ hg manifest -r8
  mf
  nf0
  nf1
  nf5
  nf6
  nf7
  nf8
cat r8 mf
  $ hg cat -r8 mf
  0 r0
  1
  2 r1
  3
  4
  5
  6
  7
  8
  9
  10 r5
  11
  12 r6
  13
  14 r7
  15
  16 r8
  17
  18
  19
  20
  21
  22
  23
man
  $ hg manifest --rev tip
  mf
  nf0
  nf1
  nf10
  nf11
  nf2
  nf3
  nf4
  nf5
  nf6
  nf7
  nf8
  nf9
cat mf
  $ hg cat mf --rev tip
  0 r0
  1
  2 r1
  3
  4 r2
  5
  6 r3
  7
  8 r4
  9
  10 r5
  11
  12 r6
  13
  14 r7
  15
  16 r8
  17
  18 r9
  19
  20 r10
  21
  22 r11
  23