Mercurial > hg-stable
comparison mercurial/vfs.py @ 32767:1a79de471d56
vfs: factor out "rename and avoid ambiguity" to reuse
This makes subsequent patch simple.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 09 Jun 2017 12:58:18 +0900 |
parents | d74b0cff94a9 |
children | ed66ec39933f |
comparison
equal
deleted
inserted
replaced
32766:77f354ae1123 | 32767:1a79de471d56 |
---|---|
175 (e.g. repo.lock or repo.wlock). | 175 (e.g. repo.lock or repo.wlock). |
176 """ | 176 """ |
177 dstpath = self.join(dst) | 177 dstpath = self.join(dst) |
178 oldstat = checkambig and util.filestat(dstpath) | 178 oldstat = checkambig and util.filestat(dstpath) |
179 if oldstat and oldstat.stat: | 179 if oldstat and oldstat.stat: |
180 ret = util.rename(self.join(src), dstpath) | 180 def dorename(spath, dpath): |
181 newstat = util.filestat(dstpath) | 181 ret = util.rename(spath, dpath) |
182 if newstat.isambig(oldstat): | 182 newstat = util.filestat(dpath) |
183 # stat of renamed file is ambiguous to original one | 183 if newstat.isambig(oldstat): |
184 newstat.avoidambig(dstpath, oldstat) | 184 # stat of renamed file is ambiguous to original one |
185 return ret, newstat.avoidambig(dpath, oldstat) | |
186 return ret, True | |
187 ret, avoided = dorename(self.join(src), dstpath) | |
185 return ret | 188 return ret |
186 return util.rename(self.join(src), dstpath) | 189 return util.rename(self.join(src), dstpath) |
187 | 190 |
188 def readlink(self, path): | 191 def readlink(self, path): |
189 return os.readlink(self.join(path)) | 192 return os.readlink(self.join(path)) |