comparison mercurial/merge.py @ 3305:e7abcf3a7c5f

filemerge: use contexts rather than my and other
author Matt Mackall <mpm@selenic.com>
date Mon, 09 Oct 2006 21:27:04 -0500
parents 69b9471f26bb
children 488d3062d225
comparison
equal deleted inserted replaced
3304:45f0c49f0449 3305:e7abcf3a7c5f
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(), "errno util os tempfile") 11 demandload(globals(), "errno util os tempfile")
12 12
13 def filemerge(repo, fw, fo, fd, my, other, wctx, mctx, move): 13 def filemerge(repo, fw, fo, fd, wctx, mctx, move):
14 """perform a 3-way merge in the working directory 14 """perform a 3-way merge in the working directory
15 15
16 fw = filename in the working directory and first parent 16 fw = filename in the working directory and first parent
17 fo = filename in other parent 17 fo = filename in other parent
18 fd = destination filename 18 fd = destination filename
32 f = os.fdopen(fd, "wb") 32 f = os.fdopen(fd, "wb")
33 repo.wwrite(ctx.path(), ctx.data(), f) 33 repo.wwrite(ctx.path(), ctx.data(), f)
34 f.close() 34 f.close()
35 return name 35 return name
36 36
37 fcm = repo.filectx(fw, fileid=my) 37 fcm = wctx.filectx(fw)
38 fco = repo.filectx(fo, fileid=other) 38 fco = mctx.filectx(fo)
39 fca = fcm.ancestor(fco) 39 fca = fcm.ancestor(fco)
40 if not fca: 40 if not fca:
41 fca = repo.filectx(fw, fileid=-1) 41 fca = repo.filectx(fw, fileid=-1)
42 a = repo.wjoin(fw) 42 a = repo.wjoin(fw)
43 b = temp("base", fca) 43 b = temp("base", fca)
293 (f, inst.strerror)) 293 (f, inst.strerror))
294 removed +=1 294 removed +=1
295 elif m == "c": # copy 295 elif m == "c": # copy
296 f2, fd, my, other, flag, move = a[2:] 296 f2, fd, my, other, flag, move = a[2:]
297 repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd)) 297 repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd))
298 if filemerge(repo, f, f2, fd, my, other, wctx, mctx, move): 298 if filemerge(repo, f, f2, fd, wctx, mctx, move):
299 unresolved += 1 299 unresolved += 1
300 util.set_exec(repo.wjoin(fd), flag) 300 util.set_exec(repo.wjoin(fd), flag)
301 merged += 1 301 merged += 1
302 elif m == "m": # merge 302 elif m == "m": # merge
303 flag, my, other = a[2:] 303 flag, my, other = a[2:]
304 repo.ui.status(_("merging %s\n") % f) 304 repo.ui.status(_("merging %s\n") % f)
305 if filemerge(repo, f, f, f, my, other, wctx, mctx, False): 305 if filemerge(repo, f, f, f, wctx, mctx, False):
306 unresolved += 1 306 unresolved += 1
307 util.set_exec(repo.wjoin(f), flag) 307 util.set_exec(repo.wjoin(f), flag)
308 merged += 1 308 merged += 1
309 elif m == "g": # get 309 elif m == "g": # get
310 flag, node = a[2:] 310 flag, node = a[2:]