Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 3307:f009a6f12a59
merge: swap file and mode args for act()
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 10 Oct 2006 00:32:30 -0500 |
parents | 5c9806554d65 |
children | ecc1bf27378c |
comparison
equal
deleted
inserted
replaced
3306:5c9806554d65 | 3307:f009a6f12a59 |
---|---|
190 a, b, c = ma.execf(fa), m1.execf(f), m2.execf(f2) | 190 a, b, c = ma.execf(fa), m1.execf(f), m2.execf(f2) |
191 return ((a^b) | (a^c)) ^ a | 191 return ((a^b) | (a^c)) ^ a |
192 | 192 |
193 action = [] | 193 action = [] |
194 | 194 |
195 def act(msg, f, m, *args): | 195 def act(msg, m, f, *args): |
196 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) | 196 repo.ui.debug(" %s: %s -> %s\n" % (f, msg, m)) |
197 action.append((f, m) + args) | 197 action.append((f, m) + args) |
198 | 198 |
199 copy = {} | 199 copy = {} |
200 if not (backwards or overwrite): | 200 if not (backwards or overwrite): |
208 # are files different? | 208 # are files different? |
209 if n != m2[f]: | 209 if n != m2[f]: |
210 a = ma.get(f, nullid) | 210 a = ma.get(f, nullid) |
211 # are both different from the ancestor? | 211 # are both different from the ancestor? |
212 if not overwrite and n != a and m2[f] != a: | 212 if not overwrite and n != a and m2[f] != a: |
213 act("versions differ", f, "m", fmerge(f)) | 213 act("versions differ", "m", f, fmerge(f)) |
214 # are we clobbering? | 214 # are we clobbering? |
215 # is remote's version newer? | 215 # is remote's version newer? |
216 # or are we going back in time and clean? | 216 # or are we going back in time and clean? |
217 elif overwrite or m2[f] != a or (backwards and not n[20:]): | 217 elif overwrite or m2[f] != a or (backwards and not n[20:]): |
218 act("remote is newer", f, "g", m2.execf(f)) | 218 act("remote is newer", "g", f, m2.execf(f)) |
219 # local is newer, not overwrite, check mode bits | 219 # local is newer, not overwrite, check mode bits |
220 elif fmerge(f) != m1.execf(f): | 220 elif fmerge(f) != m1.execf(f): |
221 act("update permissions", f, "e", m2.execf(f)) | 221 act("update permissions", "e", f, m2.execf(f)) |
222 # contents same, check mode bits | 222 # contents same, check mode bits |
223 elif m1.execf(f) != m2.execf(f): | 223 elif m1.execf(f) != m2.execf(f): |
224 if overwrite or fmerge(f) != m1.execf(f): | 224 if overwrite or fmerge(f) != m1.execf(f): |
225 act("update permissions", f, "e", m2.execf(f)) | 225 act("update permissions", "e", f, m2.execf(f)) |
226 elif f in copy: | 226 elif f in copy: |
227 f2 = copy[f] | 227 f2 = copy[f] |
228 if f in ma: # case 3,20 A/B/A | 228 if f in ma: # case 3,20 A/B/A |
229 act("remote moved", | 229 act("remote moved", "c", |
230 f, "c", f2, f2, fmerge(f, f2, f), True) | 230 f, f2, f2, fmerge(f, f2, f), True) |
231 else: | 231 else: |
232 if f2 in m1: # case 2 A,B/B/B | 232 if f2 in m1: # case 2 A,B/B/B |
233 act("local copied", | 233 act("local copied", "c", |
234 f, "c", f2, f, fmerge(f, f2, f2), False) | 234 f, f2, f, fmerge(f, f2, f2), False) |
235 else: # case 4,21 A/B/B | 235 else: # case 4,21 A/B/B |
236 act("local moved", | 236 act("local moved", "c", |
237 f, "c", f2, f, fmerge(f, f2, f2), False) | 237 f, f2, f, fmerge(f, f2, f2), False) |
238 elif f in ma: | 238 elif f in ma: |
239 if n != ma[f] and not overwrite: | 239 if n != ma[f] and not overwrite: |
240 if repo.ui.prompt( | 240 if repo.ui.prompt( |
241 (_(" local changed %s which remote deleted\n") % f) + | 241 (_(" local changed %s which remote deleted\n") % f) + |
242 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("d"): | 242 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("d"): |
243 act("prompt delete", f, "r") | 243 act("prompt delete", "r", f) |
244 else: | 244 else: |
245 act("other deleted", f, "r") | 245 act("other deleted", "r", f) |
246 else: | 246 else: |
247 # file is created on branch or in working directory | 247 # file is created on branch or in working directory |
248 if (overwrite and n[20:] != "u") or (backwards and not n[20:]): | 248 if (overwrite and n[20:] != "u") or (backwards and not n[20:]): |
249 act("remote deleted", f, "r") | 249 act("remote deleted", "r", f) |
250 | 250 |
251 for f, n in m2.iteritems(): | 251 for f, n in m2.iteritems(): |
252 if partial and not partial(f): | 252 if partial and not partial(f): |
253 continue | 253 continue |
254 if f in m1: | 254 if f in m1: |
256 if f in copy: | 256 if f in copy: |
257 f2 = copy[f] | 257 f2 = copy[f] |
258 if f2 not in m2: # already seen | 258 if f2 not in m2: # already seen |
259 continue | 259 continue |
260 # rename case 1, A/A,B/A | 260 # rename case 1, A/A,B/A |
261 act("remote copied", f2, "c", f, f, fmerge(f2, f, f2), False) | 261 act("remote copied", "c", f2, f, f, fmerge(f2, f, f2), False) |
262 elif f in ma: | 262 elif f in ma: |
263 if overwrite or backwards: | 263 if overwrite or backwards: |
264 act("recreating", f, "g", m2.execf(f)) | 264 act("recreating", "g", f, m2.execf(f)) |
265 elif n != ma[f]: | 265 elif n != ma[f]: |
266 if repo.ui.prompt( | 266 if repo.ui.prompt( |
267 (_("remote changed %s which local deleted\n") % f) + | 267 (_("remote changed %s which local deleted\n") % f) + |
268 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("k"): | 268 _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("k"): |
269 act("prompt recreating", f, "g", m2.execf(f)) | 269 act("prompt recreating", "g", f, m2.execf(f)) |
270 else: | 270 else: |
271 act("remote created", f, "g", m2.execf(f)) | 271 act("remote created", "g", f, m2.execf(f)) |
272 | 272 |
273 return action | 273 return action |
274 | 274 |
275 def applyupdates(repo, action, wctx, mctx): | 275 def applyupdates(repo, action, wctx, mctx): |
276 updated, merged, removed, unresolved = 0, 0, 0, 0 | 276 updated, merged, removed, unresolved = 0, 0, 0, 0 |