[PATCH 2 of 2] filemerge: detect merge tool aborts

Matt Mackall mpm at selenic.com
Mon Feb 4 21:12:05 CST 2008


On Mon, 2008-02-04 at 20:27 -0600, Steve Borho wrote:
> # HG changeset patch
> # User Steve Borho <steve at borho.org>
> # Date 1202177707 21600
> # Node ID 532093498c8f7953d01a1bc3d874deee24d8be24
> # Parent  bb87b78bf30a6c3642b04e3a42aea8775fb78f38
> filemerge: detect merge tool aborts
> 
> Some merge tools return 0 even if they do not write an output file.
> This patch tries to at least recognize that the merge failed.
> 
> diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
> --- a/mercurial/filemerge.py
> +++ b/mercurial/filemerge.py
> @@ -7,7 +7,7 @@
>  
>  from node import *
>  from i18n import _
> -import util, os, tempfile, context, simplemerge, re
> +import util, os, tempfile, context, simplemerge, re, filecmp
>  
>  def _toolstr(ui, tool, part, default=""):
>      return ui.config("merge-tools", tool + "." + part, default)
> @@ -199,6 +199,11 @@
>      if r:
>          repo.ui.warn(_("merging %s failed!\n") % fd)
>      else:
> +        if filecmp.cmp(repo.wjoin(fd), back):

elif saves a level of indentation. I'm tempted to put this under a
<tool>.checkchanged option (default false) though.

> +            if ui.prompt(_(" output file %s appears unchanged\n"
> +                "was merge successful (yn)?") % fd,
> +                _("[yn]"), _("n")) != _("y"):
> +                r = 1
>          os.unlink(back)
>  
>      os.unlink(b)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list