Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 3312:c5075ad5e3e9
merge: use contexts in checkunknown and forgetremoved
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 10 Oct 2006 01:43:58 -0500 |
parents | 966632304dde |
children | b16456909a0a |
comparison
equal
deleted
inserted
replaced
3311:966632304dde | 3312:c5075ad5e3e9 |
---|---|
61 | 61 |
62 os.unlink(b) | 62 os.unlink(b) |
63 os.unlink(c) | 63 os.unlink(c) |
64 return r | 64 return r |
65 | 65 |
66 def checkunknown(repo, m2, wctx): | 66 def checkunknown(wctx, mctx): |
67 """ | 67 """ |
68 check for collisions between unknown files and files in m2 | 68 check for collisions between unknown files and files in m2 |
69 """ | 69 """ |
70 man = mctx.manifest() | |
70 for f in wctx.unknown(): | 71 for f in wctx.unknown(): |
71 if f in m2: | 72 if f in man: |
72 if repo.file(f).cmp(m2[f], repo.wread(f)): | 73 if mctx.filectx(f).cmp(wctx.filectx(f).data()): |
73 raise util.Abort(_("'%s' already exists in the working" | 74 raise util.Abort(_("'%s' already exists in the working" |
74 " dir and differs from remote") % f) | 75 " dir and differs from remote") % f) |
75 | 76 |
76 def forgetremoved(m2, wctx): | 77 def forgetremoved(wctx, mctx): |
77 """ | 78 """ |
78 Forget removed files | 79 Forget removed files |
79 | 80 |
80 If we're jumping between revisions (as opposed to merging), and if | 81 If we're jumping between revisions (as opposed to merging), and if |
81 neither the working directory nor the target rev has the file, | 82 neither the working directory nor the target rev has the file, |
83 dirstate from listing the file when it is no longer in the | 84 dirstate from listing the file when it is no longer in the |
84 manifest. | 85 manifest. |
85 """ | 86 """ |
86 | 87 |
87 action = [] | 88 action = [] |
88 | 89 man = mctx.manifest() |
89 for f in wctx.deleted() + wctx.removed(): | 90 for f in wctx.deleted() + wctx.removed(): |
90 if f not in m2: | 91 if f not in man: |
91 action.append((f, "f")) | 92 action.append((f, "f")) |
92 | 93 |
93 return action | 94 return action |
94 | 95 |
95 def nonoverlap(d1, d2): | 96 def nonoverlap(d1, d2): |
381 | 382 |
382 if branchmerge and not forcemerge: | 383 if branchmerge and not forcemerge: |
383 if wc.modified() or wc.added() or wc.removed(): | 384 if wc.modified() or wc.added() or wc.removed(): |
384 raise util.Abort(_("outstanding uncommitted changes")) | 385 raise util.Abort(_("outstanding uncommitted changes")) |
385 | 386 |
386 m1 = wc.manifest() | |
387 m2 = p2.manifest() | |
388 | |
389 # resolve the manifest to determine which files | 387 # resolve the manifest to determine which files |
390 # we care about merging | 388 # we care about merging |
391 repo.ui.note(_("resolving manifests\n")) | 389 repo.ui.note(_("resolving manifests\n")) |
392 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % | 390 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % |
393 (overwrite, branchmerge, bool(partial))) | 391 (overwrite, branchmerge, bool(partial))) |
394 repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa)) | 392 repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa)) |
395 | 393 |
396 action = [] | 394 action = [] |
397 | 395 |
398 if not force: | 396 if not force: |
399 checkunknown(repo, m2, wc) | 397 checkunknown(wc, p2) |
400 if not branchmerge: | 398 if not branchmerge: |
401 action += forgetremoved(m2, wc) | 399 action += forgetremoved(wc, p2) |
402 | 400 |
403 action += manifestmerge(repo, wc, p2, pa, overwrite, partial) | 401 action += manifestmerge(repo, wc, p2, pa, overwrite, partial) |
404 | 402 |
405 ### apply phase | 403 ### apply phase |
406 | 404 |