prepush: rewrite most of the code from scratch
For servers with branchmap support, the algorithm now works as follows:
1. A list of branches in outgoing changesets is created.
2. Using the remote branchmap, a check for new branches is performed.
3. A map (from branch to head list) of locally known remote heads before
the push is created, and one which, after step 4, will contain the locally
known remote heads after the push.
4. The post-push head map is updated with the outgoing changesets, using the
branch cache update mechanism.
5. A check for new heads is performed, by comparing the length of the head list
before and after push, for each branch. If there are new heads, an error
depending on whether or not there are incoming changes on the branch,
is returned.
6. If the push is allowed, a warning is written if there are incoming changes
on any branches involved in the push.
For old servers, an algorithm similar to step 4-6 above is used to check for
new topological heads only.
Two bugs are also fixed:
1. Sometimes you would be allowed to push new branch heads without --force.
A test for this case was added.
2. You would get the "note: unsynced remote changes!" warning if there were any
incoming changesets, even if they were on unrelated branches.
% initialize darcs repo
Finished recording patch 'p0'
% branch and update
Finished recording patch 'p1.1'
% update source
Finished recording patch 'p1.2'
% merge branch
Backing up ./a(-darcs-backup0)
We have conflicts in the following files:
./a
Finished pulling and applying.
Finished recording patch 'p2'
% test file and directory move
Finished recording patch 'p3'
initializing destination darcs-repo-hg repository
scanning source...
sorting...
converting...
4 p0
3 p1.2
2 p1.1
1 p2
0 p3
o 4 "p3" files: dir/d dir/d2 dir2/d f ff
|
o 3 "p2" files: a dir/d dir/d2 f
|
o 2 "p1.1" files:
|
o 1 "p1.2" files: a b
|
o 0 "p0" files: a
7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a
1e88685f5ddec574a34c70af492f95b6debc8741 644 b
37406831adc447ec2385014019599dfec953c806 644 dir2/d
b783a337463792a5c7d548ad85a7d3253c16ba8c 644 ff