Bug 4203 - hg clone fails with revlog format 0 repos
Summary: hg clone fails with revlog format 0 repos
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 2.9
Hardware: PC Linux
: urgent bug
Assignee: Bugzilla
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2014-03-24 06:17 UTC by Thomas Arendsen Hein
Modified: 2014-03-26 03:37 UTC (History)
5 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Arendsen Hein 2014-03-24 06:17 UTC
A local "hg clone" of an old repository in revlog format 0 fails with:

Traceback (most recent call last):
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 134, in _runcatch
    return _dispatch(req)
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 806, in _dispatch
    cmdpats, cmdoptions)
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 586, in runcommand
    ret = _runcommand(ui, options, cmd, d)
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 897, in _runcommand
    return checkargs()
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 868, in checkargs
    return cmdfunc()
  File "/home/thomas/hg/repos/tah/mercurial/dispatch.py", line 803, in <lambda>
    d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/home/thomas/hg/repos/tah/mercurial/util.py", line 511, in check
    return func(*args, **kwargs)
  File "/home/thomas/hg/repos/tah/mercurial/commands.py", line 1310, in clone
    branch=opts.get('branch'))
  File "/home/thomas/hg/repos/tah/mercurial/hg.py", line 337, in clone
    destlock = copystore(ui, srcrepo, destpath)
  File "/home/thomas/hg/repos/tah/mercurial/hg.py", line 217, in copystore
    destlock = lock.lock(dstvfs, dstbase + "/lock")
  File "/home/thomas/hg/repos/tah/mercurial/lock.py", line 41, in __init__
    self.lock()
  File "/home/thomas/hg/repos/tah/mercurial/lock.py", line 59, in lock
    self.trylock()
  File "/home/thomas/hg/repos/tah/mercurial/lock.py", line 90, in trylock
    why.filename, self.desc)
LockUnavailable: [Errno 13] Permission denied: '/lock'
abort: could not lock /lock: Permission denied

(traceback shown due to --traceback)

hg clone --pull works.

Bisect shows, that this was introduced in Mercurial 2.9:

The first bad revision is:
changeset:   20089:2d0ab571b822
user:        FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date:        Tue Nov 12 16:23:52 2013 +0900
summary:     hg: rewrite "copystore()" with vfs


To reproduce:

mkdir repo
cd repo
mkdir .hg
echo foo > foo
hg add foo
hg ci -m foo
hg clone -U . ../repo2
Comment 1 Thomas Arendsen Hein 2014-03-24 06:36 UTC
Added FUJIWARA Katsunori <foozy@lares.dti.ne.jp> to Cc: list.
Comment 2 Matt Mackall 2014-03-24 11:10 UTC
Regression -> urgent!
Comment 3 HG Bot 2014-03-25 17:30 UTC
Fixed by http://selenic.com/repo/hg/rev/dda11e799529
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
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()".

(please test the fix)
Comment 4 Thomas Arendsen Hein 2014-03-26 03:37 UTC
Thank you, works for me in 2.9.1+24-dd2e25e49862