sapling/tests
maf46@burn.cl.cam.ac.uk 7b2a775c50 Fix zombie files in merge
# 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
===================================================================
2005-07-04 12:38:34 -08:00
..
fish-merge Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
README testing fixups 2005-06-14 13:44:37 -08:00
run-tests Add username/merge/editor to .hgrc 2005-07-03 21:51:09 -08:00
test-backwards-remove hg merge: fix time asymmetry bug with deleting files on update to past 2005-06-16 22:32:55 -08:00
test-backwards-remove.out hg merge: fix time asymmetry bug with deleting files on update to past 2005-06-16 22:32:55 -08:00
test-bad-pull Work-around failing tests/test-bad-pull with slow bg process. 2005-07-01 07:31:26 +01:00
test-bad-pull.out Merge with TAH 2005-06-30 23:28:16 -08:00
test-basic Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
test-basic.out Fixed tests for displaying tags in hg history and hg parents. 2005-06-17 11:03:03 +01:00
test-bdiff Add a fast binary diff extension (not yet used) 2005-06-21 17:27:58 -08:00
test-bdiff.out Add a fast binary diff extension (not yet used) 2005-06-21 17:27:58 -08:00
test-clone [PATCH] Tests for clone command 2005-06-30 23:51:25 -08:00
test-clone-failure [PATCH] Tests for clone command 2005-06-30 23:51:25 -08:00
test-clone-failure.out [PATCH] Tests for clone command 2005-06-30 23:51:25 -08:00
test-clone.out [PATCH] Tests for clone command 2005-06-30 23:51:25 -08:00
test-conflict options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-conflict.out options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-copy options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-copy.out options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-diffdir Refactor diffrevs/diffdir into changes 2005-06-30 20:54:01 -08:00
test-diffdir.out Update test-diffdir output 2005-07-02 13:39:40 -08:00
test-empty-dir Remove empty directories on update 2005-07-02 15:38:16 -08:00
test-empty-dir.out Remove empty directories on update 2005-07-02 15:38:16 -08:00
test-flags options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-flags.out options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-help A bunch of parsing/help updates 2005-07-03 11:47:45 -08:00
test-help.out A bunch of parsing/help updates 2005-07-03 11:47:45 -08:00
test-hook Add initial hook support 2005-06-27 22:18:12 -08:00
test-hook.out Add initial hook support 2005-06-27 22:18:12 -08:00
test-merge1 Fix up test-merge1 2005-06-21 21:07:08 -08:00
test-merge1.out Fix up test-merge1 2005-06-21 21:07:08 -08:00
test-merge2 Pick up tests from previous patch 2005-06-21 18:51:06 -08:00
test-merge2.out Pick up tests from previous patch 2005-06-21 18:51:06 -08:00
test-merge3 [PATCH] (3/4) Removing an added file 2005-06-21 17:50:37 -08:00
test-merge3.out [PATCH] (3/4) Removing an added file 2005-06-21 17:50:37 -08:00
test-merge4 [PATCH] Removal of a file added by merging branches 2005-06-21 19:19:39 -08:00
test-merge4.out [PATCH] Removal of a file added by merging branches 2005-06-21 19:19:39 -08:00
test-merge5 [PATCH] Don't prompt user for keep-vs-delete when the merge is about to be aborted 2005-06-21 19:14:11 -08:00
test-merge5.out Fix zombie files in merge 2005-07-04 12:38:34 -08:00
test-merge6 Fix zombie files in merge 2005-07-04 12:38:34 -08:00
test-merge6.out Fix zombie files in merge 2005-07-04 12:38:34 -08:00
test-pull Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
test-pull.out options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-rawcommit1 options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-rawcommit1.out options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-simple-update Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
test-simple-update.out [PATCH] add clone command 2005-06-26 15:20:46 -08:00
test-tag From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl> 2005-06-21 17:47:28 -08:00
test-tag.out From: Radoslaw Szkodzinski <astralstorm@gorzow.mm.pl> 2005-06-21 17:47:28 -08:00
test-tags Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
test-tags.out Fix dodiff/changes 2005-07-01 11:24:09 -08:00
test-undo Remove bashisms and use /bin/sh instead of /bin/bash. 2005-07-01 07:22:27 +01:00
test-undo.out Update undo test 2005-06-28 02:04:49 -08:00
test-unrelated-pull Actually warn on pulling from an unrelated repository 2005-07-02 18:25:15 -08:00
test-unrelated-pull.out Actually warn on pulling from an unrelated repository 2005-07-02 18:25:15 -08:00
test-up-local-change options: kill -d for debug 2005-07-02 22:54:35 -08:00
test-up-local-change.out options: kill -d for debug 2005-07-02 22:54:35 -08:00

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