def _premerge(repo, toolconf, files, labels=None): tool, toolpath, binary, symlink = toolconf if symlink: return 1 a, b, c, back = files ui = repo.ui validkeep = ['keep', 'keep-merge3'] # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not binary) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() if premerge not in validkeep: _valid = ', '.join(["'" + v + "'" for v in validkeep]) raise error.ConfigError( _("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid)) if premerge: if premerge == 'keep-merge3': if not labels: labels = _defaultconflictlabels if len(labels) < 3: labels.append('base') r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels) if not r: ui.debug(" premerge successful\n") return 0 if premerge not in validkeep: util.copyfile(back, a) # restore from backup and try again return 1 # continue merging
def _premerge(repo, toolconf, files, labels=None): tool, toolpath, binary, symlink = toolconf if symlink: return 1 a, b, c, back = files ui = repo.ui validkeep = ['keep', 'keep-merge3'] # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not binary) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() if premerge not in validkeep: _valid = ', '.join(["'" + v + "'" for v in validkeep]) raise error.ConfigError(_("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid)) if premerge: if premerge == 'keep-merge3': if not labels: labels = _defaultconflictlabels if len(labels) < 3: labels.append('base') r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels) if not r: ui.debug(" premerge successful\n") return 0 if premerge not in validkeep: util.copyfile(back, a) # restore from backup and try again return 1 # continue merging
def _premerge(repo, toolconf, files): tool, toolpath, binary, symlink = toolconf a, b, c, back = files ui = repo.ui # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not (binary or symlink)) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() valid = 'keep'.split() if premerge not in valid: _valid = ', '.join(["'" + v + "'" for v in valid]) raise error.ConfigError( _("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid)) if premerge: r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(" premerge successful\n") return 0 if premerge != 'keep': util.copyfile(back, a) # restore from backup and try again return 1 # continue merging
def _premerge(repo, toolconf, files): tool, toolpath, binary, symlink = toolconf if symlink: return 1 a, b, c, back = files ui = repo.ui # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not binary) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() valid = 'keep'.split() if premerge not in valid: _valid = ', '.join(["'" + v + "'" for v in valid]) raise error.ConfigError(_("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid)) if premerge: r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(" premerge successful\n") return 0 if premerge != 'keep': util.copyfile(back, a) # restore from backup and try again return 1 # continue merging
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): """ Uses the internal non-interactive simple merge algorithm for merging files. It will fail if there are any conflicts and leave markers in the partially merged file.""" r = _premerge(repo, toolconf, files) if r: a, b, c, back = files ui = repo.ui r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) return True, r return False, 0
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): """ Uses the internal non-interactive simple merge algorithm for merging files. It will fail if there are any conflicts and leave markers in the partially merged file.""" r = _premerge(repo, toolconf, files) if r: a, b, c, back = files ui = repo.ui r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) return True, r return False, 0
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files): """ Uses the internal non-interactive simple merge algorithm for merging files. It will fail if there are any conflicts and leave markers in the partially merged file.""" tool, toolpath, binary, symlink = toolconf if symlink: repo.ui.warn(_("warning: internal:merge cannot merge symlinks " "for %s\n") % fcd.path()) return False, 1 r = _premerge(repo, toolconf, files) if r: a, b, c, back = files ui = repo.ui r = simplemerge.simplemerge(ui, a, b, c, label=["local", "other"]) return True, r return False, 0
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): """ Uses the internal non-interactive simple merge algorithm for merging files. It will fail if there are any conflicts and leave markers in the partially merged file. Markers will have two sections, one for each side of merge.""" tool, toolpath, binary, symlink = toolconf if symlink: repo.ui.warn(_('warning: internal :merge cannot merge symlinks ' 'for %s\n') % fcd.path()) return False, 1 r = _premerge(repo, toolconf, files, labels=labels) if r: a, b, c, back = files ui = repo.ui r = simplemerge.simplemerge(ui, a, b, c, label=labels) return True, r return False, 0
def _imerge(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): """ Uses the internal non-interactive simple merge algorithm for merging files. It will fail if there are any conflicts and leave markers in the partially merged file.""" tool, toolpath, binary, symlink = toolconf if symlink: repo.ui.warn( _('warning: internal:merge cannot merge symlinks ' 'for %s\n') % fcd.path()) return False, 1 r = _premerge(repo, toolconf, files, labels=labels) if r: a, b, c, back = files ui = repo.ui r = simplemerge.simplemerge(ui, a, b, c, label=labels, no_minimal=True) return True, r return False, 0
def filemerge(repo, mynode, orig, fcd, fco, fca): """perform a 3-way merge in the working directory mynode = parent node before merge orig = original local filename before merge fco = other file context fca = ancestor file context fcd = local file context for current/destination file """ def temp(prefix, ctx): pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) (fd, name) = tempfile.mkstemp(prefix=pre) data = repo.wwritedata(ctx.path(), ctx.data()) f = os.fdopen(fd, "wb") f.write(data) f.close() return name def isbin(ctx): try: return util.binary(ctx.data()) except IOError: return False if not fco.cmp(fcd.data()): # files identical? return None ui = repo.ui fd = fcd.path() binary = isbin(fcd) or isbin(fco) or isbin(fca) symlink = 'l' in fcd.flags() + fco.flags() tool, toolpath = _picktool(repo, ui, fd, binary, symlink) ui.debug(_("picked tool '%s' for %s (binary %s symlink %s)\n") % (tool, fd, binary, symlink)) if not tool or tool == 'internal:prompt': tool = "internal:local" if ui.prompt(_(" no tool found to merge %s\n" "keep (l)ocal or take (o)ther?") % fd, (_("&Local"), _("&Other")), _("l")) != _("l"): tool = "internal:other" if tool == "internal:local": return 0 if tool == "internal:other": repo.wwrite(fd, fco.data(), fco.flags()) return 0 if tool == "internal:fail": return 1 # do the actual merge a = repo.wjoin(fd) b = temp("base", fca) c = temp("other", fco) out = "" back = a + ".orig" util.copyfile(a, back) if orig != fco.path(): ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) else: ui.status(_("merging %s\n") % fd) ui.debug(_("my %s other %s ancestor %s\n") % (fcd, fco, fca)) # do we attempt to simplemerge first? if _toolbool(ui, tool, "premerge", not (binary or symlink)): r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(_(" premerge successful\n")) os.unlink(back) os.unlink(b) os.unlink(c) return 0 util.copyfile(back, a) # restore from backup and try again env = dict(HG_FILE=fd, HG_MY_NODE=short(mynode), HG_OTHER_NODE=str(fco.changectx()), HG_MY_ISLINK='l' in fcd.flags(), HG_OTHER_ISLINK='l' in fco.flags(), HG_BASE_ISLINK='l' in fca.flags()) if tool == "internal:merge": r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) elif tool == 'internal:dump': a = repo.wjoin(fd) util.copyfile(a, a + ".local") repo.wwrite(fd + ".other", fco.data(), fco.flags()) repo.wwrite(fd + ".base", fca.data(), fca.flags()) return 1 # unresolved else: args = _toolstr(ui, tool, "args", '$local $base $other') if "$output" in args: out, a = a, back # read input from backup, write to original replace = dict(local=a, base=b, other=c, output=out) args = re.sub("\$(local|base|other|output)", lambda x: '"%s"' % replace[x.group()[1:]], args) r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env) if not r and _toolbool(ui, tool, "checkconflicts"): if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()): r = 1 if not r and _toolbool(ui, tool, "checkchanged"): if filecmp.cmp(repo.wjoin(fd), back): if ui.prompt(_(" output file %s appears unchanged\n" "was merge successful (yn)?") % fd, (_("&Yes"), _("&No")), _("n")) != _("y"): r = 1 if _toolbool(ui, tool, "fixeol"): _matcheol(repo.wjoin(fd), back) if r: ui.warn(_("merging %s failed!\n") % fd) else: os.unlink(back) os.unlink(b) os.unlink(c) return r
def filemerge(repo, mynode, orig, fcd, fco, fca): """perform a 3-way merge in the working directory mynode = parent node before merge orig = original local filename before merge fco = other file context fca = ancestor file context fcd = local file context for current/destination file """ def temp(prefix, ctx): pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) (fd, name) = tempfile.mkstemp(prefix=pre) data = repo.wwritedata(ctx.path(), ctx.data()) f = os.fdopen(fd, "wb") f.write(data) f.close() return name def isbin(ctx): try: return util.binary(ctx.data()) except IOError: return False if not fco.cmp(fcd.data()): # files identical? return None if fca == fco: # backwards, use working dir parent as ancestor fca = fcd.parents()[0] ui = repo.ui fd = fcd.path() binary = isbin(fcd) or isbin(fco) or isbin(fca) symlink = 'l' in fcd.flags() + fco.flags() tool, toolpath = _picktool(repo, ui, fd, binary, symlink) ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % (tool, fd, binary, symlink)) if not tool or tool == 'internal:prompt': tool = "internal:local" if ui.promptchoice( _(" no tool found to merge %s\n" "keep (l)ocal or take (o)ther?") % fd, (_("&Local"), _("&Other")), 0): tool = "internal:other" if tool == "internal:local": return 0 if tool == "internal:other": repo.wwrite(fd, fco.data(), fco.flags()) return 0 if tool == "internal:fail": return 1 # do the actual merge a = repo.wjoin(fd) b = temp("base", fca) c = temp("other", fco) out = "" back = a + ".orig" util.copyfile(a, back) if orig != fco.path(): ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) else: ui.status(_("merging %s\n") % fd) ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) # do we attempt to simplemerge first? if _toolbool(ui, tool, "premerge", not (binary or symlink)): r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(" premerge successful\n") os.unlink(back) os.unlink(b) os.unlink(c) return 0 util.copyfile(back, a) # restore from backup and try again env = dict(HG_FILE=fd, HG_MY_NODE=short(mynode), HG_OTHER_NODE=str(fco.changectx()), HG_BASE_NODE=str(fca.changectx()), HG_MY_ISLINK='l' in fcd.flags(), HG_OTHER_ISLINK='l' in fco.flags(), HG_BASE_ISLINK='l' in fca.flags()) if tool == "internal:merge": r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) elif tool == 'internal:dump': a = repo.wjoin(fd) util.copyfile(a, a + ".local") repo.wwrite(fd + ".other", fco.data(), fco.flags()) repo.wwrite(fd + ".base", fca.data(), fca.flags()) return 1 # unresolved else: args = _toolstr(ui, tool, "args", '$local $base $other') if "$output" in args: out, a = a, back # read input from backup, write to original replace = dict(local=a, base=b, other=c, output=out) args = re.sub( "\$(local|base|other|output)", lambda x: '"%s"' % util.localpath(replace[x.group()[1:]]), args) r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env) if not r and _toolbool(ui, tool, "checkconflicts"): if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data()): r = 1 if not r and _toolbool(ui, tool, "checkchanged"): if filecmp.cmp(repo.wjoin(fd), back): if ui.promptchoice( _(" output file %s appears unchanged\n" "was merge successful (yn)?") % fd, (_("&Yes"), _("&No")), 1): r = 1 if _toolbool(ui, tool, "fixeol"): _matcheol(repo.wjoin(fd), back) if r: ui.warn(_("merging %s failed!\n") % fd) else: os.unlink(back) os.unlink(b) os.unlink(c) return r
def filemerge(repo, fw, fd, fo, wctx, mctx): """perform a 3-way merge in the working directory fw = original filename in the working directory fd = destination filename in the working directory fo = filename in other parent wctx, mctx = working and merge changecontexts """ def temp(prefix, ctx): pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) (fd, name) = tempfile.mkstemp(prefix=pre) data = repo.wwritedata(ctx.path(), ctx.data()) f = os.fdopen(fd, "wb") f.write(data) f.close() return name def isbin(ctx): try: return util.binary(ctx.data()) except IOError: return False fco = mctx.filectx(fo) if not fco.cmp(wctx.filectx(fd).data()): # files identical? return None ui = repo.ui fcm = wctx.filectx(fw) fca = fcm.ancestor(fco) or repo.filectx(fw, fileid=nullrev) binary = isbin(fcm) or isbin(fco) or isbin(fca) symlink = fcm.islink() or fco.islink() tool, toolpath = _picktool(repo, ui, fw, binary, symlink) ui.debug(_("picked tool '%s' for %s (binary %s symlink %s)\n") % (tool, fw, binary, symlink)) if not tool: tool = "internal:local" if ui.prompt(_(" no tool found to merge %s\n" "keep (l)ocal or take (o)ther?") % fw, _("[lo]"), _("l")) != _("l"): tool = "internal:other" if tool == "internal:local": return 0 if tool == "internal:other": repo.wwrite(fd, fco.data(), fco.fileflags()) return 0 if tool == "internal:fail": return 1 # do the actual merge a = repo.wjoin(fd) b = temp("base", fca) c = temp("other", fco) out = "" back = a + ".orig" util.copyfile(a, back) if fw != fo: repo.ui.status(_("merging %s and %s\n") % (fw, fo)) else: repo.ui.status(_("merging %s\n") % fw) repo.ui.debug(_("my %s other %s ancestor %s\n") % (fcm, fco, fca)) # do we attempt to simplemerge first? if _toolbool(ui, tool, "premerge", not (binary or symlink)): r = simplemerge.simplemerge(a, b, c, quiet=True) if not r: ui.debug(_(" premerge successful\n")) os.unlink(back) os.unlink(b) os.unlink(c) return 0 util.copyfile(back, a) # restore from backup and try again env = dict(HG_FILE=fd, HG_MY_NODE=str(wctx.parents()[0]), HG_OTHER_NODE=str(mctx), HG_MY_ISLINK=fcm.islink(), HG_OTHER_ISLINK=fco.islink(), HG_BASE_ISLINK=fca.islink()) if tool == "internal:merge": r = simplemerge.simplemerge(a, b, c, label=['local', 'other']) else: args = _toolstr(ui, tool, "args", '$local $base $other') if "$output" in args: out, a = a, back # read input from backup, write to original replace = dict(local=a, base=b, other=c, output=out) args = re.sub("\$(local|base|other|output)", lambda x: '"%s"' % replace[x.group()[1:]], args) r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env) if not r and _toolbool(ui, tool, "checkconflicts"): if re.match("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcm.data()): r = 1 if not r and _toolbool(ui, tool, "checkchanged"): if filecmp.cmp(repo.wjoin(fd), back): if ui.prompt(_(" output file %s appears unchanged\n" "was merge successful (yn)?") % fd, _("[yn]"), _("n")) != _("y"): r = 1 if _toolbool(ui, tool, "fixeol"): _matcheol(repo.wjoin(fd), back) if r: repo.ui.warn(_("merging %s failed!\n") % fd) else: os.unlink(back) os.unlink(b) os.unlink(c) return r
def filemerge(repo, mynode, orig, fcd, fco, fca): """perform a 3-way merge in the working directory mynode = parent node before merge orig = original local filename before merge fco = other file context fca = ancestor file context fcd = local file context for current/destination file """ def temp(prefix, ctx): pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) (fd, name) = tempfile.mkstemp(prefix=pre) data = repo.wwritedata(ctx.path(), ctx.data()) f = os.fdopen(fd, "wb") f.write(data) f.close() return name if not fco.cmp(fcd): # files identical? return None ui = repo.ui fd = fcd.path() binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() symlink = 'l' in fcd.flags() + fco.flags() tool, toolpath = _picktool(repo, ui, fd, binary, symlink) ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % (tool, fd, binary, symlink)) if not tool or tool == 'internal:prompt': tool = "internal:local" if ui.promptchoice( _(" no tool found to merge %s\n" "keep (l)ocal or take (o)ther?") % fd, (_("&Local"), _("&Other")), 0): tool = "internal:other" if tool == "internal:local": return 0 if tool == "internal:other": repo.wwrite(fd, fco.data(), fco.flags()) return 0 if tool == "internal:fail": return 1 # do the actual merge a = repo.wjoin(fd) b = temp("base", fca) c = temp("other", fco) out = "" back = a + ".orig" util.copyfile(a, back) if orig != fco.path(): ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) else: ui.status(_("merging %s\n") % fd) ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not (binary or symlink)) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() valid = 'keep'.split() if premerge not in valid: _valid = ', '.join(["'" + v + "'" for v in valid]) raise error.ConfigError( _("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid)) if premerge: r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(" premerge successful\n") os.unlink(back) os.unlink(b) os.unlink(c) return 0 if premerge != 'keep': util.copyfile(back, a) # restore from backup and try again env = dict(HG_FILE=fd, HG_MY_NODE=short(mynode), HG_OTHER_NODE=str(fco.changectx()), HG_BASE_NODE=str(fca.changectx()), HG_MY_ISLINK='l' in fcd.flags(), HG_OTHER_ISLINK='l' in fco.flags(), HG_BASE_ISLINK='l' in fca.flags()) if tool == "internal:merge": r = simplemerge.simplemerge(ui, a, b, c, label=['local', 'other']) elif tool == 'internal:dump': a = repo.wjoin(fd) util.copyfile(a, a + ".local") repo.wwrite(fd + ".other", fco.data(), fco.flags()) repo.wwrite(fd + ".base", fca.data(), fca.flags()) os.unlink(b) os.unlink(c) return 1 # unresolved else: args = _toolstr(ui, tool, "args", '$local $base $other') if "$output" in args: out, a = a, back # read input from backup, write to original replace = dict(local=a, base=b, other=c, output=out) args = util.interpolate(r'\$', replace, args, lambda s: '"%s"' % util.localpath(s)) r = util.system(toolpath + ' ' + args, cwd=repo.root, environ=env, out=ui.fout) if not r and (_toolbool(ui, tool, "checkconflicts") or 'conflicts' in _toollist(ui, tool, "check")): if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), re.MULTILINE): r = 1 checked = False if 'prompt' in _toollist(ui, tool, "check"): checked = True if ui.promptchoice( _("was merge of '%s' successful (yn)?") % fd, (_("&Yes"), _("&No")), 1): r = 1 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or 'changed' in _toollist(ui, tool, "check")): if filecmp.cmp(repo.wjoin(fd), back): if ui.promptchoice( _(" output file %s appears unchanged\n" "was merge successful (yn)?") % fd, (_("&Yes"), _("&No")), 1): r = 1 if _toolbool(ui, tool, "fixeol"): _matcheol(repo.wjoin(fd), back) if r: if tool == "internal:merge": ui.warn( _("merging %s incomplete! " "(edit conflicts, then use 'hg resolve --mark')\n") % fd) else: ui.warn(_("merging %s failed!\n") % fd) else: os.unlink(back) os.unlink(b) os.unlink(c) return r
def filemerge(repo, mynode, orig, fcd, fco, fca): """perform a 3-way merge in the working directory mynode = parent node before merge orig = original local filename before merge fco = other file context fca = ancestor file context fcd = local file context for current/destination file """ def temp(prefix, ctx): pre = "%s~%s." % (os.path.basename(ctx.path()), prefix) (fd, name) = tempfile.mkstemp(prefix=pre) data = repo.wwritedata(ctx.path(), ctx.data()) f = os.fdopen(fd, "wb") f.write(data) f.close() return name if not fco.cmp(fcd): # files identical? return None ui = repo.ui fd = fcd.path() binary = fcd.isbinary() or fco.isbinary() or fca.isbinary() symlink = "l" in fcd.flags() + fco.flags() tool, toolpath = _picktool(repo, ui, fd, binary, symlink) ui.debug("picked tool '%s' for %s (binary %s symlink %s)\n" % (tool, fd, binary, symlink)) if not tool or tool == "internal:prompt": tool = "internal:local" if ui.promptchoice( _(" no tool found to merge %s\n" "keep (l)ocal or take (o)ther?") % fd, (_("&Local"), _("&Other")), 0 ): tool = "internal:other" if tool == "internal:local": return 0 if tool == "internal:other": repo.wwrite(fd, fco.data(), fco.flags()) return 0 if tool == "internal:fail": return 1 # do the actual merge a = repo.wjoin(fd) b = temp("base", fca) c = temp("other", fco) out = "" back = a + ".orig" util.copyfile(a, back) if orig != fco.path(): ui.status(_("merging %s and %s to %s\n") % (orig, fco.path(), fd)) else: ui.status(_("merging %s\n") % fd) ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) # do we attempt to simplemerge first? try: premerge = _toolbool(ui, tool, "premerge", not (binary or symlink)) except error.ConfigError: premerge = _toolstr(ui, tool, "premerge").lower() valid = "keep".split() if premerge not in valid: _valid = ", ".join(["'" + v + "'" for v in valid]) raise error.ConfigError( _("%s.premerge not valid " "('%s' is neither boolean nor %s)") % (tool, premerge, _valid) ) if premerge: r = simplemerge.simplemerge(ui, a, b, c, quiet=True) if not r: ui.debug(" premerge successful\n") os.unlink(back) os.unlink(b) os.unlink(c) return 0 if premerge != "keep": util.copyfile(back, a) # restore from backup and try again env = dict( HG_FILE=fd, HG_MY_NODE=short(mynode), HG_OTHER_NODE=str(fco.changectx()), HG_BASE_NODE=str(fca.changectx()), HG_MY_ISLINK="l" in fcd.flags(), HG_OTHER_ISLINK="l" in fco.flags(), HG_BASE_ISLINK="l" in fca.flags(), ) if tool == "internal:merge": r = simplemerge.simplemerge(ui, a, b, c, label=["local", "other"]) elif tool == "internal:dump": a = repo.wjoin(fd) util.copyfile(a, a + ".local") repo.wwrite(fd + ".other", fco.data(), fco.flags()) repo.wwrite(fd + ".base", fca.data(), fca.flags()) os.unlink(b) os.unlink(c) return 1 # unresolved else: args = _toolstr(ui, tool, "args", "$local $base $other") if "$output" in args: out, a = a, back # read input from backup, write to original replace = dict(local=a, base=b, other=c, output=out) args = util.interpolate(r"\$", replace, args, lambda s: '"%s"' % util.localpath(s)) r = util.system(toolpath + " " + args, cwd=repo.root, environ=env, out=ui.fout) if not r and (_toolbool(ui, tool, "checkconflicts") or "conflicts" in _toollist(ui, tool, "check")): if re.search("^(<<<<<<< .*|=======|>>>>>>> .*)$", fcd.data(), re.MULTILINE): r = 1 checked = False if "prompt" in _toollist(ui, tool, "check"): checked = True if ui.promptchoice(_("was merge of '%s' successful (yn)?") % fd, (_("&Yes"), _("&No")), 1): r = 1 if not r and not checked and (_toolbool(ui, tool, "checkchanged") or "changed" in _toollist(ui, tool, "check")): if filecmp.cmp(repo.wjoin(fd), back): if ui.promptchoice( _(" output file %s appears unchanged\n" "was merge successful (yn)?") % fd, (_("&Yes"), _("&No")), 1 ): r = 1 if _toolbool(ui, tool, "fixeol"): _matcheol(repo.wjoin(fd), back) if r: if tool == "internal:merge": ui.warn(_("merging %s incomplete! " "(edit conflicts, then use 'hg resolve --mark')\n") % fd) else: ui.warn(_("merging %s failed!\n") % fd) else: os.unlink(back) os.unlink(b) os.unlink(c) return r