1. Stefan Rusek
  2. hg-fixutf8
  3. Issues
Issue #29 new

Incompatible with Mercurial 2.0

Anonymous created an issue

I think there is an incompatibility between this plugin and Mercurial 2.0. Under Windows XP SP3 (Italian) hg (both command line and tortoise) silently fails to add files to a repository. Removing the plugin hg works correctly.

Comments (5)

  1. Shun-ichi Goto

    This is due to the change of mercurial.util.atomictempfile by this changeset:

    changeset:   15057:774da7121fc9
    user:        Greg Ward <greg@gerg.ca>
    date:        Thu Aug 25 20:21:04 2011 -0400
    summary:     atomictempfile: make close() consistent with other file-like objects.
    

    fixutf8 alternates this class on setup but it does not match new interface.

    Here is a tiny patch:

    diff -r 3ad952b61af1 fixutf8.py
    --- a/fixutf8.py	Fri Sep 16 16:57:21 2011 +0900
    +++ b/fixutf8.py	Tue Jan 10 17:25:55 2012 +0900
    @@ -223,6 +223,9 @@
                         posixfile_utf8.close(self)
                         util.rename(self.temp, util.localpath(self.__name))
     
    +            # for new hg (after 15057:774da7121fc9)
    +            close = rename
    +
                 def __del__(self):
                     if not self.closed:
                         try:
    
  2. Grigory Ptashko

    Hello.

    I confirm this behaviour. After installing the extension hg (both command line and tortoise) just don't add files with cyrillic filenames. They say 'added' but in fact they don't add. Can we expect that this issue be resolved?

    Thank you.

  3. Grigory Ptashko

    After applying the above patch it works with Mercurial 2.0. But (!). It doesn't work when I try to add folders with cyrillic letters in the repository. So with top level files with cyrillic filenames it is ok, but folder with cyrillic letters do not add.

    is there any chance we can have a fix of this?

    Thank you.

  4. YongKi Kim

    I found this clue at util.py of mercurial 2.6 source. It should work. Please gently modify 'class atomictempfile_utf8' part of fixutf8.py with this code:

            class atomictempfile_utf8(posixfile_utf8):
                """file-like object that atomically updates a file
    
                All writes will be redirected to a temporary copy of the original
                file.  When rename is called, the copy is renamed to the original
                name, making the changes visible.
                """
                def __init__(self, name, mode="w+b", createmode=None):
                    self.__name = name
                    self._tempname = util.mktempcopy(name, emptyok=('w' in mode),
                                           createmode=createmode)
                    posixfile_utf8.__init__(self, self._tempname, mode)
    
                    # delegated methods
    
                # https://bitbucket.org/stefanrusek/hg-fixutf8/issue/29/incompatible-with-mercurial-20
                def rename(self):
                    util.rename(self._tempname, util.localpath(self.__name))
    
                def close(self):
                    if not self.closed:
                        posixfile_utf8.close(self)
                        util.rename(self._tempname, util.localpath(self.__name))
    
                def discard(self):
                    if not self.closed:
                        try:
                            os.unlink(self._tempname)
                        except OSError:
                            pass
                        posixfile_utf8.close(self)
    
                def __del__(self):
                    if not self.closed:
                        try:
                            os.unlink(self._tempname)
                        except: pass
                        posixfile_utf8.close(self)
    
  5. Log in to comment