Mercurial > hg > mercurial-crew-with-dirclash
annotate mercurial/merge.py @ 3082:240ec0e61290
Add the -s option to `hg help qseries`.
author | john.levon@sun.com |
---|---|
date | Wed, 13 Sep 2006 21:46:36 +0200 |
parents | db3f42261452 |
children | fe9b13e35e46 |
rev | line source |
---|---|
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # merge.py - directory-level update/merge handling for Mercurial |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # Copyright 2006 Matt Mackall <mpm@selenic.com> |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 # |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 from node import * |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 from i18n import gettext as _ |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 from demandload import * |
3015
db3f42261452
fix errors reported by pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3007
diff
changeset
|
11 demandload(globals(), "errno util os tempfile") |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
12 |
2912
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2911
diff
changeset
|
13 def fmerge(f, local, other, ancestor): |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2911
diff
changeset
|
14 """merge executable flags""" |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2911
diff
changeset
|
15 a, b, c = ancestor.execf(f), local.execf(f), other.execf(f) |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2911
diff
changeset
|
16 return ((a^b) | (a^c)) ^ a |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2911
diff
changeset
|
17 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 def merge3(repo, fn, my, other, p1, p2): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 """perform a 3-way merge in the working directory""" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 def temp(prefix, node): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 pre = "%s~%s." % (os.path.basename(fn), prefix) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 (fd, name) = tempfile.mkstemp(prefix=pre) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 f = os.fdopen(fd, "wb") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 repo.wwrite(fn, fl.read(node), f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 f.close() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
27 return name |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 fl = repo.file(fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 base = fl.ancestor(my, other) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 a = repo.wjoin(fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
32 b = temp("base", base) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 c = temp("other", other) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
35 repo.ui.note(_("resolving %s\n") % fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 repo.ui.debug(_("file %s: my %s other %s ancestor %s\n") % |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
37 (fn, short(my), short(other), short(base))) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 cmd = (os.environ.get("HGMERGE") or repo.ui.config("ui", "merge") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 or "hgmerge") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 r = util.system('%s "%s" "%s" "%s"' % (cmd, a, b, c), cwd=repo.root, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 environ={'HG_FILE': fn, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 'HG_MY_NODE': p1, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 'HG_OTHER_NODE': p2, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
45 'HG_FILE_MY_NODE': hex(my), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
46 'HG_FILE_OTHER_NODE': hex(other), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 'HG_FILE_BASE_NODE': hex(base)}) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 if r: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 repo.ui.warn(_("merging %s failed!\n") % fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
50 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
51 os.unlink(b) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
52 os.unlink(c) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
53 return r |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
54 |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
55 def update(repo, node, branchmerge=False, force=False, partial=None, |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
56 wlock=None, show_stats=True, remind=True): |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
57 |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
58 overwrite = force and not branchmerge |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
59 forcemerge = force and branchmerge |
2826
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
60 |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
61 if not wlock: |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
62 wlock = repo.wlock() |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
63 |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
64 ### check phase |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
65 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 pl = repo.dirstate.parents() |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
67 if not overwrite and pl[1] != nullid: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
68 raise util.Abort(_("outstanding uncommitted merges")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
69 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
70 p1, p2 = pl[0], node |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
71 pa = repo.changelog.ancestor(p1, p2) |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
72 |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
73 # are we going backwards? |
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
74 backwards = (pa == p2) |
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
75 |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
76 # is there a linear path from p1 to p2? |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
77 linear_path = (pa == p1 or pa == p2) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
78 if branchmerge and linear_path: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
79 raise util.Abort(_("there is nothing to merge, just use " |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
80 "'hg update' or look at 'hg heads'")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
81 |
3000
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
82 if not linear_path and not (overwrite or branchmerge): |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
83 raise util.Abort(_("update spans branches, use 'hg merge' " |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
84 "or 'hg update -C' to lose changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
85 |
2874
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
86 modified, added, removed, deleted, unknown = repo.status()[:5] |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
87 if branchmerge and not forcemerge: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
88 if modified or added or removed: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
89 raise util.Abort(_("outstanding uncommitted changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
90 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 m1n = repo.changelog.read(p1)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 m2n = repo.changelog.read(p2)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 man = repo.manifest.ancestor(m1n, m2n) |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
94 m1 = repo.manifest.read(m1n).copy() |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 m2 = repo.manifest.read(m2n).copy() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 ma = repo.manifest.read(man) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 |
2898
06c05c675a35
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2850
diff
changeset
|
98 if not force: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 for f in unknown: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 if f in m2: |
2911
95cc73523983
Use revlog hash comparison technique in merge
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
101 if repo.file(f).cmp(m2[f], repo.wread(f)): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 raise util.Abort(_("'%s' already exists in the working" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 " dir and differs from remote") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 # resolve the manifest to determine which files |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 # we care about merging |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 repo.ui.note(_("resolving manifests\n")) |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
108 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s linear %s\n") % |
2916 | 109 (overwrite, branchmerge, bool(partial), linear_path)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
110 repo.ui.debug(_(" ancestor %s local %s remote %s\n") % |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 (short(man), short(m1n), short(m2n))) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
113 action = {} |
2917
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
114 forget = [] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
115 |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
116 # update m1 from working dir |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
117 umap = dict.fromkeys(unknown) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
118 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
119 for f in added + modified + unknown: |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
120 m1[f] = m1.get(f, nullid) + "+" |
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
121 m1.set(f, util.is_exec(repo.wjoin(f), m1.execf(f))) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
122 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
123 for f in deleted + removed: |
3005 | 124 del m1[f] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
125 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
126 # If we're jumping between revisions (as opposed to merging), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
127 # and if neither the working directory nor the target rev has |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
128 # the file, then we need to remove it from the dirstate, to |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
129 # prevent the dirstate from listing the file when it is no |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
130 # longer in the manifest. |
2917
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
131 if linear_path and f not in m2: |
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
132 forget.append(f) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
133 |
3000
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
134 if partial: |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
135 for f in m1.keys(): |
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
136 if not partial(f): del m1[f] |
3000
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
137 for f in m2.keys(): |
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
138 if not partial(f): del m2[f] |
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
139 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
140 # Compare manifests |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
141 for f, n in m1.iteritems(): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
142 if f in m2: |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
143 queued = 0 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
144 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
145 # are files different? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
146 if n != m2[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
147 a = ma.get(f, nullid) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
148 # are both different from the ancestor? |
3001
ad558f297eb1
merge: simplify some update logic
Matt Mackall <mpm@selenic.com>
parents:
3000
diff
changeset
|
149 if not overwrite and n != a and m2[f] != a: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
150 repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
151 action[f] = (fmerge(f, m1, m2, ma), n[:20], m2[f]) |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
152 queued = 1 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
153 # are we clobbering? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
154 # is remote's version newer? |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
155 # or are we going back in time and clean? |
3003
cbb90f4bafb0
merge: eliminate usage of m1 after working manifest creation
Matt Mackall <mpm@selenic.com>
parents:
3002
diff
changeset
|
156 elif overwrite or m2[f] != a or (backwards and not n[20:]): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
157 repo.ui.debug(_(" remote %s is newer, get\n") % f) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
158 action[f] = (m2.execf(f), m2[f], None) |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
159 queued = 1 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
160 elif f in umap or f in added: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
161 # this unknown file is the same as the checkout |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
162 # we need to reset the dirstate if the file was added |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
163 action[f] = (m2.execf(f), m2[f], None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
164 |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
165 # do we still need to look at mode bits? |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
166 if not queued and m1.execf(f) != m2.execf(f): |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
167 if overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
168 repo.ui.debug(_(" updating permissions for %s\n") % f) |
2850
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2849
diff
changeset
|
169 util.set_exec(repo.wjoin(f), m2.execf(f)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
170 else: |
3015
db3f42261452
fix errors reported by pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3007
diff
changeset
|
171 mode = fmerge(f, m1, m2, ma) |
db3f42261452
fix errors reported by pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
3007
diff
changeset
|
172 if mode != m1.execf(f): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
173 repo.ui.debug(_(" updating permissions for %s\n") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
174 % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
175 util.set_exec(repo.wjoin(f), mode) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
176 del m2[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
177 elif f in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
178 if n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
179 r = _("d") |
2999
fa9c769fee8a
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2998
diff
changeset
|
180 if not overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
181 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
182 (_(" local changed %s which remote deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
183 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
184 if r == _("d"): |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
185 action[f] = (None, None, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
186 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
187 repo.ui.debug(_("other deleted %s\n") % f) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
188 action[f] = (None, None, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
189 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
190 # file is created on branch or in working directory |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
191 if overwrite and f not in umap: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
192 repo.ui.debug(_("remote deleted %s, clobbering\n") % f) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
193 action[f] = (None, None, None) |
3003
cbb90f4bafb0
merge: eliminate usage of m1 after working manifest creation
Matt Mackall <mpm@selenic.com>
parents:
3002
diff
changeset
|
194 elif not n[20:]: # same as parent |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
195 if backwards: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
196 repo.ui.debug(_("remote deleted %s\n") % f) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
197 action[f] = (None, None, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
198 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
199 repo.ui.debug(_("local modified %s, keeping\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
200 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
201 repo.ui.debug(_("working dir created %s, keeping\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
202 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
203 for f, n in m2.iteritems(): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
204 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
205 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
206 if f in ma and n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
207 r = _("k") |
2999
fa9c769fee8a
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2998
diff
changeset
|
208 if not overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
209 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
210 (_("remote changed %s which local deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
211 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
212 if r == _("k"): |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
213 action[f] = (m2.execf(f), n, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
214 elif f not in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
215 repo.ui.debug(_("remote created %s\n") % f) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
216 action[f] = (m2.execf(f), n, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 else: |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
218 if overwrite or backwards: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
219 repo.ui.debug(_("local deleted %s, recreating\n") % f) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
220 action[f] = (m2.execf(f), n, None) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
221 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
222 repo.ui.debug(_("local deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
223 |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
224 del m1, m2, ma |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
225 |
2917
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
226 ### apply phase |
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
227 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
228 if linear_path or overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
229 # we don't need to do any magic, just jump to the new rev |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
230 p1, p2 = p2, nullid |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
231 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
232 xp1 = hex(p1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
233 xp2 = hex(p2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
234 if p2 == nullid: xxp2 = '' |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
235 else: xxp2 = xp2 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
236 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
237 repo.hook('preupdate', throw=True, parent1=xp1, parent2=xxp2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
238 |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
239 # update files |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
240 unresolved = [] |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
241 updated, merged, removed = 0, 0, 0 |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
242 files = action.keys() |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
243 files.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
244 for f in files: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
245 flag, my, other = action[f] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
246 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
247 continue |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
248 if not my: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
249 repo.ui.note(_("removing %s\n") % f) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
250 util.audit_path(f) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
251 try: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
252 util.unlink(repo.wjoin(f)) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
253 except OSError, inst: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
254 if inst.errno != errno.ENOENT: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
255 repo.ui.warn(_("update failed to remove %s: %s!\n") % |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
256 (f, inst.strerror)) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
257 removed +=1 |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
258 elif other: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
259 repo.ui.status(_("merging %s\n") % f) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
260 if merge3(repo, f, my, other, xp1, xp2): |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
261 unresolved.append(f) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
262 util.set_exec(repo.wjoin(f), flag) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
263 merged += 1 |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
264 else: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
265 repo.ui.note(_("getting %s\n") % f) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
266 t = repo.file(f).read(my) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
267 repo.wwrite(f, t) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
268 util.set_exec(repo.wjoin(f), flag) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
269 updated += 1 |
2919
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
270 |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
271 # update dirstate |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
272 if not partial: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
273 repo.dirstate.setparents(p1, p2) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
274 repo.dirstate.forget(forget) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
275 files = action.keys() |
2919
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
276 files.sort() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
277 for f in files: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
278 flag, my, other = action[f] |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
279 if not my: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
280 if branchmerge: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
281 repo.dirstate.update([f], 'r') |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
282 else: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
283 repo.dirstate.forget([f]) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
284 elif not other: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
285 if branchmerge: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
286 repo.dirstate.update([f], 'n', st_mtime=-1) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
287 else: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
288 repo.dirstate.update([f], 'n') |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
289 else: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
290 if branchmerge: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
291 # We've done a branch merge, mark this file as merged |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
292 # so that we properly record the merger later |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
293 repo.dirstate.update([f], 'm') |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
294 else: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
295 # We've update-merged a locally modified file, so |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
296 # we set the dirstate to emulate a normal checkout |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
297 # of that file some time in the past. Thus our |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
298 # merge will appear as a normal local file |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
299 # modification. |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
300 fl = repo.file(f) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
301 f_len = fl.size(fl.rev(other)) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
302 repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
303 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
304 if show_stats: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
305 stats = ((updated, _("updated")), |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
306 (merged - len(unresolved), _("merged")), |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
307 (removed, _("removed")), |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
308 (len(unresolved), _("unresolved"))) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
309 note = ", ".join([_("%d files %s") % s for s in stats]) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
310 repo.ui.status("%s\n" % note) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
311 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
312 if branchmerge: |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
313 if unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
314 repo.ui.status(_("There are unresolved merges," |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
315 " you can redo the full merge using:\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
316 " hg update -C %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
317 " hg merge %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
318 % (repo.changelog.rev(p1), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
319 repo.changelog.rev(p2)))) |
2803 | 320 elif remind: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
321 repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
322 elif unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
323 repo.ui.status(_("There are unresolved merges with" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
324 " locally modified files.\n")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
325 |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
326 repo.hook('update', parent1=xp1, parent2=xxp2, error=len(unresolved)) |
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
327 return len(unresolved) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
328 |