##// END OF EJS Templates
simplemerge: use contexts to read file data from, if passed...
Phil Cohen -
r33827:8b91a4ff default
parent child Browse files
Show More
@@ -410,12 +410,30 b' def _verifytext(text, path, ui, opts):'
410 410
411 411 def simplemerge(ui, localfile, basefile, otherfile,
412 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 418 def readfile(filename):
414 419 f = open(filename, "rb")
415 420 text = f.read()
416 421 f.close()
417 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 437 mode = opts.get('mode','merge')
420 438 if mode == 'union':
421 439 name_a = None
@@ -436,9 +454,9 b' def simplemerge(ui, localfile, basefile,'
436 454 raise error.Abort(_("can only specify three labels."))
437 455
438 456 try:
439 localtext = readfile(localfile)
440 basetext = readfile(basefile)
441 othertext = readfile(otherfile)
457 localtext = readctx(localctx) if localctx else readfile(localfile)
458 basetext = readctx(basectx) if basectx else readfile(basefile)
459 othertext = readctx(otherctx) if otherctx else readfile(otherfile)
442 460 except error.Abort:
443 461 return 1
444 462
@@ -128,7 +128,7 b' add some changesets to rename/remove/mer'
128 128 $ hg merge
129 129 merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat
130 130 merging sub/normal2 and stuff/normal2 to stuff/normal2
131 warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary file. (glob)
131 warning: stuff/maybelarge.dat looks like a binary file. (glob)
132 132 warning: conflicts while merging stuff/maybelarge.dat! (edit, then use 'hg resolve --mark')
133 133 0 files updated, 1 files merged, 0 files removed, 1 files unresolved
134 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