comparison mercurial/hg.py @ 20825:dda11e799529 stable

hg: use "os.path.join()" to join path components which may be empty (issue4203) Changset 2d0ab571b822 rewriting "hg.copystore()" with vfs uses 'dstbase + "/lock"' instead of "os.path.join()", because target files given from "store.copyfiles()" already uses "/" as path separator But in the repository using revlog format 0, "dstbase" becomes empty ("data" directory is located under ".hg" directly), and 'dstbase + "/lock"' is treated as "/lock": in almost all cases, write access to "/lock" causes "permission denied". This patch uses "os.path.join()" to join path components which may be empty in "hg.copystore()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 25 Mar 2014 19:34:17 +0900
parents 7d269e7620c4
children 9a09a625bc93 bc56ec9e64df
comparison
equal deleted inserted replaced
20824:c57c9cece645 20825:dda11e799529
211 dstbase = os.path.dirname(f) 211 dstbase = os.path.dirname(f)
212 if dstbase and not dstvfs.exists(dstbase): 212 if dstbase and not dstvfs.exists(dstbase):
213 dstvfs.mkdir(dstbase) 213 dstvfs.mkdir(dstbase)
214 if srcvfs.exists(f): 214 if srcvfs.exists(f):
215 if f.endswith('data'): 215 if f.endswith('data'):
216 # 'dstbase' may be empty (e.g. revlog format 0)
217 lockfile = os.path.join(dstbase, "lock")
216 # lock to avoid premature writing to the target 218 # lock to avoid premature writing to the target
217 destlock = lock.lock(dstvfs, dstbase + "/lock") 219 destlock = lock.lock(dstvfs, lockfile)
218 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f), 220 hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
219 hardlink) 221 hardlink)
220 num += n 222 num += n
221 if hardlink: 223 if hardlink:
222 ui.debug("linked %d files\n" % num) 224 ui.debug("linked %d files\n" % num)