[PATCH 3 of 3 STABLE?] resolve: don't abort when file is missing

Martin von Zweigbergk martinvonz at google.com
Wed Nov 11 12:22:31 CST 2015


On Tue, Nov 10, 2015 at 5:21 PM Siddharth Agarwal <sid0 at fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0 at fb.com>
> # Date 1447204619 28800
> #      Tue Nov 10 17:16:59 2015 -0800
> # Node ID 28e772623b133246812619909196efe50857309d
> # Parent  0829cdf6d0d3da14077f4de0d73c8bddf6190f06
> resolve: don't abort when file is missing
>
> A file being missing is a completely valid situation in which the user may
> want
> to re-resolve merge conflicts. Mercurial already maintains backups of local
> data, so this turns out to be easy to handle.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -5655,7 +5655,11 @@ def resolve(ui, repo, *pats, **opts):
>              else:
>                  # backup pre-resolve (merge uses .orig for its own
> purposes)
>                  a = repo.wjoin(f)
> -                util.copyfile(a, a + ".resolve")
> +                try:
> +                    util.copyfile(a, a + ".resolve")
> +                except (IOError, OSError) as inst:
> +                    if inst.errno != errno.ENOENT:
> +                        raise
>
>                  try:
>                      # preresolve file
> @@ -5673,7 +5677,11 @@ def resolve(ui, repo, *pats, **opts):
>                  # replace filemerge's .orig file with our resolve file
>                  # for files in tocomplete, ms.resolve will not overwrite
>                  # .orig -- only preresolve does
> -                util.rename(a + ".resolve", a + ".orig")
> +                try:
> +                    util.rename(a + ".resolve", a + ".orig")
> +                except OSError as inst:
> +                    if inst.errno != errno.ENOENT:
> +                        raise
>

Is this hunk needed for the fix? IIUC, it's about renaming from the backed
up .resolve file, which seems like a much less likely case. Separate patch
and description (and maybe test)?


>
>          for f in tocomplete:
>              try:
> diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
> --- a/tests/test-merge-tools.t
> +++ b/tests/test-merge-tools.t
> @@ -579,6 +579,33 @@ prompt with EOF
>    ? f.orig
>    # hg resolve --list
>    U f
> +  $ rm f
> +  $ hg resolve --all --config ui.merge=internal:prompt --config
> ui.interactive=true
> +   no tool found to merge f
> +  keep (l)ocal or take (o)ther?
> +  [1]
> +  $ aftermerge
> +  # cat f
> +  revision 1
> +  space
> +  # hg stat
> +  M f
> +  # hg resolve --list
> +  U f
> +  $ hg resolve --all --config ui.merge=internal:prompt
> +   no tool found to merge f
> +  keep (l)ocal or take (o)ther? l
> +  (no more unresolved files)
> +  $ aftermerge
> +  # cat f
> +  revision 1
> +  space
> +  # hg stat
> +  M f
> +  ? f.orig
> +  # hg resolve --list
> +  R f
> +
>  ui.merge specifies internal:dump:
>
>    $ beforemerge
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151111/779a2d3b/attachment.html>


More information about the Mercurial-devel mailing list