Show More
@@ -5660,9 +5660,8 def update(ui, repo, node=None, rev=None | |||
|
5660 | 5660 | rev = cmdutil.finddate(ui, repo, date) |
|
5661 | 5661 | |
|
5662 | 5662 | if check: |
|
5663 | # we could use dirty() but we can ignore merge and branch trivia | |
|
5664 | 5663 | c = repo[None] |
|
5665 | if c.modified() or c.added() or c.removed(): | |
|
5664 | if c.dirty(merge=False, branch=False): | |
|
5666 | 5665 | raise util.Abort(_("uncommitted local changes")) |
|
5667 | 5666 | if rev is None: |
|
5668 | 5667 | rev = repo[repo[None].branch()].rev() |
@@ -940,14 +940,15 class workingctx(changectx): | |||
|
940 | 940 | return sorted(self._repo.dirstate.walk(match, self.substate.keys(), |
|
941 | 941 | True, False)) |
|
942 | 942 | |
|
943 | def dirty(self, missing=False): | |
|
943 | def dirty(self, missing=False, merge=True, branch=True): | |
|
944 | 944 | "check whether a working directory is modified" |
|
945 | 945 | # check subrepos first |
|
946 | 946 | for s in self.substate: |
|
947 | 947 | if self.sub(s).dirty(): |
|
948 | 948 | return True |
|
949 | 949 | # check current working dir |
|
950 | return (self.p2() or self.branch() != self.p1().branch() or | |
|
950 | return ((merge and self.p2()) or | |
|
951 | (branch and self.branch() != self.p1().branch()) or | |
|
951 | 952 | self.modified() or self.added() or self.removed() or |
|
952 | 953 | (missing and self.deleted())) |
|
953 | 954 |
@@ -15,6 +15,11 | |||
|
15 | 15 | $ hg init |
|
16 | 16 | $ echo foo > foo |
|
17 | 17 | $ echo zero > a |
|
18 | $ hg init sub | |
|
19 | $ echo suba > sub/suba | |
|
20 | $ hg --cwd sub ci -Am addsuba | |
|
21 | adding suba | |
|
22 | $ echo 'sub = sub' > .hgsub | |
|
18 | 23 | $ hg ci -qAm0 |
|
19 | 24 | $ echo one > a ; hg ci -m1 |
|
20 | 25 | $ echo two > a ; hg ci -m2 |
@@ -29,44 +34,46 Initial repo state: | |||
|
29 | 34 | |
|
30 | 35 | $ hg --config 'extensions.graphlog=' \ |
|
31 | 36 | > glog --template '{rev}:{node|short} {parents} {branches}\n' |
|
32 | @ 5:e1bb631146ca b1 | |
|
37 | @ 5:ff252e8273df b1 | |
|
33 | 38 | | |
|
34 |
o 4: |
|
|
39 | o 4:d047485b3896 0:60829823a42a b1 | |
|
35 | 40 | | |
|
36 | | o 3:4b57d2520816 1:44592833ba9f | |
|
41 | | o 3:6efa171f091b 1:0786582aa4b1 | |
|
37 | 42 | | | |
|
38 |
| | o 2: |
|
|
43 | | | o 2:bd10386d478c | |
|
39 | 44 | | |/ |
|
40 | | o 1:44592833ba9f | |
|
45 | | o 1:0786582aa4b1 | |
|
41 | 46 | |/ |
|
42 |
o 0: |
|
|
47 | o 0:60829823a42a | |
|
43 | 48 | |
|
44 | 49 | |
|
45 | 50 | Test helper functions: |
|
46 | 51 | |
|
47 | 52 | $ revtest () { |
|
48 | 53 | > msg=$1 |
|
49 | > dirtyflag=$2 # 'clean' or 'dirty' | |
|
54 | > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub' | |
|
50 | 55 | > startrev=$3 |
|
51 | 56 | > targetrev=$4 |
|
52 | 57 | > opt=$5 |
|
53 | 58 | > hg up -qC $startrev |
|
54 | 59 | > test $dirtyflag = dirty && echo dirty > foo |
|
60 | > test $dirtyflag = dirtysub && echo dirty > sub/suba | |
|
55 | 61 | > hg up $opt $targetrev |
|
56 | 62 | > hg parent --template 'parent={rev}\n' |
|
57 | > hg stat | |
|
63 | > hg stat -S | |
|
58 | 64 | > } |
|
59 | 65 | |
|
60 | 66 | $ norevtest () { |
|
61 | 67 | > msg=$1 |
|
62 | > dirtyflag=$2 # 'clean' or 'dirty' | |
|
68 | > dirtyflag=$2 # 'clean', 'dirty' or 'dirtysub' | |
|
63 | 69 | > startrev=$3 |
|
64 | 70 | > opt=$4 |
|
65 | 71 | > hg up -qC $startrev |
|
66 | 72 | > test $dirtyflag = dirty && echo dirty > foo |
|
73 | > test $dirtyflag = dirtysub && echo dirty > sub/suba | |
|
67 | 74 | > hg up $opt |
|
68 | 75 | > hg parent --template 'parent={rev}\n' |
|
69 | > hg stat | |
|
76 | > hg stat -S | |
|
70 | 77 | > } |
|
71 | 78 | |
|
72 | 79 | Test cases are documented in a table in the update function of merge.py. |
@@ -99,16 +106,30 Cases are run as shown in that table, ro | |||
|
99 | 106 | parent=2 |
|
100 | 107 | M foo |
|
101 | 108 | |
|
109 | $ revtest 'none dirtysub linear' dirtysub 1 2 | |
|
110 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
111 | parent=2 | |
|
112 | M sub/suba | |
|
113 | ||
|
102 | 114 | $ revtest 'none dirty same' dirty 2 3 |
|
103 | 115 | abort: crosses branches (merge branches or use --clean to discard changes) |
|
104 | 116 | parent=2 |
|
105 | 117 | M foo |
|
106 | 118 | |
|
119 | $ revtest 'none dirtysub same' dirtysub 2 3 | |
|
120 | abort: crosses branches (merge branches or use --clean to discard changes) | |
|
121 | parent=2 | |
|
122 | M sub/suba | |
|
123 | ||
|
107 | 124 | $ revtest 'none dirty cross' dirty 3 4 |
|
108 | 125 | abort: crosses branches (merge branches or use --clean to discard changes) |
|
109 | 126 | parent=3 |
|
110 | 127 | M foo |
|
111 | 128 | |
|
129 | $ revtest 'none dirtysub cross' dirtysub 3 4 | |
|
130 | abort: crosses branches (merge branches or use --clean to discard changes) | |
|
131 | parent=3 | |
|
132 | M sub/suba | |
|
112 | 133 | |
|
113 | 134 | $ revtest '-C dirty linear' dirty 1 2 -C |
|
114 | 135 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
@@ -119,6 +140,11 Cases are run as shown in that table, ro | |||
|
119 | 140 | parent=1 |
|
120 | 141 | M foo |
|
121 | 142 | |
|
143 | $ revtest '-c dirtysub linear' dirtysub 1 2 -c | |
|
144 | abort: uncommitted local changes | |
|
145 | parent=1 | |
|
146 | M sub/suba | |
|
147 | ||
|
122 | 148 | $ norevtest '-c clean same' clean 2 -c |
|
123 | 149 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
124 | 150 | parent=3 |
General Comments 0
You need to be logged in to leave comments.
Login now