Patchwork [5,of,6,V2] vfs: replace avoiding ambiguity in abstractvfs.rename with _avoidambig

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 4, 2017, 2:29 p.m.
Message ID <afad00f764b6ea14a6c5.1499178543@speaknoevil>
Download mbox | patch
Permalink /patch/21970/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - July 4, 2017, 2:29 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1499177627 -32400
#      Tue Jul 04 23:13:47 2017 +0900
# Node ID afad00f764b6ea14a6c5b6f16d55e403ed44026a
# Parent  5079632240f2bcec1539cb5b3572ac588f19c9c7
vfs: replace avoiding ambiguity in abstractvfs.rename with _avoidambig

This centralizes common logic to forcibly avoid file stat ambiguity
into _avoidambig(), which was introduced by previous patch.

Patch

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -195,18 +195,8 @@  class abstractvfs(object):
         dstpath = self.join(dst)
         oldstat = checkambig and util.filestat.frompath(dstpath)
         if oldstat and oldstat.stat:
-            def dorename(spath, dpath):
-                ret = util.rename(spath, dpath)
-                newstat = util.filestat.frompath(dpath)
-                if newstat.isambig(oldstat):
-                    # stat of renamed file is ambiguous to original one
-                    return ret, newstat.avoidambig(dpath, oldstat)
-                return ret, True
-            ret, avoided = dorename(srcpath, dstpath)
-            if not avoided:
-                # simply copy to change owner of srcpath (see issue5418)
-                util.copyfile(dstpath, srcpath)
-                ret, avoided = dorename(srcpath, dstpath)
+            ret = util.rename(srcpath, dstpath)
+            _avoidambig(dstpath, oldstat)
             return ret
         return util.rename(srcpath, dstpath)