Patchwork [2,of,2] filemerge: move :merge-local/other symlink check to precheck

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 9, 2015, 7:48 a.m.
Message ID <4e65cd4b1a1d2cccb15e.1447055325@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11333/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 9, 2015, 7:48 a.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447054964 28800
#      Sun Nov 08 23:42:44 2015 -0800
# Node ID 4e65cd4b1a1d2cccb15e3e099432ddb4a4bd9786
# Parent  8c9da62bfea7439e5d811cd281f8d144f76f87e7
filemerge: move :merge-local/other symlink check to precheck

In upcoming patches we're going to add more checks to the function currently
named _symlinkcheck. This consolidates all those checks.
Martin von Zweigbergk - Nov. 9, 2015, 8:27 p.m.
Looks good, thanks. Pushing to the clowncopter.

On Sun, Nov 8, 2015 at 11:50 PM Siddharth Agarwal <sid0@fb.com> wrote:

> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1447054964 28800
> #      Sun Nov 08 23:42:44 2015 -0800
> # Node ID 4e65cd4b1a1d2cccb15e3e099432ddb4a4bd9786
> # Parent  8c9da62bfea7439e5d811cd281f8d144f76f87e7
> filemerge: move :merge-local/other symlink check to precheck
>
> In upcoming patches we're going to add more checks to the function
> currently
> named _symlinkcheck. This consolidates all those checks.
>
> diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
> --- a/mercurial/filemerge.py
> +++ b/mercurial/filemerge.py
> @@ -308,16 +308,12 @@ def _imergeauto(repo, mynode, orig, fcd,
>      """
>      assert localorother is not None
>      tool, toolpath, binary, symlink = toolconf
> -    if symlink:
> -        repo.ui.warn(_('warning: :merge-%s cannot merge symlinks '
> -                       'for %s\n') % (localorother, fcd.path()))
> -        return False, 1
>      a, b, c, back = files
>      r = simplemerge.simplemerge(repo.ui, a, b, c, label=labels,
>                                  localorother=localorother)
>      return True, r
>
> -@internaltool('merge-local', mergeonly)
> +@internaltool('merge-local', mergeonly, precheck=_symlinkcheck)
>  def _imergelocal(*args, **kwargs):
>      """
>      Like :merge, but resolve all conflicts non-interactively in favor
> @@ -325,7 +321,7 @@ def _imergelocal(*args, **kwargs):
>      success, status = _imergeauto(localorother='local', *args, **kwargs)
>      return success, status
>
> -@internaltool('merge-other', mergeonly)
> +@internaltool('merge-other', mergeonly, precheck=_symlinkcheck)
>  def _imergeother(*args, **kwargs):
>      """
>      Like :merge, but resolve all conflicts non-interactively in favor
> diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
> --- a/tests/test-merge-types.t
> +++ b/tests/test-merge-types.t
> @@ -118,7 +118,7 @@ Symlink is other parent, executable is l
>    picked tool ':merge-local' for a (binary False symlink True)
>    merging a
>    my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da
> -  warning: :merge-local cannot merge symlinks for a
> +  warning: internal :merge-local cannot merge symlinks for a
>    0 files updated, 0 files merged, 0 files removed, 1 files unresolved
>    use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to
> abandon
>    [1]
> @@ -140,7 +140,7 @@ Symlink is other parent, executable is l
>    picked tool ':merge-other' for a (binary False symlink True)
>    merging a
>    my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da
> -  warning: :merge-other cannot merge symlinks for a
> +  warning: internal :merge-other cannot merge symlinks for a
>    0 files updated, 0 files merged, 0 files removed, 1 files unresolved
>    use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to
> abandon
>    [1]
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -308,16 +308,12 @@  def _imergeauto(repo, mynode, orig, fcd,
     """
     assert localorother is not None
     tool, toolpath, binary, symlink = toolconf
-    if symlink:
-        repo.ui.warn(_('warning: :merge-%s cannot merge symlinks '
-                       'for %s\n') % (localorother, fcd.path()))
-        return False, 1
     a, b, c, back = files
     r = simplemerge.simplemerge(repo.ui, a, b, c, label=labels,
                                 localorother=localorother)
     return True, r
 
-@internaltool('merge-local', mergeonly)
+@internaltool('merge-local', mergeonly, precheck=_symlinkcheck)
 def _imergelocal(*args, **kwargs):
     """
     Like :merge, but resolve all conflicts non-interactively in favor
@@ -325,7 +321,7 @@  def _imergelocal(*args, **kwargs):
     success, status = _imergeauto(localorother='local', *args, **kwargs)
     return success, status
 
-@internaltool('merge-other', mergeonly)
+@internaltool('merge-other', mergeonly, precheck=_symlinkcheck)
 def _imergeother(*args, **kwargs):
     """
     Like :merge, but resolve all conflicts non-interactively in favor
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -118,7 +118,7 @@  Symlink is other parent, executable is l
   picked tool ':merge-local' for a (binary False symlink True)
   merging a
   my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da
-  warning: :merge-local cannot merge symlinks for a
+  warning: internal :merge-local cannot merge symlinks for a
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
@@ -140,7 +140,7 @@  Symlink is other parent, executable is l
   picked tool ':merge-other' for a (binary False symlink True)
   merging a
   my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da
-  warning: :merge-other cannot merge symlinks for a
+  warning: internal :merge-other cannot merge symlinks for a
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]