##// END OF EJS Templates
update: add comments and test cases for updating across branches...
Stuart W Marks -
r9716:ea8c207a default
parent child Browse files
Show More
@@ -0,0 +1,81 b''
1 #!/bin/sh
2
3 # Construct the following history tree:
4 #
5 # @ 5:e1bb631146ca b1
6 # |
7 # o 4:a4fdb3b883c4 0:b608b9236435 b1
8 # |
9 # | o 3:4b57d2520816 1:44592833ba9f
10 # | |
11 # | | o 2:063f31070f65
12 # | |/
13 # | o 1:44592833ba9f
14 # |/
15 # o 0:b608b9236435
16
17 hg init
18 echo foo > foo
19 echo zero > a
20 hg ci -qAm0
21 echo one > a ; hg ci -m1
22 echo two > a ; hg ci -m2
23 hg up -q 1
24 echo three > a ; hg ci -qm3
25 hg up -q 0
26 hg branch -q b1
27 echo four > a ; hg ci -qm4
28 echo five > a ; hg ci -qm5
29
30 echo % initial repo state
31 echo
32 hg --config 'extensions.graphlog=' \
33 glog --template '{rev}:{node|short} {parents} {branches}\n'
34
35 # Test helper functions.
36
37 revtest () {
38 msg=$1
39 dirtyflag=$2 # 'clean' or 'dirty'
40 startrev=$3
41 targetrev=$4
42 opt=$5
43 echo % revtest $msg $startrev $targetrev
44 hg up -qC $startrev
45 test $dirtyflag = dirty && echo dirty > foo
46 hg up $opt $targetrev
47 hg parent --template 'parent={rev}\n'
48 hg stat
49 }
50
51 norevtest () {
52 msg=$1
53 dirtyflag=$2 # 'clean' or 'dirty'
54 startrev=$3
55 opt=$4
56 echo % norevtest $msg $startrev
57 hg up -qC $startrev
58 test $dirtyflag = dirty && echo dirty > foo
59 hg up $opt
60 hg parent --template 'parent={rev}\n'
61 hg stat
62 }
63
64 # Test cases are documented in a table in the update function of merge.py.
65 # Cases are run as shown in that table, row by row.
66
67 norevtest 'none clean linear' clean 4
68 norevtest 'none clean same' clean 2
69
70 revtest 'none clean linear' clean 1 2
71 revtest 'none clean same' clean 2 3
72 revtest 'none clean cross' clean 3 4
73
74 revtest 'none dirty linear' dirty 1 2
75 revtest 'none dirty same' dirty 2 3
76 revtest 'none dirty cross' dirty 3 4
77
78 revtest '-C dirty linear' dirty 1 2 -C
79 revtest '-c dirty linear' dirty 1 2 -c
80 norevtest '-c clean same' clean 2 -c
81 revtest '-cC dirty linear' dirty 1 2 -cC
@@ -0,0 +1,55 b''
1 % initial repo state
2
3 @ 5:e1bb631146ca b1
4 |
5 o 4:a4fdb3b883c4 0:b608b9236435 b1
6 |
7 | o 3:4b57d2520816 1:44592833ba9f
8 | |
9 | | o 2:063f31070f65
10 | |/
11 | o 1:44592833ba9f
12 |/
13 o 0:b608b9236435
14
15 % norevtest none clean linear 4
16 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 parent=5
18 % norevtest none clean same 2
19 abort: crosses branches (use 'hg merge' or 'hg update -C')
20 parent=2
21 % revtest none clean linear 1 2
22 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 parent=2
24 % revtest none clean same 2 3
25 abort: crosses branches (use 'hg merge' or 'hg update -C')
26 parent=2
27 % revtest none clean cross 3 4
28 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
29 parent=4
30 % revtest none dirty linear 1 2
31 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
32 parent=2
33 M foo
34 % revtest none dirty same 2 3
35 abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes)
36 parent=2
37 M foo
38 % revtest none dirty cross 3 4
39 abort: crosses named branches (use 'hg update -C' to discard changes)
40 parent=3
41 M foo
42 % revtest -C dirty linear 1 2
43 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 parent=2
45 % revtest -c dirty linear 1 2
46 abort: uncommitted local changes
47 parent=1
48 M foo
49 % norevtest -c clean same 2
50 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
51 parent=3
52 % revtest -cC dirty linear 1 2
53 abort: cannot specify both -c/--check and -C/--clean
54 parent=1
55 M foo
@@ -397,9 +397,37 b' def update(repo, node, branchmerge, forc'
397 """
397 """
398 Perform a merge between the working directory and the given node
398 Perform a merge between the working directory and the given node
399
399
400 node = the node to update to, or None if unspecified
400 branchmerge = whether to merge between branches
401 branchmerge = whether to merge between branches
401 force = whether to force branch merging or file overwriting
402 force = whether to force branch merging or file overwriting
402 partial = a function to filter file lists (dirstate not updated)
403 partial = a function to filter file lists (dirstate not updated)
404
405 The table below shows all the behaviors of the update command
406 given the -c and -C or no options, whether the working directory
407 is dirty, whether a revision is specified, and the relationship of
408 the parent rev to the target rev (linear, on the same named
409 branch, or on another named branch).
410
411 This logic is tested by test-update-branches.
412
413 -c -C dirty rev | linear same cross
414 n n n n | ok (1) x
415 n n n y | ok (1) ok
416 n n y * | merge (2) (3)
417 n y * * | --- discard ---
418 y n y * | --- (4) ---
419 y n n * | --- ok ---
420 y y * * | --- (5) ---
421
422 x = can't happen
423 * = don't-care
424 1 = abort: crosses branches (use 'hg merge' or 'hg update -C')
425 2 = abort: crosses branches (use 'hg merge' or 'hg update -C'
426 to discard changes)
427 3 = abort: crosses named branches (use 'hg update -C' to
428 discard changes)
429 4 = abort: uncommitted local changes
430 5 = incompatible options (checked in commands.py)
403 """
431 """
404
432
405 wlock = repo.wlock()
433 wlock = repo.wlock()
General Comments 0
You need to be logged in to leave comments. Login now