Show More
@@ -2135,7 +2135,8 b' def undo(ui, repo):' | |||||
2135 | """ |
|
2135 | """ | |
2136 | repo.undo() |
|
2136 | repo.undo() | |
2137 |
|
2137 | |||
2138 |
def update(ui, repo, node=None, merge=False, clean=False, |
|
2138 | def update(ui, repo, node=None, merge=False, clean=False, force=None, | |
|
2139 | branch=None): | |||
2139 | """update or merge working directory |
|
2140 | """update or merge working directory | |
2140 |
|
2141 | |||
2141 | Update the working directory to the specified revision. |
|
2142 | Update the working directory to the specified revision. | |
@@ -2172,7 +2173,7 b' def update(ui, repo, node=None, merge=Fa' | |||||
2172 | return 1 |
|
2173 | return 1 | |
2173 | else: |
|
2174 | else: | |
2174 | node = node and repo.lookup(node) or repo.changelog.tip() |
|
2175 | node = node and repo.lookup(node) or repo.changelog.tip() | |
2175 | return repo.update(node, allow=merge, force=clean) |
|
2176 | return repo.update(node, allow=merge, force=clean, forcemerge=force) | |
2176 |
|
2177 | |||
2177 | def verify(ui, repo): |
|
2178 | def verify(ui, repo): | |
2178 | """verify the integrity of the repository |
|
2179 | """verify the integrity of the repository | |
@@ -2418,8 +2419,9 b' table = {' | |||||
2418 | (update, |
|
2419 | (update, | |
2419 | [('b', 'branch', "", _('checkout the head of a specific branch')), |
|
2420 | [('b', 'branch', "", _('checkout the head of a specific branch')), | |
2420 | ('m', 'merge', None, _('allow merging of branches')), |
|
2421 | ('m', 'merge', None, _('allow merging of branches')), | |
2421 |
('C', 'clean', None, _('overwrite locally modified files')) |
|
2422 | ('C', 'clean', None, _('overwrite locally modified files')), | |
2422 | _('hg update [-b TAG] [-m] [-C] [REV]')), |
|
2423 | ('f', 'force', None, _('force a merge with outstanding changes'))], | |
|
2424 | _('hg update [-b TAG] [-m] [-C] [-f] [REV]')), | |||
2423 | "verify": (verify, [], _('hg verify')), |
|
2425 | "verify": (verify, [], _('hg verify')), | |
2424 | "version": (show_version, [], _('hg version')), |
|
2426 | "version": (show_version, [], _('hg version')), | |
2425 | } |
|
2427 | } |
@@ -1358,7 +1358,7 b' class localrepository(object):' | |||||
1358 | return |
|
1358 | return | |
1359 |
|
1359 | |||
1360 | def update(self, node, allow=False, force=False, choose=None, |
|
1360 | def update(self, node, allow=False, force=False, choose=None, | |
1361 | moddirstate=True): |
|
1361 | moddirstate=True, forcemerge=False): | |
1362 | pl = self.dirstate.parents() |
|
1362 | pl = self.dirstate.parents() | |
1363 | if not force and pl[1] != nullid: |
|
1363 | if not force and pl[1] != nullid: | |
1364 | self.ui.warn(_("aborting: outstanding uncommitted merges\n")) |
|
1364 | self.ui.warn(_("aborting: outstanding uncommitted merges\n")) | |
@@ -1378,6 +1378,18 b' class localrepository(object):' | |||||
1378 |
|
1378 | |||
1379 | (c, a, d, u) = self.changes() |
|
1379 | (c, a, d, u) = self.changes() | |
1380 |
|
1380 | |||
|
1381 | if allow and not forcemerge: | |||
|
1382 | if c or a or d: | |||
|
1383 | raise util.Abort(_("outstanding uncommited changes")) | |||
|
1384 | if not forcemerge and not force: | |||
|
1385 | for f in u: | |||
|
1386 | if f in m2: | |||
|
1387 | t1 = self.wread(f) | |||
|
1388 | t2 = self.file(f).read(m2[f]) | |||
|
1389 | if cmp(t1, t2) != 0: | |||
|
1390 | raise util.Abort(_("'%s' already exists in the working" | |||
|
1391 | " dir and differs from remote") % f) | |||
|
1392 | ||||
1381 | # is this a jump, or a merge? i.e. is there a linear path |
|
1393 | # is this a jump, or a merge? i.e. is there a linear path | |
1382 | # from p1 to p2? |
|
1394 | # from p1 to p2? | |
1383 | linear_path = (pa == p1 or pa == p2) |
|
1395 | linear_path = (pa == p1 or pa == p2) |
@@ -40,8 +40,10 b' echo This is file c1 > c' | |||||
40 | hg add c |
|
40 | hg add c | |
41 | hg commit -m "commit #2" -d "0 0" |
|
41 | hg commit -m "commit #2" -d "0 0" | |
42 | echo This is file b2 > b |
|
42 | echo This is file b2 > b | |
|
43 | echo %% merge should fail | |||
|
44 | env HGMERGE=../merge hg update -m 1 | |||
43 | echo %% merge of b expected |
|
45 | echo %% merge of b expected | |
44 | env HGMERGE=../merge hg update -m 1 |
|
46 | env HGMERGE=../merge hg update -f -m 1 | |
45 | cd ..; /bin/rm -rf t |
|
47 | cd ..; /bin/rm -rf t | |
46 | echo %% |
|
48 | echo %% | |
47 |
|
49 | |||
@@ -65,8 +67,10 b' echo \'Contents of b should be "this is f' | |||||
65 | cat b |
|
67 | cat b | |
66 |
|
68 | |||
67 | echo This is file b22 > b |
|
69 | echo This is file b22 > b | |
|
70 | echo %% merge fails | |||
|
71 | env HGMERGE=../merge hg update -m 2 | |||
68 | echo %% merge expected! |
|
72 | echo %% merge expected! | |
69 | env HGMERGE=../merge hg update -m 2 |
|
73 | env HGMERGE=../merge hg update -f -m 2 | |
70 | cd ..; /bin/rm -rf t |
|
74 | cd ..; /bin/rm -rf t | |
71 |
|
75 | |||
72 | mkdir t |
|
76 | mkdir t | |
@@ -85,6 +89,8 b' echo This is file c1 > c' | |||||
85 | hg add c |
|
89 | hg add c | |
86 | hg commit -m "commit #3" -d "0 0" |
|
90 | hg commit -m "commit #3" -d "0 0" | |
87 | echo This is file b33 > b |
|
91 | echo This is file b33 > b | |
88 |
echo %% merge of b |
|
92 | echo %% merge of b should fail | |
89 | env HGMERGE=../merge hg update -m 2 |
|
93 | env HGMERGE=../merge hg update -m 2 | |
|
94 | echo %% merge of b expected | |||
|
95 | env HGMERGE=../merge hg update -f -m 2 | |||
90 | cd ..; /bin/rm -rf t |
|
96 | cd ..; /bin/rm -rf t |
@@ -1,13 +1,19 b'' | |||||
1 | %% no merges expected |
|
1 | %% no merges expected | |
|
2 | %% merge should fail | |||
|
3 | abort: 'b' already exists in the working dir and differs from remote | |||
2 | %% merge of b expected |
|
4 | %% merge of b expected | |
3 | merging for b |
|
5 | merging for b | |
4 | merging b |
|
6 | merging b | |
5 | %% |
|
7 | %% | |
6 | Contents of b should be "this is file b1" |
|
8 | Contents of b should be "this is file b1" | |
7 | This is file b1 |
|
9 | This is file b1 | |
|
10 | %% merge fails | |||
|
11 | abort: outstanding uncommited changes | |||
8 | %% merge expected! |
|
12 | %% merge expected! | |
9 | merging for b |
|
13 | merging for b | |
10 | merging b |
|
14 | merging b | |
|
15 | %% merge of b should fail | |||
|
16 | abort: outstanding uncommited changes | |||
11 | %% merge of b expected |
|
17 | %% merge of b expected | |
12 | merging for b |
|
18 | merging for b | |
13 | merging b |
|
19 | merging b |
@@ -25,7 +25,8 b' cd ../r2' | |||||
25 | hg -q pull ../r1 |
|
25 | hg -q pull ../r1 | |
26 | hg status |
|
26 | hg status | |
27 | hg --debug up |
|
27 | hg --debug up | |
28 | hg --debug up -m |
|
28 | hg --debug up -m || echo failed | |
|
29 | hg --debug up -f -m | |||
29 | hg parents |
|
30 | hg parents | |
30 | hg -v history |
|
31 | hg -v history | |
31 | hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
|
32 | hg diff | sed -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/" \ |
@@ -16,6 +16,8 b' getting b' | |||||
16 | merging a |
|
16 | merging a | |
17 | resolving a |
|
17 | resolving a | |
18 | file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2 |
|
18 | file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2 | |
|
19 | abort: outstanding uncommited changes | |||
|
20 | failed | |||
19 | resolving manifests |
|
21 | resolving manifests | |
20 | force None allow 1 moddirstate True linear True |
|
22 | force None allow 1 moddirstate True linear True | |
21 | ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e |
|
23 | ancestor 1165e8bd193e local 1165e8bd193e remote 1165e8bd193e |
General Comments 0
You need to be logged in to leave comments.
Login now