opener: force copy on 'a'ppend if nlinks() returns 0 (issue1922) stable
authorAdrian Buehlmann <adrian@cadifra.com>
Wed, 26 Jan 2011 19:14:30 +0100
branchstable
changeset 13305 035684c6b69a
parent 13287 d0e0d3d43e14
child 13306 146bad852ede
opener: force copy on 'a'ppend if nlinks() returns 0 (issue1922) If pywin32 is not installed, 'os.lstat(pathname).st_nlink' is used for nlinks(), which is always zero for all files on Windows. To make sure we break up hardlinks if pywin32 is missing, we force nlink = 2 if nlinks() returns < 1. (this completely fixes issue1922)
mercurial/util.py
--- a/mercurial/util.py	Sat Jan 22 16:15:40 2011 +0100
+++ b/mercurial/util.py	Wed Jan 26 19:14:30 2011 +0100
@@ -913,6 +913,8 @@
                     # shares if the file is open.
                     fd = open(f)
                     nlink = nlinks(f)
+                    if nlink < 1:
+                        nlink = 2 # force mktempcopy (issue1922)
                     fd.close()
             except (OSError, IOError):
                 nlink = 0