Mercurial > hg > mercurial-crew-with-dirclash
annotate mercurial/merge.py @ 3103:22336ad45cf2
merge: add forget to action list
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 17 Sep 2006 15:54:51 -0500 |
parents | 36b08cd92fb7 |
children | e6818b0b8154 |
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 |
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 |
3095
92a0c2200e41
merge: use context code to retrieve manifests
Matt Mackall <mpm@selenic.com>
parents:
3007
diff
changeset
|
91 m1 = repo.changectx(p1).manifest().copy() |
92a0c2200e41
merge: use context code to retrieve manifests
Matt Mackall <mpm@selenic.com>
parents:
3007
diff
changeset
|
92 m2 = repo.changectx(p2).manifest().copy() |
92a0c2200e41
merge: use context code to retrieve manifests
Matt Mackall <mpm@selenic.com>
parents:
3007
diff
changeset
|
93 ma = repo.changectx(pa).manifest() |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 |
2898
06c05c675a35
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2850
diff
changeset
|
95 if not force: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 for f in unknown: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 if f in m2: |
2911
95cc73523983
Use revlog hash comparison technique in merge
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
98 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
|
99 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
|
100 " dir and differs from remote") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
101 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 # resolve the manifest to determine which files |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 # we care about merging |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 repo.ui.note(_("resolving manifests\n")) |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
105 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s linear %s\n") % |
2916 | 106 (overwrite, branchmerge, bool(partial), linear_path)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 repo.ui.debug(_(" ancestor %s local %s remote %s\n") % |
3095
92a0c2200e41
merge: use context code to retrieve manifests
Matt Mackall <mpm@selenic.com>
parents:
3007
diff
changeset
|
108 (short(p1), short(p2), short(pa))) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
109 |
3101
87ea5a71f7b9
merge: convert actions to list
Matt Mackall <mpm@selenic.com>
parents:
3097
diff
changeset
|
110 action = [] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
112 # update m1 from working dir |
2799
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 |
3097
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
115 for i,l in (("a", added), ("m", modified), ("u", unknown)): |
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
116 for f in l: |
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
117 m1[f] = m1.get(f, nullid) + i |
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
118 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
|
119 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
120 for f in deleted + removed: |
3005 | 121 del m1[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 # 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. |
2917
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
128 if linear_path and f not in m2: |
3103
22336ad45cf2
merge: add forget to action list
Matt Mackall <mpm@selenic.com>
parents:
3102
diff
changeset
|
129 action.append((f, "f")) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
130 |
3000
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
131 if partial: |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
132 for f in m1.keys(): |
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
133 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
|
134 for f in m2.keys(): |
33dcf03ef45f
merge: hoist partial code out of manifest loops
Matt Mackall <mpm@selenic.com>
parents:
2999
diff
changeset
|
135 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
|
136 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
137 # Compare manifests |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
138 for f, n in m1.iteritems(): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
139 if f in m2: |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
140 queued = 0 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
141 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
142 # are files different? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
143 if n != m2[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
144 a = ma.get(f, nullid) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
145 # are both different from the ancestor? |
3001
ad558f297eb1
merge: simplify some update logic
Matt Mackall <mpm@selenic.com>
parents:
3000
diff
changeset
|
146 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
|
147 repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
148 action.append((f, "m", fmerge(f, m1, m2, ma), n[:20], m2[f])) |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
149 queued = 1 |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
150 # are we clobbering? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
151 # is remote's version newer? |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
152 # 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
|
153 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
|
154 repo.ui.debug(_(" remote %s is newer, get\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
155 action.append((f, "g", m2.execf(f), m2[f])) |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
156 queued = 1 |
3097
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
157 elif n[20:] in ("u","a"): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
158 # 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
|
159 # we need to reset the dirstate if the file was added |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
160 action.append((f, "g", m2.execf(f), m2[f])) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
161 |
2998
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2997
diff
changeset
|
162 # 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
|
163 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
|
164 if overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
165 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
|
166 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
|
167 else: |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
168 if fmerge(f, m1, m2, ma) != m1.execf(f): |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
169 repo.ui.debug(_(" updating permissions for %s\n") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
170 % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
171 util.set_exec(repo.wjoin(f), mode) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
172 del m2[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
173 elif f in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
174 if n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
175 r = _("d") |
2999
fa9c769fee8a
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2998
diff
changeset
|
176 if not overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
177 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
178 (_(" local changed %s which remote deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
179 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
180 if r == _("d"): |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
181 action.append((f, "r")) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
182 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
183 repo.ui.debug(_("other deleted %s\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
184 action.append((f, "r")) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
185 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
186 # file is created on branch or in working directory |
3097
1b738357bba9
merge: fold umap and added into m1 manifest
Matt Mackall <mpm@selenic.com>
parents:
3096
diff
changeset
|
187 if overwrite and n[20:] != "u": |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
188 repo.ui.debug(_("remote deleted %s, clobbering\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
189 action.append((f, "r")) |
3003
cbb90f4bafb0
merge: eliminate usage of m1 after working manifest creation
Matt Mackall <mpm@selenic.com>
parents:
3002
diff
changeset
|
190 elif not n[20:]: # same as parent |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
191 if backwards: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
192 repo.ui.debug(_("remote deleted %s\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
193 action.append((f, "r")) |
2799
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 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
|
196 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
197 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
|
198 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
199 for f, n in m2.iteritems(): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
200 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
201 continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
202 if f in ma and n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
203 r = _("k") |
2999
fa9c769fee8a
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2998
diff
changeset
|
204 if not overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
205 r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
206 (_("remote changed %s which local deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
207 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
208 if r == _("k"): |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
209 action.append((f, "g", m2.execf(f), n)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
210 elif f not in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
211 repo.ui.debug(_("remote created %s\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
212 action.append((f, "g", m2.execf(f), n)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
213 else: |
2997
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2919
diff
changeset
|
214 if overwrite or backwards: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
215 repo.ui.debug(_("local deleted %s, recreating\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
216 action.append((f, "g", m2.execf(f), n)) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
218 repo.ui.debug(_("local deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
219 |
3004
31011730f9bd
merge: eliminate mw manifestdict, do everything with m1
Matt Mackall <mpm@selenic.com>
parents:
3003
diff
changeset
|
220 del m1, m2, ma |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
221 |
2917
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
222 ### apply phase |
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2916
diff
changeset
|
223 |
2829
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2828
diff
changeset
|
224 if linear_path or overwrite: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
225 # 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
|
226 p1, p2 = p2, nullid |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
227 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
228 xp1 = hex(p1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
229 xp2 = hex(p2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
230 if p2 == nullid: xxp2 = '' |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
231 else: xxp2 = xp2 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
232 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
233 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
|
234 |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
235 # update files |
3096
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
236 updated, merged, removed, unresolved = 0, 0, 0, 0 |
3101
87ea5a71f7b9
merge: convert actions to list
Matt Mackall <mpm@selenic.com>
parents:
3097
diff
changeset
|
237 action.sort() |
87ea5a71f7b9
merge: convert actions to list
Matt Mackall <mpm@selenic.com>
parents:
3097
diff
changeset
|
238 for a in action: |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
239 f, m = a[:2] |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
240 if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
241 continue |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
242 if m == "r": # remove |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
243 repo.ui.note(_("removing %s\n") % f) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
244 util.audit_path(f) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
245 try: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
246 util.unlink(repo.wjoin(f)) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
247 except OSError, inst: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
248 if inst.errno != errno.ENOENT: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
249 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
|
250 (f, inst.strerror)) |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
251 removed +=1 |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
252 elif m == "m": # merge |
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
253 flag, my, other = a[2:] |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
254 repo.ui.status(_("merging %s\n") % f) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
255 if merge3(repo, f, my, other, xp1, xp2): |
3096
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
256 unresolved += 1 |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
257 util.set_exec(repo.wjoin(f), flag) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
258 merged += 1 |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
259 elif m == "g": # get |
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
260 flag, node = a[2:] |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
261 repo.ui.note(_("getting %s\n") % f) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
262 t = repo.file(f).read(node) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
263 repo.wwrite(f, t) |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
264 util.set_exec(repo.wjoin(f), flag) |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
265 updated += 1 |
2919
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
266 |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
267 # update dirstate |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
268 if not partial: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2918
diff
changeset
|
269 repo.dirstate.setparents(p1, p2) |
3101
87ea5a71f7b9
merge: convert actions to list
Matt Mackall <mpm@selenic.com>
parents:
3097
diff
changeset
|
270 for a in action: |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
271 f, m = a[:2] |
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
272 if m == "r": # remove |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
273 if branchmerge: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
274 repo.dirstate.update([f], 'r') |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
275 else: |
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
276 repo.dirstate.forget([f]) |
3103
22336ad45cf2
merge: add forget to action list
Matt Mackall <mpm@selenic.com>
parents:
3102
diff
changeset
|
277 elif m == "f": # forget |
22336ad45cf2
merge: add forget to action list
Matt Mackall <mpm@selenic.com>
parents:
3102
diff
changeset
|
278 repo.dirstate.forget([f]) |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
279 elif m == "g": # get |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
280 if branchmerge: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
281 repo.dirstate.update([f], 'n', st_mtime=-1) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
282 else: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
283 repo.dirstate.update([f], 'n') |
3102
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
284 elif m == "m": # merge |
36b08cd92fb7
merge: add codes to action list, eliminate None elements
Matt Mackall <mpm@selenic.com>
parents:
3101
diff
changeset
|
285 flag, my, other = a[2:] |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
286 if branchmerge: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
287 # 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
|
288 # so that we properly record the merger later |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
289 repo.dirstate.update([f], 'm') |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
290 else: |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
291 # 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
|
292 # 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
|
293 # 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
|
294 # merge will appear as a normal local file |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
295 # modification. |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
296 fl = repo.file(f) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
297 f_len = fl.size(fl.rev(other)) |
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
298 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
|
299 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
300 if show_stats: |
3006
87a0332ab58b
merge: combine merge and get lists
Matt Mackall <mpm@selenic.com>
parents:
3005
diff
changeset
|
301 stats = ((updated, _("updated")), |
3096
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
302 (merged - unresolved, _("merged")), |
3007
962b9c7df641
merge: add remove to the action hash
Matt Mackall <mpm@selenic.com>
parents:
3006
diff
changeset
|
303 (removed, _("removed")), |
3096
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
304 (unresolved, _("unresolved"))) |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
305 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
|
306 repo.ui.status("%s\n" % note) |
2825
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2824
diff
changeset
|
307 if not partial: |
2824
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
308 if branchmerge: |
2827
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2826
diff
changeset
|
309 if unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
310 repo.ui.status(_("There are unresolved merges," |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
311 " you can redo the full merge using:\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
312 " hg update -C %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
313 " hg merge %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
314 % (repo.changelog.rev(p1), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
315 repo.changelog.rev(p2)))) |
2803 | 316 elif remind: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
317 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
|
318 elif unresolved: |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
319 repo.ui.status(_("There are unresolved merges with" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
320 " locally modified files.\n")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
321 |
3096
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
322 repo.hook('update', parent1=xp1, parent2=xxp2, error=unresolved) |
54d85098fb82
merge: make unresolved a counter
Matt Mackall <mpm@selenic.com>
parents:
3095
diff
changeset
|
323 return unresolved |
2799
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
324 |