Bug 3519 - invalid path in function getfilectx(repo, memctx, f) from hg lfconvert
Summary: invalid path in function getfilectx(repo, memctx, f) from hg lfconvert
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: largefiles (show other bugs)
Version: earlier
Hardware: PC All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
: 3629 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-29 07:35 UTC by mojmir svoboda
Modified: 2017-11-01 18:05 UTC (History)
6 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 mojmir svoboda 2012-06-29 07:35 UTC
There is a problem when I try to use lfconvert to convert from largefiles to normal, see:

# hg lfconvert --to-normal code code2

initializing destination code2
transaction abort!
rollback completed
...8<...

File "/hgext/largefiles/lfcommands.py", line 116, in lfconvert
        _addchangeset(ui, rsrc, rdst, ctx, revmap)
File "/hgext/largefiles/lfcommands.py", line 170, in _addchangeset
        _commitcontext(rdst, parents, ctx, dstfiles, getfilectx, revmap)
File "/hgext/largefiles/lfcommands.py", line 260, in _commitcontext
        ret = rdst.commitctx(mctx)
File "/hgext/largefiles/reposetup.py", line 284, in commitctx
        node = super(lfilesrepo, self).commitctx(*args, **kwargs)
File "/mercurial/localrepo.py", line 1248, in commitctx
        fctx = ctx[f]
File "/mercurial/context.py", line 1185, in __getitem__
        return self.filectx(key)
File "/mercurial/context.py", line 1227, in filectx
        return self._filectxfn(self._repo, self, path)

File "lfcommands.py", line 152, in getfilectx
   fd = open(path, 'rb')
   TypeError: coercing to Unicode: need string or buffer, NoneType found

The path at that line contains "None" which is not a valid path in
this case.
Whole process terminates.

Current hg version: branch stable
Mercurial Distributed SCM (version 2.2.2+27-2440822446ce+20120629)

I'm available for more info, minor debugging (dont speak python too much, sorry) and testing if you'd like.
Comment 1 Matt Harbison 2012-10-14 00:41 UTC
The problem is likely that a largefile isn't available in the system cache.  There's a TODO comment near the point of failure asking what to do if the file isn't cached.

Adding this snippet to the end of test-lfconvert.t (and setting the usercache property in the hgrc at the top of the test) demonstrates the problem, but it isn't a problem if the rm line is commented out:

  $ hg clone -U largefiles-repo issue3519
  $ rm "${USERCACHE}"/*
  $ hg lfconvert --to-normal issue3519 normalized3519

It seems like aborting with a message that names the missing file and rev would be the minimally nice thing, but ideally it would go download the file.

A workaround is to use 'clone --all-largefiles' to make sure everything is cached, and then convert *that* repo.
Comment 2 Matt Harbison 2012-10-14 00:42 UTC
*** Bug 3629 has been marked as a duplicate of this bug. ***
Comment 3 Matt Harbison 2012-10-14 23:02 UTC
Proposed fix here:

    http://www.selenic.com/pipermail/mercurial-devel/2012-October/045237.html
Comment 4 HG Bot 2012-10-19 01:12 UTC
Fixed by http://selenic.com/repo/hg/rev/0fc1ce271ee6
Matt Harbison <matt_harbison@yahoo.com>
largefiles: fix a traceback in lfconvert if a largefile is missing (issue3519)

The largefile may be missing for various reasons, including that a remote
repository was cloned without the --all-largefiles option.  Therefore, it seems
reasonable to attempt to download the missing files and failing that, abort and
indicate the affected file and revision so the user can manually fix the
problem.

(please test the fix)