Show More
@@ -410,12 +410,30 b' def _verifytext(text, path, ui, opts):' | |||||
410 |
|
410 | |||
411 | def simplemerge(ui, localfile, basefile, otherfile, |
|
411 | def simplemerge(ui, localfile, basefile, otherfile, | |
412 | localctx=None, basectx=None, otherctx=None, repo=None, **opts): |
|
412 | localctx=None, basectx=None, otherctx=None, repo=None, **opts): | |
|
413 | """Performs the simplemerge algorithm. | |||
|
414 | ||||
|
415 | {local|base|other}ctx are optional. If passed, they (local/base/other) will | |||
|
416 | be read from. You should pass explicit labels in this mode since the default | |||
|
417 | is to use the file paths.""" | |||
413 | def readfile(filename): |
|
418 | def readfile(filename): | |
414 | f = open(filename, "rb") |
|
419 | f = open(filename, "rb") | |
415 | text = f.read() |
|
420 | text = f.read() | |
416 | f.close() |
|
421 | f.close() | |
417 | return _verifytext(text, filename, ui, opts) |
|
422 | return _verifytext(text, filename, ui, opts) | |
418 |
|
423 | |||
|
424 | def readctx(ctx): | |||
|
425 | if not ctx: | |||
|
426 | return None | |||
|
427 | if not repo: | |||
|
428 | raise error.ProgrammingError('simplemerge: repo must be passed if ' | |||
|
429 | 'using contexts') | |||
|
430 | # `wwritedata` is used to get the post-filter data from `ctx` (i.e., | |||
|
431 | # what would have been in the working copy). Since merges were run in | |||
|
432 | # the working copy, and thus used post-filter data, we do the same to | |||
|
433 | # maintain behavior. | |||
|
434 | return repo.wwritedata(ctx.path(), | |||
|
435 | _verifytext(ctx.data(), ctx.path(), ui, opts)) | |||
|
436 | ||||
419 | mode = opts.get('mode','merge') |
|
437 | mode = opts.get('mode','merge') | |
420 | if mode == 'union': |
|
438 | if mode == 'union': | |
421 | name_a = None |
|
439 | name_a = None | |
@@ -436,9 +454,9 b' def simplemerge(ui, localfile, basefile,' | |||||
436 | raise error.Abort(_("can only specify three labels.")) |
|
454 | raise error.Abort(_("can only specify three labels.")) | |
437 |
|
455 | |||
438 | try: |
|
456 | try: | |
439 | localtext = readfile(localfile) |
|
457 | localtext = readctx(localctx) if localctx else readfile(localfile) | |
440 | basetext = readfile(basefile) |
|
458 | basetext = readctx(basectx) if basectx else readfile(basefile) | |
441 | othertext = readfile(otherfile) |
|
459 | othertext = readctx(otherctx) if otherctx else readfile(otherfile) | |
442 | except error.Abort: |
|
460 | except error.Abort: | |
443 | return 1 |
|
461 | return 1 | |
444 |
|
462 |
@@ -128,7 +128,7 b' add some changesets to rename/remove/mer' | |||||
128 | $ hg merge |
|
128 | $ hg merge | |
129 | merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat |
|
129 | merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat | |
130 | merging sub/normal2 and stuff/normal2 to stuff/normal2 |
|
130 | merging sub/normal2 and stuff/normal2 to stuff/normal2 | |
131 |
warning: |
|
131 | warning: stuff/maybelarge.dat looks like a binary file. (glob) | |
132 | warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg resolve --mark') |
|
132 | warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg resolve --mark') | |
133 | 0 files updated, 1 files merged, 0 files removed, 1 files unresolved |
|
133 | 0 files updated, 1 files merged, 0 files removed, 1 files unresolved | |
134 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
|
134 | use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon |
General Comments 0
You need to be logged in to leave comments.
Login now