Mercurial > hg
comparison tests/test-fix.t @ 40570:ad71c792a8d8
fix: add extra field to fixed revisions to avoid creating obsolescence cycles
The extra field prevents sequential invocations of fix from producing the same
hash twice. Previously, this could cause problems because it would create an
obsolescence cycle instead of the expected new successor.
This change also adds an explicit check for whether a new revision should be
committed. Until now, the code relied on memctx.commit() to quietly do nothing
if the node already exists. Because of the new extra field, this no longer
covers the case where we don't want to replace an unchanged node.
Differential Revision: https://phab.mercurial-scm.org/D5245
author | Danny Hooper <hooper@google.com> |
---|---|
date | Thu, 08 Nov 2018 12:35:26 -0800 |
parents | 19e1c26213f1 |
children | 8604f130eb43 |
comparison
equal
deleted
inserted
replaced
40569:19e1c26213f1 | 40570:ad71c792a8d8 |
---|---|
1193 6 | 1193 6 |
1194 7 | 1194 7 |
1195 8 | 1195 8 |
1196 | 1196 |
1197 $ cd .. | 1197 $ cd .. |
1198 | |
1199 It's possible for repeated applications of a fixer tool to create cycles in the | |
1200 generated content of a file. For example, two users with different versions of | |
1201 a code formatter might fight over the formatting when they run hg fix. In the | |
1202 absence of other changes, this means we could produce commits with the same | |
1203 hash in subsequent runs of hg fix. This is a problem unless we support | |
1204 obsolescence cycles well. We avoid this by adding an extra field to the | |
1205 successor which forces it to have a new hash. That's why this test creates | |
1206 three revisions instead of two. | |
1207 | |
1208 $ hg init cyclictool | |
1209 $ cd cyclictool | |
1210 | |
1211 $ cat >> .hg/hgrc <<EOF | |
1212 > [fix] | |
1213 > swapletters:command = tr ab ba | |
1214 > swapletters:pattern = foo | |
1215 > EOF | |
1216 | |
1217 $ echo ab > foo | |
1218 $ hg commit -Aqm foo | |
1219 | |
1220 $ hg fix -r 0 | |
1221 $ hg fix -r 1 | |
1222 | |
1223 $ hg cat -r 0 foo --hidden | |
1224 ab | |
1225 $ hg cat -r 1 foo --hidden | |
1226 ba | |
1227 $ hg cat -r 2 foo | |
1228 ab | |
1229 | |
1230 $ cd .. | |
1231 |