Mercurial > hg
comparison mercurial/vfs.py @ 33281:6af0f023d014
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.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 04 Jul 2017 23:13:47 +0900 |
parents | 646352291f5b |
children | d1db7af81548 |
comparison
equal
deleted
inserted
replaced
33280:646352291f5b | 33281:6af0f023d014 |
---|---|
193 """ | 193 """ |
194 srcpath = self.join(src) | 194 srcpath = self.join(src) |
195 dstpath = self.join(dst) | 195 dstpath = self.join(dst) |
196 oldstat = checkambig and util.filestat.frompath(dstpath) | 196 oldstat = checkambig and util.filestat.frompath(dstpath) |
197 if oldstat and oldstat.stat: | 197 if oldstat and oldstat.stat: |
198 def dorename(spath, dpath): | 198 ret = util.rename(srcpath, dstpath) |
199 ret = util.rename(spath, dpath) | 199 _avoidambig(dstpath, oldstat) |
200 newstat = util.filestat.frompath(dpath) | |
201 if newstat.isambig(oldstat): | |
202 # stat of renamed file is ambiguous to original one | |
203 return ret, newstat.avoidambig(dpath, oldstat) | |
204 return ret, True | |
205 ret, avoided = dorename(srcpath, dstpath) | |
206 if not avoided: | |
207 # simply copy to change owner of srcpath (see issue5418) | |
208 util.copyfile(dstpath, srcpath) | |
209 ret, avoided = dorename(srcpath, dstpath) | |
210 return ret | 200 return ret |
211 return util.rename(srcpath, dstpath) | 201 return util.rename(srcpath, dstpath) |
212 | 202 |
213 def readlink(self, path): | 203 def readlink(self, path): |
214 return os.readlink(self.join(path)) | 204 return os.readlink(self.join(path)) |