[PATCH] merge: show helpful message on file with directory name conflicts (issue29)

Augie Fackler raf at durin42.com
Tue Dec 10 15:30:07 CST 2013


On Mon, Dec 09, 2013 at 06:22:57PM +0530, Prasoon Shukla wrote:
> # HG changeset patch
> # User Prasoon Shukla <prasoon92.iitr at gmail.com>
> # Date 1386593059 -19800
> #      Mon Dec 09 18:14:19 2013 +0530
> # Node ID f81553a5e76a62ba265cc4d92ada0f265c3b708d
> # Parent  1c92524c37cdd251c1a36b2da0fb4148b0e6ba09
> merge: show helpful message on file with directory name conflicts (issue29)
>
> Merging from a branch containing a file (directory) with same name as a
> directory (file) in the working directory causes an exception with an
> unhelpful message. This fix rasies an exception with a better error message.
> The fix incorporates detecting the errno of the exception raised, then
> comparing the errno with standard errnos defined in built-in errno module.
> Exception is raised for the proper errnos.
>
> diff -r 1c92524c37cd -r f81553a5e76a mercurial/scmutil.py
> --- a/mercurial/scmutil.py	Sun Dec 01 21:24:48 2013 -0600
> +++ b/mercurial/scmutil.py	Mon Dec 09 18:14:19 2013 +0530
> @@ -281,6 +281,15 @@
>                              nlink = 2 # force mktempcopy (issue1922)
>                          fd.close()
>                  except (OSError, IOError), e:
> +                    # issue29 fixed with next 2 if statements
> +                    # we display filename relative to the directory of repo
> +                    if e.errno == errno.EISDIR:
> +                        raise util.Abort(_("incoming file %s collides "
> +                        "with local directory %s/, please fix" %(path, path)))

Hm. How should the user fix this? Does this only happen in untracked
local directories, or does this happen if I make a file named "b/wat"
and you make a file named "b" and then we try to merge?

I feel like this could use a hint for /how/ the user should resolve
the problem.

> +                    if e.errno == errno.ENOTDIR:
> +                        raise util.Abort(_("a directory name in incoming "
> +                              "file %s collids with local file of the same "
> +                              "name, please fix" % path))
>                      if e.errno != errno.ENOENT:
>                          raise
>                      nlink = 0
> diff -r 1c92524c37cd -r f81553a5e76a tests/test-merge1.t
> --- a/tests/test-merge1.t	Sun Dec 01 21:24:48 2013 -0600
> +++ b/tests/test-merge1.t	Mon Dec 09 18:14:19 2013 +0530
> @@ -28,7 +28,7 @@
>
>    $ mkdir b
>    $ hg up
> -  abort: *: '$TESTTMP/t/b' (glob)
> +  abort: incoming file b collides with local directory b/, please fix
>    [255]
>    $ hg ci
>    abort: last update was interrupted
> diff -r 1c92524c37cd -r f81553a5e76a tests/test-merge4.t
> --- a/tests/test-merge4.t	Sun Dec 01 21:24:48 2013 -0600
> +++ b/tests/test-merge4.t	Mon Dec 09 18:14:19 2013 +0530
> @@ -7,9 +7,28 @@
>    $ hg commit -m "commit #1"
>    $ hg update 0
>    0 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ mkdir b
> +  $ echo file in dir > b/file.txt
> +  $ hg ci -A -m "commit #2"
> +  adding b/file.txt
> +  created new head
> +
> +Now, folder name 'b' matches the file b in commit#1. Merge should fail
> +with proper warning.
> +
> +  $ hg merge 1
> +  abort: incoming file b collides with local directory b/, please fix
> +  [255]
> +  $ hg update 1
> +  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
> +  $ hg merge 2
> +  abort: a directory name in incoming file b/file.txt collids with local file of the same name, please fix
> +  [255]
> +  $ hg update 0
> +  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
>    $ echo This is file c1 > c
>    $ hg add c
> -  $ hg commit -m "commit #2"
> +  $ hg commit -m "commit #3"
>    created new head
>    $ hg merge 1
>    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list