tests/test-up-local-change
author Henrik Stuart <henrik.stuart@edlund.dk>
Sat, 23 May 2009 17:02:49 +0200
changeset 8562 e3495c399006
parent 4659 7a7d4937272b
permissions -rwxr-xr-x
named branches: server branchmap wire protocol support (issue736) The repository command, 'branchmap', returns a dictionary, branchname -> [branchheads], and will be implemented for localrepo, httprepo and sshrepo. The following wire format is used for returning data: branchname1 branch1head2 branch1head2 ... branchname2 ... ... Branch names are URL encoded to escape white space, and branch heads are sent as hex encoded node ids. All branches and all their heads are sent. The background and motivation for this command is the desire for a richer named branch semantics when pushing changesets. The details are explained in the original proposal which is included below. 1. BACKGROUND The algorithm currently implemented in Mercurial only considers the graph theoretical heads when determining whether new heads are created, rather than using the branch heads as a count (the algorithm considers a branch head effectively closed when it is merged into another branch or a new named branch is started from that point onward). Our particular problem with the algorithm is that we'd like to see the following case working without forcing a push: Upsteam has: (0:dev) ---- (1:dev) \ `--- (2:stable) Someone merges stable into dev: (0:dev) ---- (1:dev) ------(3:dev) \ / `--- (2:stable) --------´ This can be pushed without --force (as it should). Now someone else does some coding on stable (a bug fix, say): (0:dev) ---- (1:dev) ------(3:dev) \ / `--- (2:stable) ---------´---------(4:stable) This time we need --force to push. We allow this to be pushed without using --force by getting all the remote branch heads (by extending the wire protocol with a new function). We would, furthermore, also prefer if it is impossible to push a new branch without --force (or a later --newbranch option so --force isn't shoe-horned into too many disparate functions, if need be), except of course in the case where the remote repository is empty. This is what our patches accomplish. 2. ALTERNATIVES We have, of course, considered some alternatives to reconstructing enough information to decide whether we are creating new remote branch heads, before we added the new wire protocol command. 2.1. LOOKUP ON REMOTE The main alternative is to use the information from remote.heads() and remote.lookup() to try to reconstruct enough graph information to decide whether we are creating new heads. This is not adequate as illustrated below. Remember that each lookup is typically a request-response pair over SSH or HTTP(S). If we have a simple repository at the remote end like this: (0:dev) ---- (1:dev) ---- (3:stable) \ `--- (2:dev) then remote.heads() will yield [2, 3]. Assume we have nodes [0, 1, 2] locally and want to create a new node, 4:dev, as a descendant from (1:dev), which should be OK as 1:dev is a branch head. If we do remote.lookup('dev') we will get [2]. Thus, we can get information about whether a branch exists on the remote server or not, but this does not solve our problem of figuring out whether we are creating new heads or not. Pushing 4:dev ought to be OK, since after the push, we still only have two heads on branch a. Using remote.lookup() and remote.heads() is thus not adequate to consistently decide whether we are creating new remote heads (e.g. in this situation the latter would never return 1:dev). 2.2. USING INCOMING TO RECONSTRUCT THE GRAPH An alternative would be to use information equivalent to hg incoming to get the full remote graph in addition to the local graph. To do this, we would have to get a changegroup(subset) bundle representing the remote end (which may be a substantial amount of data), getting the branch heads from an instantiated bundlerepository, deleting the bundle, and finally, we can compute the prepush logic. While this is backwards compatible, it will cause a possibly substantial slowdown of the push command as it first needs to pull in all changes. 3. FURTHER ARGUMENTS IN FAVOUR OF THE BRANCHMAP WIRE-PROTOCOL EXTENSION Currently, the commands incoming and pull, work based on the tip of a given branch if used with "-r branchname", making it hard to get all revisions of a certain branch only (if it has multiple heads). This can be solved by requesting the remote's branchheads and letting the revisions to be used with the command be these heads. This can be done by extending the commands with a new option, e.g.: hg pull -b branchname which will be turned into the equivalent of: hg pull -r branchhead1 -r branchhead2 -r branchhead3 We have a simple follow-up patch that can do this ready as well (although not submitted yet as it is pending the acceptance of the branch patch). 4. WRAP-UP We generally find that the branchmap wire protocol extension can provide better named branch support to Mercurial. Currently, some things, like the initial push scenario in this mail, are fairly counter-intuitive, and the more often you have to force push, the more it is likely you will get a lot of spurious and unnecessary merge nodes. Also, restricting incoming and pull to all changes on a branch rather than changes on the tip-most head would be a sensible extension to making named branches a first class citizen in Mercurial. Currently, named branches sometimes feel like a late-coming unwanted step-child. We have run it in a production environment for a while, with fewer multiple heads occurring in our repositories and fewer confused users as a result. Also, it fixes the long-standing issue 736. Co-contributor: Sune Foldager <cryo@cyanite.org>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
544
3d4d5f2aba9a Remove bashisms and use /bin/sh instead of /bin/bash.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 485
diff changeset
     1
#!/bin/sh
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     2
4365
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3199
diff changeset
     3
HGMERGE=true; export HGMERGE
46280c004f22 change tests to use simplemerge by default
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 3199
diff changeset
     4
800
ec85f9e6f3b1 Don't use 'set -x', fix exports, sed and hexdump usage for Solaris.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     5
set -e
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     6
mkdir r1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     7
cd r1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     8
hg init
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     9
echo a > a
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    10
hg addremove
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1674
diff changeset
    11
hg commit -m "1" -d "1000000 0"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    12
485
c5705ab9cebd [PATCH] add clone command
mpm@selenic.com
parents: 350
diff changeset
    13
hg clone . ../r2
c5705ab9cebd [PATCH] add clone command
mpm@selenic.com
parents: 350
diff changeset
    14
cd ../r2
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    15
hg up
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    16
echo abc > a
3199
096f1c73cdc3 Add -D/--nodates options to hg diff/export that removes dates from diff headers
Stephen Darnell <stephen@darnell.plus.com>
parents: 2283
diff changeset
    17
hg diff --nodates
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    18
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    19
cd ../r1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    20
echo b > b
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    21
echo a2 > a
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    22
hg addremove
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1674
diff changeset
    23
hg commit -m "2" -d "1000000 0"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    24
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    25
cd ../r2
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    26
hg -q pull ../r1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    27
hg status
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    28
hg parents
591
eb46971fc57f options: kill -d for debug
mpm@selenic.com
parents: 547
diff changeset
    29
hg --debug up
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    30
hg parents
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    31
hg --debug up 0
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    32
hg parents
2283
e506c14382fd deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2065
diff changeset
    33
hg --debug merge || echo failed
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    34
hg parents
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    35
hg --debug up
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    36
hg parents
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    37
hg -v history
3199
096f1c73cdc3 Add -D/--nodates options to hg diff/export that removes dates from diff headers
Stephen Darnell <stephen@darnell.plus.com>
parents: 2283
diff changeset
    38
hg diff --nodates
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    39
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    40
# create a second head
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    41
cd ../r1
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    42
hg up 0
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    43
echo b2 > b
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    44
echo a3 > a
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    45
hg addremove
1933
7544700fd931 Use 'hg ci -d "1000000 0"' in tests to circumvent problem with leading zero.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1674
diff changeset
    46
hg commit -m "3" -d "1000000 0"
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    47
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    48
cd ../r2
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    49
hg -q pull ../r1
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    50
hg status
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    51
hg parents
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    52
hg --debug up || echo failed
2283
e506c14382fd deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2065
diff changeset
    53
hg --debug merge || echo failed
e506c14382fd deprecate 'update -m'. use 'merge' instead.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents: 2065
diff changeset
    54
hg --debug merge -f
1674
dee55c4a4963 abort when using 'update -m' and this is not a merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1581
diff changeset
    55
hg parents
3199
096f1c73cdc3 Add -D/--nodates options to hg diff/export that removes dates from diff headers
Stephen Darnell <stephen@darnell.plus.com>
parents: 2283
diff changeset
    56
hg diff --nodates
2065
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    57
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    58
# test a local add
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    59
cd ..
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    60
hg init a
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    61
hg init b
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    62
echo a > a/a
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    63
echo a > b/a
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    64
hg --cwd a commit -A -m a
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    65
cd b
4659
7a7d4937272b Kill trailing spaces
Thomas Arendsen Hein <thomas@intevation.de>
parents: 4365
diff changeset
    66
hg add a
2065
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    67
hg pull -u ../a
2ff37e3bf780 fix update when a locally added file match the target revision
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1933
diff changeset
    68
hg st