mirror of
https://github.com/facebook/sapling.git
synced 2024-10-08 15:57:43 +03:00
7b2a775c50
# HG changeset patch # User maf46@burn.cl.cam.ac.uk # Node ID 57667c9b93a5a743e4629d15a0e6bd76699130c3 # Parent 4309b0a5a6010dd2e5811b77d2bc29a51acf290f Fix zombie files in merge Keir Fraser observed the following: > I made a small test case that illustrates the bug in merging changesets > with 'hg remove's in them: > > 1. Create a repository A containing files foo & bar. > 2. Create clone called B. > 3. A removes file bar, and commits this removal. > 4. B edits file foo, and commits this edit. > > Now, if B: > # hg pull ../A; hg update -m; hg commit > Then bar remains deleted. > > If A: > # hg pull ../B; hg update -m; hg commit > Then bar is resurrected! > > It looks as though, when you merge across a branch, any deletions in > your own branch are forgotten. > ... > Fixing this is a must, as zombie files are a real pain. :-) Keir later patched our local copy of hg as shown below, which fixes the problem. I've also enclosed a test which captures the test Keir outlined... Files deleted on a branch should not automatically reappear in a merge Patch notes: 1. The first chunk does not change behaviour, but cleans up the code to more closely match check of 'force' in the second chunk. I think it makes the code clearer. 2. The second chunk fixes two bugs -- i. If we choose to keep a remotely-changed locally-deleted file, then we need to 'get' that file. If we choose to delete it then no action need be taken (it is already deleted in the working manifest). Without this fix, choosing to delete would get a Python traceback. ii. The test for whether the file was remotely-created is insufficient. It is only true if f is not in the common ancestor. Otherwise the file was deleted locally, and should remain deleted. (this is the most important fix!) Index: hg/tests/test-merge6 =================================================================== |
||
---|---|---|
.. | ||
fish-merge | ||
README | ||
run-tests | ||
test-backwards-remove | ||
test-backwards-remove.out | ||
test-bad-pull | ||
test-bad-pull.out | ||
test-basic | ||
test-basic.out | ||
test-bdiff | ||
test-bdiff.out | ||
test-clone | ||
test-clone-failure | ||
test-clone-failure.out | ||
test-clone.out | ||
test-conflict | ||
test-conflict.out | ||
test-copy | ||
test-copy.out | ||
test-diffdir | ||
test-diffdir.out | ||
test-empty-dir | ||
test-empty-dir.out | ||
test-flags | ||
test-flags.out | ||
test-help | ||
test-help.out | ||
test-hook | ||
test-hook.out | ||
test-merge1 | ||
test-merge1.out | ||
test-merge2 | ||
test-merge2.out | ||
test-merge3 | ||
test-merge3.out | ||
test-merge4 | ||
test-merge4.out | ||
test-merge5 | ||
test-merge5.out | ||
test-merge6 | ||
test-merge6.out | ||
test-pull | ||
test-pull.out | ||
test-rawcommit1 | ||
test-rawcommit1.out | ||
test-simple-update | ||
test-simple-update.out | ||
test-tag | ||
test-tag.out | ||
test-tags | ||
test-tags.out | ||
test-undo | ||
test-undo.out | ||
test-unrelated-pull | ||
test-unrelated-pull.out | ||
test-up-local-change | ||
test-up-local-change.out |
A simple testing framework To run the tests, do: cd tests/ ./run-tests This finds all scripts in the test directory named test-* and executes them. The scripts can be either shell scripts or Python. Each test is run in a temporary directory that is removed when the test is complete. A test-<x> succeeds if the script returns success and its output matches test-<x>.out. If the new output doesn't match, it is stored in test-<x>.err. There are some tricky points here that you should be aware of when writing tests: - hg commit and hg up -m want user interaction for commit use -t "text" for hg up -m, set HGMERGE to something noninteractive (like true or merge) - changeset hashes will change based on user and date which make things like hg history output change use commit -t "test" -u test -d "0 0" - diff will show the current time use hg diff | sed "s/\(\(---\|+++\).*\)\t.*/\1/" to strip dates - set -x and pipelines don't generate stable output turn off set -x or break pipelines into pieces