author | Matt Mackall <mpm@selenic.com> |
Mon, 21 Aug 2006 14:25:56 -0500 | |
changeset 2969 | 833677bc9791 |
parent 2968 | 545d33aa3f82 |
child 2970 | fa9c769fee8a |
permissions | -rw-r--r-- |
2775
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 |
|
2892
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
diff
changeset
|
13 |
def fmerge(f, local, other, ancestor): |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
diff
changeset
|
14 |
"""merge executable flags""" |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
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:
2891
diff
changeset
|
16 |
return ((a^b) | (a^c)) ^ a |
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
diff
changeset
|
17 |
|
2775
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 |
|
2811
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2810
diff
changeset
|
55 |
def update(repo, node, branchmerge=False, force=False, partial=None, |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
56 |
wlock=None, show_stats=True, remind=True): |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
57 |
|
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
58 |
overwrite = force and not branchmerge |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
59 |
forcemerge = force and branchmerge |
2812
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2811
diff
changeset
|
60 |
|
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2811
diff
changeset
|
61 |
if not wlock: |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2811
diff
changeset
|
62 |
wlock = repo.wlock() |
3aeab7bb5adc
Refactor update locking slightly
Matt Mackall <mpm@selenic.com>
parents:
2811
diff
changeset
|
63 |
|
2814
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
64 |
### check phase |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
65 |
|
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
66 |
pl = repo.dirstate.parents() |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
67 |
if not overwrite and pl[1] != nullid: |
2775
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) |
2814
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
72 |
|
2968
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
73 |
# are we going backwards? |
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
74 |
backwards = (pa == p2) |
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
75 |
|
2814
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
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:
2813
diff
changeset
|
77 |
linear_path = (pa == p1 or pa == p2) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
78 |
if branchmerge and linear_path: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
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:
2813
diff
changeset
|
80 |
"'hg update' or look at 'hg heads'")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
81 |
|
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
82 |
if not overwrite and not linear_path and not branchmerge: |
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
83 |
raise util.Abort(_("update spans branches, use 'hg merge' " |
2814
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
84 |
"or 'hg update -C' to lose changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
85 |
|
2875
3d6efcbbd1c9
remove localrepository.changes.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2838
diff
changeset
|
86 |
modified, added, removed, deleted, unknown = repo.status()[:5] |
2814
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
87 |
if branchmerge and not forcemerge: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
88 |
if modified or added or removed: |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
89 |
raise util.Abort(_("outstanding uncommitted changes")) |
0f787997e3c2
Merge: move most tests to the beginning
Matt Mackall <mpm@selenic.com>
parents:
2813
diff
changeset
|
90 |
|
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
91 |
m1n = repo.changelog.read(p1)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
92 |
m2n = repo.changelog.read(p2)[0] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
93 |
man = repo.manifest.ancestor(m1n, m2n) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
94 |
m1 = repo.manifest.read(m1n) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
95 |
m2 = repo.manifest.read(m2n).copy() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
96 |
ma = repo.manifest.read(man) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
97 |
|
2842
06c05c675a35
merge: minor simplification
Matt Mackall <mpm@selenic.com>
parents:
2838
diff
changeset
|
98 |
if not force: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
99 |
for f in unknown: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
100 |
if f in m2: |
2891
95cc73523983
Use revlog hash comparison technique in merge
Matt Mackall <mpm@selenic.com>
parents:
2886
diff
changeset
|
101 |
if repo.file(f).cmp(m2[f], repo.wread(f)): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
102 |
raise util.Abort(_("'%s' already exists in the working" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
103 |
" dir and differs from remote") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
104 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
105 |
# resolve the manifest to determine which files |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
106 |
# we care about merging |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
107 |
repo.ui.note(_("resolving manifests\n")) |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
108 |
repo.ui.debug(_(" overwrite %s branchmerge %s partial %s linear %s\n") % |
2896 | 109 |
(overwrite, branchmerge, bool(partial), linear_path)) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
110 |
repo.ui.debug(_(" ancestor %s local %s remote %s\n") % |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
111 |
(short(man), short(m1n), short(m2n))) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
112 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
113 |
merge = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
114 |
get = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
115 |
remove = [] |
2897
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2896
diff
changeset
|
116 |
forget = [] |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
117 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
118 |
# construct a working dir manifest |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
119 |
mw = m1.copy() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
120 |
umap = dict.fromkeys(unknown) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
121 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
122 |
for f in added + modified + unknown: |
2894
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
123 |
mw[f] = "" |
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
124 |
# is the wfile new and matches m2? |
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
125 |
if (f not in m1 and f in m2 and |
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
126 |
not repo.file(f).cmp(m2[f], repo.wread(f))): |
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
127 |
mw[f] = m2[f] |
f28f4c850cd8
merge: hoist some working manifest logic out of merge loop
Matt Mackall <mpm@selenic.com>
parents:
2893
diff
changeset
|
128 |
|
2838
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2837
diff
changeset
|
129 |
mw.set(f, util.is_exec(repo.wjoin(f), mw.execf(f))) |
2775
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 |
for f in deleted + removed: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
132 |
if f in mw: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
133 |
del mw[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
134 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
135 |
# 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
|
136 |
# 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
|
137 |
# 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
|
138 |
# 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
|
139 |
# longer in the manifest. |
2897
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2896
diff
changeset
|
140 |
if linear_path and f not in m2: |
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2896
diff
changeset
|
141 |
forget.append(f) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
142 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
143 |
# Compare manifests |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
144 |
for f, n in mw.iteritems(): |
2811
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2810
diff
changeset
|
145 |
if partial and not partial(f): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
146 |
continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
147 |
if f in m2: |
2969
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2968
diff
changeset
|
148 |
queued = 0 |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
149 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
150 |
# are files different? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
151 |
if n != m2[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
152 |
a = ma.get(f, nullid) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
153 |
# are both different from the ancestor? |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
154 |
if n != a and m2[f] != a: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
155 |
repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
2892
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
diff
changeset
|
156 |
merge[f] = (fmerge(f, mw, m2, ma), m1.get(f, nullid), m2[f]) |
2969
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2968
diff
changeset
|
157 |
queued = 1 |
2775
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? |
2968
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
160 |
# or are we going back in time and clean? |
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
161 |
elif overwrite or m2[f] != a or (backwards and mw[f] == m1[f]): |
2775
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) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
163 |
get[f] = (m2.execf(f), m2[f]) |
2969
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2968
diff
changeset
|
164 |
queued = 1 |
2775
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 |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
168 |
get[f] = (m2.execf(f), m2[f]) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
169 |
|
2969
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2968
diff
changeset
|
170 |
# do we still need to look at mode bits? |
833677bc9791
merge: rename mysterious variable
Matt Mackall <mpm@selenic.com>
parents:
2968
diff
changeset
|
171 |
if not queued and mw.execf(f) != m2.execf(f): |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
172 |
if overwrite: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
173 |
repo.ui.debug(_(" updating permissions for %s\n") % f) |
2838
b11c014dcbd9
Merge: use single objects for tracking manifests
Matt Mackall <mpm@selenic.com>
parents:
2837
diff
changeset
|
174 |
util.set_exec(repo.wjoin(f), m2.execf(f)) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
175 |
else: |
2892
dd41ad984f71
merge: factor out exec bit merge function
Matt Mackall <mpm@selenic.com>
parents:
2891
diff
changeset
|
176 |
if fmerge(f, mw, m2, ma) != mw.execf(f): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
177 |
repo.ui.debug(_(" updating permissions for %s\n") |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
178 |
% f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
179 |
util.set_exec(repo.wjoin(f), mode) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
180 |
del m2[f] |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
181 |
elif f in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
182 |
if n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
183 |
r = _("d") |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
184 |
if not overwrite and (linear_path or branchmerge): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
185 |
r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
186 |
(_(" local changed %s which remote deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
187 |
_("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
188 |
if r == _("d"): |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
189 |
remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
190 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
191 |
repo.ui.debug(_("other deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
192 |
remove.append(f) # other deleted it |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
193 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
194 |
# file is created on branch or in working directory |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
195 |
if overwrite and f not in umap: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
196 |
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
|
197 |
remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
198 |
elif n == m1.get(f, nullid): # same as parent |
2968
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
199 |
if backwards: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
200 |
repo.ui.debug(_("remote deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
201 |
remove.append(f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
202 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
203 |
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
|
204 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
205 |
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
|
206 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
207 |
for f, n in m2.iteritems(): |
2811
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2810
diff
changeset
|
208 |
if partial and not partial(f): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
209 |
continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
210 |
if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
211 |
continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
212 |
if f in ma and n != ma[f]: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
213 |
r = _("k") |
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
214 |
if not overwrite and (linear_path or branchmerge): |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
215 |
r = repo.ui.prompt( |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
216 |
(_("remote changed %s which local deleted\n") % f) + |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
217 |
_("(k)eep or (d)elete?"), _("[kd]"), _("k")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
218 |
if r == _("k"): |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
219 |
get[f] = (m2.execf(f), n) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
220 |
elif f not in ma: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
221 |
repo.ui.debug(_("remote created %s\n") % f) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
222 |
get[f] = (m2.execf(f), n) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
223 |
else: |
2968
545d33aa3f82
merge: add backwards variable
Matt Mackall <mpm@selenic.com>
parents:
2899
diff
changeset
|
224 |
if overwrite or backwards: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
225 |
repo.ui.debug(_("local deleted %s, recreating\n") % f) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
226 |
get[f] = (m2.execf(f), n) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
227 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
228 |
repo.ui.debug(_("local deleted %s\n") % f) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
229 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
230 |
del mw, m1, m2, ma |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
231 |
|
2897
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2896
diff
changeset
|
232 |
### apply phase |
dd032b0f02ac
merge: move forgets to the apply stage
Matt Mackall <mpm@selenic.com>
parents:
2896
diff
changeset
|
233 |
|
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
234 |
if overwrite: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
235 |
for f in merge: |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
236 |
get[f] = merge[f][:2] |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
237 |
merge = {} |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
238 |
|
2815
4870f795f681
Merge: combine force and forcemerge arguments
Matt Mackall <mpm@selenic.com>
parents:
2814
diff
changeset
|
239 |
if linear_path or overwrite: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
240 |
# 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
|
241 |
p1, p2 = p2, nullid |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
242 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
243 |
xp1 = hex(p1) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
244 |
xp2 = hex(p2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
245 |
if p2 == nullid: xxp2 = '' |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
246 |
else: xxp2 = xp2 |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
247 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
248 |
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
|
249 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
250 |
# 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
|
251 |
files = get.keys() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
252 |
files.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
253 |
for f in files: |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
254 |
flag, node = get[f] |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
255 |
if f[0] == "/": |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
256 |
continue |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
257 |
repo.ui.note(_("getting %s\n") % f) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
258 |
t = repo.file(f).read(node) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
259 |
repo.wwrite(f, t) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
260 |
util.set_exec(repo.wjoin(f), flag) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
261 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
262 |
# merge the tricky bits |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
263 |
unresolved = [] |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
264 |
files = merge.keys() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
265 |
files.sort() |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
266 |
for f in files: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
267 |
repo.ui.status(_("merging %s\n") % f) |
2837
19b3bc840182
Merge: save away mode bit so that we don't need manifest later
Matt Mackall <mpm@selenic.com>
parents:
2836
diff
changeset
|
268 |
flag, my, other = merge[f] |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
269 |
ret = merge3(repo, f, my, other, xp1, xp2) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
270 |
if ret: |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
271 |
unresolved.append(f) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
272 |
util.set_exec(repo.wjoin(f), flag) |
2899
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
273 |
|
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
274 |
remove.sort() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
275 |
for f in remove: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
276 |
repo.ui.note(_("removing %s\n") % f) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
277 |
util.audit_path(f) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
278 |
try: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
279 |
util.unlink(repo.wjoin(f)) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
280 |
except OSError, inst: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
281 |
if inst.errno != errno.ENOENT: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
282 |
repo.ui.warn(_("update failed to remove %s: %s!\n") % |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
283 |
(f, inst.strerror)) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
284 |
|
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
285 |
# update dirstate |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
286 |
if not partial: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
287 |
repo.dirstate.setparents(p1, p2) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
288 |
repo.dirstate.forget(forget) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
289 |
if branchmerge: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
290 |
repo.dirstate.update(remove, 'r') |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
291 |
else: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
292 |
repo.dirstate.forget(remove) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
293 |
|
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
294 |
files = get.keys() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
295 |
files.sort() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
296 |
for f in files: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
297 |
if branchmerge: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
298 |
repo.dirstate.update([f], 'n', st_mtime=-1) |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
299 |
else: |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
300 |
repo.dirstate.update([f], 'n') |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
301 |
|
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
302 |
files = merge.keys() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
303 |
files.sort() |
8743188f4d2e
merge: consolidate dirstate updates
Matt Mackall <mpm@selenic.com>
parents:
2898
diff
changeset
|
304 |
for f in files: |
2810
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
305 |
if branchmerge: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
306 |
# 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
|
307 |
# so that we properly record the merger later |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
308 |
repo.dirstate.update([f], 'm') |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
309 |
else: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
310 |
# 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
|
311 |
# 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
|
312 |
# 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
|
313 |
# merge will appear as a normal local file |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
314 |
# modification. |
2898
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2897
diff
changeset
|
315 |
fl = repo.file(f) |
db397c38005d
merge: use file size stored in revlog index
Matt Mackall <mpm@selenic.com>
parents:
2897
diff
changeset
|
316 |
f_len = fl.size(fl.rev(other)) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
317 |
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
|
318 |
|
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
319 |
if show_stats: |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
320 |
stats = ((len(get), _("updated")), |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
321 |
(len(merge) - len(unresolved), _("merged")), |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
322 |
(len(remove), _("removed")), |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
323 |
(len(unresolved), _("unresolved"))) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
324 |
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
|
325 |
repo.ui.status("%s\n" % note) |
2811
1ea086bc2086
Merge: combine choose and moddirstate to partial
Matt Mackall <mpm@selenic.com>
parents:
2810
diff
changeset
|
326 |
if not partial: |
2810
ca06d35af65e
Rename merge.allow -> merge.branchmerge
Matt Mackall <mpm@selenic.com>
parents:
2803
diff
changeset
|
327 |
if branchmerge: |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
328 |
if unresolved: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
329 |
repo.ui.status(_("There are unresolved merges," |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
330 |
" you can redo the full merge using:\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
331 |
" hg update -C %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
332 |
" hg merge %s\n" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
333 |
% (repo.changelog.rev(p1), |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
334 |
repo.changelog.rev(p2)))) |
2803 | 335 |
elif remind: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
336 |
repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
337 |
elif unresolved: |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
338 |
repo.ui.status(_("There are unresolved merges with" |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
339 |
" locally modified files.\n")) |
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
340 |
|
2813
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
341 |
repo.hook('update', parent1=xp1, parent2=xxp2, error=len(unresolved)) |
56f99f5aab34
Merge: refactor err and failedmerge -> unresolved
Matt Mackall <mpm@selenic.com>
parents:
2812
diff
changeset
|
342 |
return len(unresolved) |
2775
b550cd82f92a
Move merge code to its own module
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
343 |