7 |
7 |
8 from node import * |
8 from node import * |
9 from i18n import gettext as _ |
9 from i18n import gettext as _ |
10 from demandload import * |
10 from demandload import * |
11 demandload(globals(), "util os tempfile") |
11 demandload(globals(), "util os tempfile") |
|
12 |
|
13 def fmerge(f, local, other, ancestor): |
|
14 """merge executable flags""" |
|
15 a, b, c = ancestor.execf(f), local.execf(f), other.execf(f) |
|
16 return ((a^b) | (a^c)) ^ a |
12 |
17 |
13 def merge3(repo, fn, my, other, p1, p2): |
18 def merge3(repo, fn, my, other, p1, p2): |
14 """perform a 3-way merge in the working directory""" |
19 """perform a 3-way merge in the working directory""" |
15 |
20 |
16 def temp(prefix, node): |
21 def temp(prefix, node): |
142 if n != m2[f]: |
147 if n != m2[f]: |
143 a = ma.get(f, nullid) |
148 a = ma.get(f, nullid) |
144 # are both different from the ancestor? |
149 # are both different from the ancestor? |
145 if n != a and m2[f] != a: |
150 if n != a and m2[f] != a: |
146 repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
151 repo.ui.debug(_(" %s versions differ, resolve\n") % f) |
147 # merge executable bits |
152 merge[f] = (fmerge(f, mw, m2, ma), m1.get(f, nullid), m2[f]) |
148 # "if we changed or they changed, change in merge" |
|
149 a, b, c = ma.execf(f), mw.execf(f), m2.execf(f) |
|
150 mode = ((a^b) | (a^c)) ^ a |
|
151 merge[f] = (mode, m1.get(f, nullid), m2[f]) |
|
152 s = 1 |
153 s = 1 |
153 # are we clobbering? |
154 # are we clobbering? |
154 # is remote's version newer? |
155 # is remote's version newer? |
155 # or are we going back in time? |
156 # or are we going back in time? |
156 elif overwrite or m2[f] != a or (p2 == pa and mw[f] == m1[f]): |
157 elif overwrite or m2[f] != a or (p2 == pa and mw[f] == m1[f]): |
165 if not s and mw.execf(f) != m2.execf(f): |
166 if not s and mw.execf(f) != m2.execf(f): |
166 if overwrite: |
167 if overwrite: |
167 repo.ui.debug(_(" updating permissions for %s\n") % f) |
168 repo.ui.debug(_(" updating permissions for %s\n") % f) |
168 util.set_exec(repo.wjoin(f), m2.execf(f)) |
169 util.set_exec(repo.wjoin(f), m2.execf(f)) |
169 else: |
170 else: |
170 a, b, c = ma.execf(f), mw.execf(f), m2.execf(f) |
171 if fmerge(f, mw, m2, ma) != mw.execf(f): |
171 mode = ((a^b) | (a^c)) ^ a |
|
172 if mode != b: |
|
173 repo.ui.debug(_(" updating permissions for %s\n") |
172 repo.ui.debug(_(" updating permissions for %s\n") |
174 % f) |
173 % f) |
175 util.set_exec(repo.wjoin(f), mode) |
174 util.set_exec(repo.wjoin(f), mode) |
176 del m2[f] |
175 del m2[f] |
177 elif f in ma: |
176 elif f in ma: |