hg: use "os.path.join()" to join path components which may be empty (issue4203)

Changset 39a4d61c40d6 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()".
This commit is contained in:
FUJIWARA Katsunori 2014-03-25 19:34:17 +09:00
parent 60d20455df
commit c52b73121a
2 changed files with 17 additions and 1 deletions

View File

@ -213,8 +213,10 @@ def copystore(ui, srcrepo, destpath):
dstvfs.mkdir(dstbase)
if srcvfs.exists(f):
if f.endswith('data'):
# 'dstbase' may be empty (e.g. revlog format 0)
lockfile = os.path.join(dstbase, "lock")
# lock to avoid premature writing to the target
destlock = lock.lock(dstvfs, dstbase + "/lock")
destlock = lock.lock(dstvfs, lockfile)
hardlink, n = util.copyfiles(srcvfs.join(f), dstvfs.join(f),
hardlink)
num += n

View File

@ -621,3 +621,17 @@ re-enable perm to allow deletion
#endif
$ cd ..
Test clone from the repository in (emulated) revlog format 0 (issue4203):
$ mkdir issue4203
$ mkdir -p src/.hg
$ echo foo > src/foo
$ hg -R src add src/foo
$ hg -R src commit -m '#0'
$ hg -R src log -q
0:e1bab28bca43
$ hg clone -U -q src dst
$ hg -R dst log -q
0:e1bab28bca43
$ cd ..