Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/merge.py @ 3315:e8be5942335d
merge: pull file copy/move out of filemerge
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 10 Oct 2006 00:54:00 -0500 |
parents | ecc1bf27378c |
children | 966632304dde |
comparison
equal
deleted
inserted
replaced
3314:ecc1bf27378c | 3315:e8be5942335d |
---|---|
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, wctx, mctx, move): | 13 def filemerge(repo, fw, fo, wctx, mctx): |
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 | |
19 wctx, mctx = working and merge changecontexts | 18 wctx, mctx = working and merge changecontexts |
20 move = whether to move or copy the file to the destination | |
21 | 19 |
22 TODO: | 20 TODO: |
23 if fw is copied in the working directory, we get confused | 21 if fw is copied in the working directory, we get confused |
24 implement move and fd | 22 implement move and fd |
25 """ | 23 """ |
50 environ={'HG_FILE': fw, | 48 environ={'HG_FILE': fw, |
51 'HG_MY_NODE': str(wctx.parents()[0]), | 49 'HG_MY_NODE': str(wctx.parents()[0]), |
52 'HG_OTHER_NODE': str(mctx)}) | 50 'HG_OTHER_NODE': str(mctx)}) |
53 if r: | 51 if r: |
54 repo.ui.warn(_("merging %s failed!\n") % fw) | 52 repo.ui.warn(_("merging %s failed!\n") % fw) |
55 else: | |
56 if fd != fw: | |
57 repo.ui.debug(_("copying %s to %s\n") % (fw, fd)) | |
58 repo.wwrite(fd, repo.wread(fw)) | |
59 if move: | |
60 repo.ui.debug(_("removing %s\n") % fw) | |
61 os.unlink(a) | |
62 | 53 |
63 os.unlink(b) | 54 os.unlink(b) |
64 os.unlink(c) | 55 os.unlink(c) |
65 return r | 56 return r |
66 | 57 |
292 f2, fd, flag, move = a[2:] | 283 f2, fd, flag, move = a[2:] |
293 if f != f2: | 284 if f != f2: |
294 repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd)) | 285 repo.ui.status(_("merging %s and %s to %s\n") % (f, f2, fd)) |
295 else: | 286 else: |
296 repo.ui.status(_("merging %s\n") % f) | 287 repo.ui.status(_("merging %s\n") % f) |
297 if filemerge(repo, f, f2, fd, wctx, mctx, move): | 288 if filemerge(repo, f, f2, wctx, mctx): |
298 unresolved += 1 | 289 unresolved += 1 |
290 else: | |
291 if f != fd: | |
292 repo.ui.debug(_("copying %s to %s\n") % (f, fd)) | |
293 repo.wwrite(fd, repo.wread(f)) | |
294 if move: | |
295 repo.ui.debug(_("removing %s\n") % f) | |
296 os.unlink(repo.wjoin(f)) | |
297 | |
299 util.set_exec(repo.wjoin(fd), flag) | 298 util.set_exec(repo.wjoin(fd), flag) |
300 merged += 1 | 299 merged += 1 |
301 elif m == "g": # get | 300 elif m == "g": # get |
302 flag = a[2] | 301 flag = a[2] |
303 repo.ui.note(_("getting %s\n") % f) | 302 repo.ui.note(_("getting %s\n") % f) |