2005-08-02 11:17:22 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-04-08 21:46:47 +04:00
|
|
|
echo "[extensions]" >> $HGRCPATH
|
|
|
|
echo "graphlog=" >> $HGRCPATH
|
|
|
|
|
2005-08-02 11:17:22 +04:00
|
|
|
mkdir a
|
|
|
|
cd a
|
|
|
|
hg init
|
|
|
|
echo foo > t1
|
|
|
|
hg add t1
|
2006-03-13 15:05:41 +03:00
|
|
|
hg commit -m "1" -d "1000000 0"
|
2005-08-02 11:17:22 +04:00
|
|
|
|
|
|
|
cd ..
|
|
|
|
hg clone a b
|
|
|
|
|
|
|
|
cd a
|
|
|
|
echo foo > t2
|
|
|
|
hg add t2
|
2006-03-13 15:05:41 +03:00
|
|
|
hg commit -m "2" -d "1000000 0"
|
2005-08-02 11:17:22 +04:00
|
|
|
|
|
|
|
cd ../b
|
|
|
|
echo foo > t3
|
|
|
|
hg add t3
|
2006-03-13 15:05:41 +03:00
|
|
|
hg commit -m "3" -d "1000000 0"
|
2005-08-02 11:17:22 +04:00
|
|
|
|
|
|
|
hg push ../a
|
|
|
|
hg pull ../a
|
|
|
|
hg push ../a
|
2006-05-15 08:07:34 +04:00
|
|
|
hg merge
|
2006-03-13 15:05:41 +03:00
|
|
|
hg commit -m "4" -d "1000000 0"
|
2005-08-02 11:17:22 +04:00
|
|
|
hg push ../a
|
2006-03-30 00:35:21 +04:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
hg init c
|
|
|
|
cd c
|
|
|
|
for i in 0 1 2; do
|
|
|
|
echo $i >> foo
|
|
|
|
hg ci -Am $i -d "1000000 0"
|
|
|
|
done
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
hg clone c d
|
|
|
|
cd d
|
|
|
|
for i in 0 1; do
|
|
|
|
hg co -C $i
|
|
|
|
echo d-$i >> foo
|
|
|
|
hg ci -m d-$i -d "1000000 0"
|
|
|
|
done
|
|
|
|
|
2006-05-15 08:07:34 +04:00
|
|
|
HGMERGE=true hg merge 3
|
2006-03-30 00:35:21 +04:00
|
|
|
hg ci -m c-d -d "1000000 0"
|
|
|
|
|
2006-12-06 01:25:28 +03:00
|
|
|
hg push ../c; echo $?
|
|
|
|
hg push -r 2 ../c; echo $?
|
|
|
|
hg push -r 3 ../c; echo $?
|
|
|
|
hg push -r 3 -r 4 ../c; echo $?
|
|
|
|
hg push -f -r 3 -r 4 ../c; echo $?
|
|
|
|
hg push -r 5 ../c; echo $?
|
2010-04-14 21:11:35 +04:00
|
|
|
hg in ../c
|
2006-03-30 00:35:21 +04:00
|
|
|
|
2010-04-14 21:11:35 +04:00
|
|
|
echo % issue 450
|
2006-12-17 07:00:22 +03:00
|
|
|
hg init ../e
|
|
|
|
hg push -r 0 ../e ; echo $?
|
|
|
|
hg push -r 1 ../e ; echo $?
|
|
|
|
|
2009-05-23 19:04:41 +04:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo % issue 736
|
|
|
|
hg init f
|
|
|
|
cd f
|
|
|
|
hg -q branch a
|
|
|
|
echo 0 > foo
|
|
|
|
hg -q ci -d "1000000 0" -Am 0
|
|
|
|
echo 1 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 1
|
|
|
|
hg -q up 0
|
|
|
|
echo 2 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 2
|
|
|
|
hg -q up 0
|
|
|
|
hg -q branch b
|
|
|
|
echo 3 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 3
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
hg -q clone f g
|
|
|
|
cd g
|
|
|
|
|
|
|
|
echo % push on existing branch and new branch
|
|
|
|
hg -q up 1
|
|
|
|
echo 4 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 4
|
|
|
|
hg -q up 0
|
|
|
|
echo 5 > foo
|
|
|
|
hg -q branch c
|
|
|
|
hg -q ci -d "1000000 0" -m 5
|
2010-02-07 02:43:24 +03:00
|
|
|
hg push ../f; echo $?
|
2009-05-23 19:04:41 +04:00
|
|
|
hg push -r 4 -r 5 ../f; echo $?
|
|
|
|
|
2010-02-07 02:43:24 +03:00
|
|
|
echo % multiple new branches
|
|
|
|
hg -q branch d
|
2009-05-23 19:04:41 +04:00
|
|
|
echo 6 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 6
|
2010-02-07 02:43:24 +03:00
|
|
|
hg push ../f; echo $?
|
2009-05-23 19:04:41 +04:00
|
|
|
hg push -r 4 -r 6 ../f; echo $?
|
2010-02-07 02:43:24 +03:00
|
|
|
cd ../g
|
2009-05-23 19:04:41 +04:00
|
|
|
|
2010-02-07 02:43:24 +03:00
|
|
|
echo % fail on multiple head push
|
|
|
|
hg -q up 1
|
2009-05-23 19:04:41 +04:00
|
|
|
echo 7 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 7
|
2010-02-07 02:43:24 +03:00
|
|
|
hg push -r 4 -r 7 ../f; echo $?
|
2009-05-23 19:04:41 +04:00
|
|
|
|
2010-02-07 02:43:24 +03:00
|
|
|
echo % push replacement head on existing branches
|
|
|
|
hg -q up 3
|
|
|
|
echo 8 > foo
|
2009-05-23 19:04:41 +04:00
|
|
|
hg -q ci -d "1000000 0" -m 8
|
2010-02-07 02:43:24 +03:00
|
|
|
hg push -r 7 -r 8 ../f; echo $?
|
|
|
|
|
|
|
|
echo % merge of branch a to other branch b followed by unrelated push on branch a
|
2009-05-23 19:04:41 +04:00
|
|
|
hg -q up 7
|
2010-02-07 02:43:24 +03:00
|
|
|
HGMERGE=true hg -q merge 8
|
2009-05-23 19:04:41 +04:00
|
|
|
hg -q ci -d "1000000 0" -m 9
|
2010-02-07 02:43:24 +03:00
|
|
|
hg -q up 8
|
|
|
|
echo 10 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 10
|
2009-05-23 19:04:41 +04:00
|
|
|
hg push -r 9 ../f; echo $?
|
2010-02-07 02:43:24 +03:00
|
|
|
hg push -r 10 ../f; echo $?
|
2009-05-23 19:04:41 +04:00
|
|
|
|
|
|
|
echo % cheating the counting algorithm
|
2010-02-07 02:43:24 +03:00
|
|
|
hg -q up 9
|
2009-05-23 19:04:41 +04:00
|
|
|
HGMERGE=true hg -q merge 2
|
|
|
|
hg -q ci -d "1000000 0" -m 11
|
2010-02-07 02:43:24 +03:00
|
|
|
hg -q up 1
|
|
|
|
echo 12 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 12
|
|
|
|
hg push -r 11 -r 12 ../f; echo $?
|
2009-05-23 19:04:41 +04:00
|
|
|
|
2010-05-21 17:22:29 +04:00
|
|
|
echo % failed push of new named branch
|
|
|
|
echo 12 > foo
|
|
|
|
hg -q ci -d "1000000 0" -m 12a
|
|
|
|
hg -q up 11
|
|
|
|
echo 13 > foo
|
|
|
|
hg -q branch e
|
|
|
|
hg -q ci -d "1000000 0" -m 13d
|
|
|
|
hg push -r 12 -r 13 ../f; echo $?
|
|
|
|
|
|
|
|
echo % using --new-branch to push new named branch
|
|
|
|
hg push --new-branch -r 12 -r 13 ../f; echo $?
|
|
|
|
|
2009-09-23 20:56:09 +04:00
|
|
|
echo % checking prepush logic does not allow silently pushing multiple new heads
|
|
|
|
cd ..
|
2009-10-17 17:40:34 +04:00
|
|
|
hg init h
|
|
|
|
echo init > h/init
|
|
|
|
hg -R h ci -Am init
|
|
|
|
echo a > h/a
|
|
|
|
hg -R h ci -Am a
|
|
|
|
hg clone h i
|
2009-09-23 20:56:09 +04:00
|
|
|
hg -R h up 0
|
2009-10-17 17:40:34 +04:00
|
|
|
echo b > h/b
|
|
|
|
hg -R h ci -Am b
|
|
|
|
hg -R i up 0
|
|
|
|
echo c > i/c
|
|
|
|
hg -R i ci -Am c
|
|
|
|
hg -R i push h
|
2009-09-23 20:56:09 +04:00
|
|
|
echo
|
|
|
|
|
2009-11-30 16:58:52 +03:00
|
|
|
echo % check prepush logic with merged branches
|
|
|
|
hg init j
|
|
|
|
hg -R j branch a
|
|
|
|
echo init > j/foo
|
|
|
|
hg -R j ci -Am init
|
|
|
|
hg clone j k
|
|
|
|
echo a1 > j/foo
|
|
|
|
hg -R j ci -m a1
|
|
|
|
hg -R k branch b
|
|
|
|
echo b > k/foo
|
|
|
|
hg -R k ci -m b
|
|
|
|
hg -R k up 0
|
|
|
|
hg -R k merge b
|
|
|
|
hg -R k ci -m merge
|
|
|
|
hg -R k push -r a j
|
|
|
|
echo
|
|
|
|
|
2010-03-26 19:02:36 +03:00
|
|
|
echo % prepush -r should not allow you to sneak in new heads
|
|
|
|
hg init l
|
|
|
|
cd l
|
|
|
|
echo a >> foo
|
|
|
|
hg -q add foo
|
|
|
|
hg -q branch a
|
|
|
|
hg -q ci -d '0 0' -ma
|
|
|
|
hg -q up null
|
|
|
|
echo a >> foo
|
|
|
|
hg -q add foo
|
|
|
|
hg -q branch b
|
|
|
|
hg -q ci -d '0 0' -mb
|
|
|
|
cd ..
|
|
|
|
hg -q clone l m -u a
|
|
|
|
cd m
|
|
|
|
hg -q merge b
|
|
|
|
hg -q ci -d '0 0' -mmb
|
|
|
|
hg -q up 0
|
|
|
|
echo a >> foo
|
|
|
|
hg -q ci -ma2
|
|
|
|
hg -q up 2
|
|
|
|
echo a >> foo
|
|
|
|
hg -q branch -f b
|
|
|
|
hg -q ci -d '0 0' -mb2
|
|
|
|
hg -q merge 3
|
|
|
|
hg -q ci -d '0 0' -mma
|
|
|
|
hg push ../l -b b
|
2010-04-08 21:46:47 +04:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo % check prepush with new branch head on former topo non-head
|
|
|
|
hg init n
|
|
|
|
cd n
|
|
|
|
hg branch A
|
|
|
|
echo a >a
|
|
|
|
hg ci -Ama
|
|
|
|
hg branch B
|
|
|
|
echo b >b
|
|
|
|
hg ci -Amb
|
|
|
|
# b is now branch head of B, and a topological head
|
|
|
|
# a is now branch head of A, but not a topological head
|
|
|
|
hg clone . inner
|
|
|
|
cd inner
|
|
|
|
hg up B
|
|
|
|
echo b1 >b1
|
|
|
|
hg ci -Amb1
|
|
|
|
# in the clone b1 is now the head of B
|
|
|
|
cd ..
|
|
|
|
hg up 0
|
|
|
|
echo a2 >a2
|
|
|
|
hg ci -Ama2
|
|
|
|
# a2 is now the new branch head of A, and a new topological head
|
|
|
|
# it replaces a former inner branch head, so it should at most warn about A, not B
|
|
|
|
echo %% glog of local
|
|
|
|
hg glog --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% glog of remote
|
|
|
|
hg glog -R inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% outgoing
|
|
|
|
hg out inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
hg push inner
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
echo % check prepush with new branch head on former topo head
|
|
|
|
hg init o
|
|
|
|
cd o
|
|
|
|
hg branch A
|
|
|
|
echo a >a
|
|
|
|
hg ci -Ama
|
|
|
|
hg branch B
|
|
|
|
echo b >b
|
|
|
|
hg ci -Amb
|
|
|
|
# b is now branch head of B, and a topological head
|
|
|
|
hg up 0
|
|
|
|
echo a1 >a1
|
|
|
|
hg ci -Ama1
|
|
|
|
# a1 is now branch head of A, and a topological head
|
|
|
|
hg clone . inner
|
|
|
|
cd inner
|
|
|
|
hg up B
|
|
|
|
echo b1 >b1
|
|
|
|
hg ci -Amb1
|
|
|
|
# in the clone b1 is now the head of B
|
|
|
|
cd ..
|
|
|
|
echo a2 >a2
|
|
|
|
hg ci -Ama2
|
|
|
|
# a2 is now the new branch head of A, and a topological head
|
|
|
|
# it replaces a former topological and branch head, so this should not warn
|
|
|
|
echo %% glog of local
|
|
|
|
hg glog --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% glog of remote
|
|
|
|
hg glog -R inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% outgoing
|
|
|
|
hg out inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
hg push inner
|
|
|
|
cd ..
|
2010-03-26 19:02:36 +03:00
|
|
|
|
2010-04-14 21:35:54 +04:00
|
|
|
echo % check prepush with new branch head and new child of former branch head
|
|
|
|
echo % but child is on different branch
|
|
|
|
hg init p
|
|
|
|
cd p
|
|
|
|
hg branch A
|
|
|
|
echo a0 >a
|
|
|
|
hg ci -Ama0
|
|
|
|
echo a1 >a
|
|
|
|
hg ci -ma1
|
|
|
|
hg up null
|
|
|
|
hg branch B
|
|
|
|
echo b0 >b
|
|
|
|
hg ci -Amb0
|
|
|
|
echo b1 >b
|
|
|
|
hg ci -mb1
|
|
|
|
|
|
|
|
hg clone . inner
|
|
|
|
|
|
|
|
hg up A
|
|
|
|
hg branch -f B
|
|
|
|
echo a3 >a
|
|
|
|
hg ci -ma3
|
|
|
|
hg up 3
|
|
|
|
hg branch -f A
|
|
|
|
echo b3 >b
|
|
|
|
hg ci -mb3
|
|
|
|
|
|
|
|
echo %% glog of local
|
|
|
|
hg glog --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% glog of remote
|
|
|
|
hg glog -R inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
echo %% outgoing
|
|
|
|
hg out inner --template "{rev}: {branches} {desc}\n"
|
|
|
|
hg push inner
|
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.
2010-04-15 23:59:21 +04:00
|
|
|
hg push inner -r4 -r5
|
|
|
|
hg in inner
|
2010-04-14 21:35:54 +04:00
|
|
|
cd ..
|
|
|
|
|
2006-03-30 00:35:21 +04:00
|
|
|
exit 0
|