Mercurial > hg > mercurial-crew-with-dirclash
annotate mercurial/merge.py @ 2885:26c37ebda1bb
hgweb: partially revert 4ec58b157265
The change from self.repo.ui.diffopts() to ui.diffopts() causes a
traceback when the diff of a changeset should be displayed in the
web interface. Revert to self.repo.ui.diffopts() for now.
author | Giorgos Keramidas <keramida@ceid.upatras.gr> |
---|---|
date | Mon, 14 Aug 2006 16:06:37 +0300 |
parents | 3d6efcbbd1c9 |
children | bee4b7abcb01 |
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 * |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 demandload(globals(), "util os tempfile") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
12 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
13 def merge3(repo, fn, my, other, p1, p2): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 """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
|
15 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 def temp(prefix, node): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 pre = "%s~%s." % (os.path.basename(fn), prefix) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
18 (fd, name) = tempfile.mkstemp(prefix=pre) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
19 f = os.fdopen(fd, "wb") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
20 repo.wwrite(fn, fl.read(node), f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
21 f.close() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
22 return name |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
23 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
24 fl = repo.file(fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
25 base = fl.ancestor(my, other) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
26 a = repo.wjoin(fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
27 b = temp("base", base) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
28 c = temp("other", other) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
29 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
30 repo.ui.note(_("resolving %s\n") % fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
31 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
|
32 (fn, short(my), short(other), short(base))) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
33 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
34 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
|
35 or "hgmerge") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
36 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
|
37 environ={'HG_FILE': fn, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
38 'HG_MY_NODE': p1, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
39 'HG_OTHER_NODE': p2, |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
40 'HG_FILE_MY_NODE': hex(my), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
41 'HG_FILE_OTHER_NODE': hex(other), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
42 'HG_FILE_BASE_NODE': hex(base)}) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
43 if r: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
44 repo.ui.warn(_("merging %s failed!\n") % fn) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
45 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
46 os.unlink(b) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
47 os.unlink(c) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
48 return r |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
49 |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
50 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
|
51 wlock=None, show_stats=True, remind=True): |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
52 |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
53 overwrite = force and not branchmerge |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
54 forcemerge = force and branchmerge |
2826
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
55 |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
56 if not wlock: |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
57 wlock = repo.wlock() |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2825
diff
changeset
|
58 |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
59 ### check phase |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
60 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
61 pl = repo.dirstate.parents() |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
62 if not overwrite and pl[1] != nullid: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
63 raise util.Abort(_("outstanding uncommitted merges")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
64 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
65 p1, p2 = pl[0], node |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 pa = repo.changelog.ancestor(p1, p2) |
2828
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
67 |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
68 # 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
|
69 linear_path = (pa == p1 or pa == p2) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
70 if branchmerge and linear_path: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
71 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
|
72 "'hg update' or look at 'hg heads'")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
73 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
74 if not overwrite and not linear_path and not branchmerge: |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
75 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
|
76 "or 'hg update -C' to lose changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
77 |
2874
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2850
diff
changeset
|
78 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
|
79 if branchmerge and not forcemerge: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
80 if modified or added or removed: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
81 raise util.Abort(_("outstanding uncommitted changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2827
diff
changeset
|
82 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
83 m1n = repo.changelog.read(p1)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
84 m2n = repo.changelog.read(p2)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
85 man = repo.manifest.ancestor(m1n, m2n) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
86 m1 = repo.manifest.read(m1n) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
87 m2 = repo.manifest.read(m2n).copy() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
88 ma = repo.manifest.read(man) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
89 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
90 if not forcemerge and not overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 for f in unknown: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 if f in m2: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 t1 = repo.wread(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 t2 = repo.file(f).read(m2[f]) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 if cmp(t1, t2) != 0: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 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
|
97 " dir and differs from remote") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
98 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 # resolve the manifest to determine which files |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 # we care about merging |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 repo.ui.note(_("resolving manifests\n")) |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
102 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s linear %s\n") % |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
103 (overwrite, branchmerge, partial and True or False, linear_path)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 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
|
105 (short(man), short(m1n), short(m2n))) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 merge = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
108 get = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
109 remove = [] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
110 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 # construct a working dir manifest |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 mw = m1.copy() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
113 umap = dict.fromkeys(unknown) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
114 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
115 for f in added + modified + unknown: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
116 mw[f] = "" |
2850
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2849
diff
changeset
|
117 mw.set(f, util.is_exec(repo.wjoin(f), mw.execf(f))) |
2799
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 deleted + removed: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
120 if f in mw: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
121 del mw[f] |
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 # 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
|
124 # 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
|
125 # 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
|
126 # 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
|
127 # longer in the manifest. |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
128 if not partial and linear_path and f not in m2: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
129 repo.dirstate.forget((f,)) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
130 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
131 # Compare manifests |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
132 for f, n in mw.iteritems(): |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
133 if partial and not partial(f): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
134 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
135 if f in m2: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
136 s = 0 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
137 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
138 # is the wfile new since m1, and match m2? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
139 if f not in m1: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
140 t1 = repo.wread(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
141 t2 = repo.file(f).read(m2[f]) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
142 if cmp(t1, t2) == 0: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
143 n = m2[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
144 del t1, t2 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
145 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
146 # are files different? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
147 if n != m2[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
148 a = ma.get(f, nullid) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
149 # are both different from the ancestor? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
150 if n != a and m2[f] != a: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
151 repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
152 # merge executable bits |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
153 # "if we changed or they changed, change in merge" |
2850
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2849
diff
changeset
|
154 a, b, c = ma.execf(f), mw.execf(f), m2.execf(f) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
155 mode = ((a^b) | (a^c)) ^ a |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
156 merge[f] = (mode, m1.get(f, nullid), m2[f]) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
157 s = 1 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
158 # are we clobbering? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
159 # is remote's version newer? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
160 # or are we going back in time? |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
161 elif overwrite or m2[f] != a or (p2 == pa and mw[f] == m1[f]): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
162 repo.ui.debug(_(" remote %s is newer, get\n") % f) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
163 get[f] = (m2.execf(f), m2[f]) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
164 s = 1 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
165 elif f in umap or f in added: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
166 # 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
|
167 # we need to reset the dirstate if the file was added |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
168 get[f] = (m2.execf(f), m2[f]) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
169 |
2850
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2849
diff
changeset
|
170 if not s and mw.execf(f) != m2.execf(f): |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
171 if overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
172 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
|
173 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
|
174 else: |
2850
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2849
diff
changeset
|
175 a, b, c = ma.execf(f), mw.execf(f), m2.execf(f) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
176 mode = ((a^b) | (a^c)) ^ a |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
177 if mode != b: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
178 repo.ui.debug(_(" updating permissions for %s\n") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
179 % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
180 util.set_exec(repo.wjoin(f), mode) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
181 del m2[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
182 elif f in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
183 if n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
184 r = _("d") |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
185 if not overwrite and (linear_path or branchmerge): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
186 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
187 (_(" local changed %s which remote deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
188 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
189 if r == _("d"): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
190 remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
191 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
192 repo.ui.debug(_("other deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
193 remove.append(f) # other deleted it |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
194 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
195 # 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
|
196 if overwrite and f not in umap: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
197 repo.ui.debug(_("remote deleted %s, clobbering\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
198 remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
199 elif n == m1.get(f, nullid): # same as parent |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
200 if p2 == pa: # going backwards? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
201 repo.ui.debug(_("remote deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
202 remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
203 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
204 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
|
205 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
206 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
|
207 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
208 for f, n in m2.iteritems(): |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
209 if partial and not partial(f): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
210 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
211 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
212 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
213 if f in ma and n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
214 r = _("k") |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
215 if not overwrite and (linear_path or branchmerge): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
216 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 (_("remote changed %s which local deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
218 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
219 if r == _("k"): |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
220 get[f] = (m2.execf(f), n) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
221 elif f not in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
222 repo.ui.debug(_("remote created %s\n") % f) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
223 get[f] = (m2.execf(f), n) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
224 else: |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
225 if overwrite or p2 == pa: # going backwards? |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
226 repo.ui.debug(_("local deleted %s, recreating\n") % f) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
227 get[f] = (m2.execf(f), n) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
228 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
229 repo.ui.debug(_("local deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
230 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
231 del mw, m1, m2, ma |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
232 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
233 if overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
234 for f in merge: |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
235 get[f] = merge[f][:2] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
236 merge = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
237 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
238 if linear_path or overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
239 # 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
|
240 p1, p2 = p2, nullid |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
241 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
242 xp1 = hex(p1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
243 xp2 = hex(p2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
244 if p2 == nullid: xxp2 = '' |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
245 else: xxp2 = xp2 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
246 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
247 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
|
248 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
249 # get the files we don't need to change |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
250 files = get.keys() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
251 files.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
252 for f in files: |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
253 flag, node = get[f] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
254 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
255 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
256 repo.ui.note(_("getting %s\n") % f) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
257 t = repo.file(f).read(node) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
258 repo.wwrite(f, t) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
259 util.set_exec(repo.wjoin(f), flag) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
260 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
261 if branchmerge: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
262 repo.dirstate.update([f], 'n', st_mtime=-1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
263 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
264 repo.dirstate.update([f], 'n') |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
265 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
266 # merge the tricky bits |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
267 unresolved = [] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
268 files = merge.keys() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
269 files.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
270 for f in files: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
271 repo.ui.status(_("merging %s\n") % f) |
2849
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2848
diff
changeset
|
272 flag, my, other = merge[f] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
273 ret = merge3(repo, f, my, other, xp1, xp2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
274 if ret: |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
275 unresolved.append(f) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
276 util.set_exec(repo.wjoin(f), flag) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
277 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
278 if branchmerge: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
279 # We've done a branch merge, mark this file as merged |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
280 # so that we properly record the merger later |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
281 repo.dirstate.update([f], 'm') |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
282 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
283 # We've update-merged a locally modified file, so |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
284 # we set the dirstate to emulate a normal checkout |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
285 # of that file some time in the past. Thus our |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
286 # merge will appear as a normal local file |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
287 # modification. |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
288 f_len = len(repo.file(f).read(other)) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
289 repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
290 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
291 remove.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
292 for f in remove: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
293 repo.ui.note(_("removing %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
294 util.audit_path(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
295 try: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
296 util.unlink(repo.wjoin(f)) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
297 except OSError, inst: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
298 if inst.errno != errno.ENOENT: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
299 repo.ui.warn(_("update failed to remove %s: %s!\n") % |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
300 (f, inst.strerror)) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
301 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
302 if branchmerge: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
303 repo.dirstate.update(remove, 'r') |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
304 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
305 repo.dirstate.forget(remove) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
306 |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
307 if not partial: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
308 repo.dirstate.setparents(p1, p2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
309 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
310 if show_stats: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
311 stats = ((len(get), _("updated")), |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
312 (len(merge) - len(unresolved), _("merged")), |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
313 (len(remove), _("removed")), |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
314 (len(unresolved), _("unresolved"))) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
315 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
|
316 repo.ui.status("%s\n" % note) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
317 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
318 if branchmerge: |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
319 if unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
320 repo.ui.status(_("There are unresolved merges," |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
321 " you can redo the full merge using:\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
322 " hg update -C %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
323 " hg merge %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
324 % (repo.changelog.rev(p1), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
325 repo.changelog.rev(p2)))) |
2803 | 326 elif remind: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
327 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
|
328 elif unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
329 repo.ui.status(_("There are unresolved merges with" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
330 " locally modified files.\n")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
331 |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
332 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
|
333 return len(unresolved) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
334 |