bzrtools: "import" fails on simple archive
Matthias Rahlf
rahlf at fs.tum.de
Mon Jan 29 12:33:38 GMT 2007
Hi,
recently John Meinel mentioned the "import" command. This was exactly
what I was looking for. But it doesn't work that easy, I'm afraid.
$mkdir upstream-1.0.1
$touch upstream-1.0.1/README
$tar czf upstream-1.0.1.tar.gz upstream-1.0.1
$mkdir my-branch
$cd my-branch
$bzr init
$bzr import ../upstream-1.0.1.tar.gz
bzr: ERROR: bzrlib.errors.PathNotChild: Path '/' is not a child of path
u'/home/user/my-branch'
Traceback (most recent call last):
File "/usr/local/lib/python2.5/site-packages/bzrlib/commands.py", line
650, in run_bzr_catch_errors
return run_bzr(argv)
File "/usr/local/lib/python2.5/site-packages/bzrlib/commands.py", line
612, in run_bzr
ret = run(*run_argv)
File "/usr/local/lib/python2.5/site-packages/bzrlib/commands.py", line
304, in run_argv_aliases
return self.run(**all_cmd_args)
File
"/usr/local/lib/python2.5/site-packages/bzrlib/plugins/bzrtools/__init__.py",
line 545, in run
do_import(source, tree)
File
"/usr/local/stow/bazaar-dev/lib/python2.5/site-packages/bzrlib/plugins/bzrtools/upstream_import.py",
line 272, in do_import
import_tar(tree, tar_input)
File
"/usr/local/stow/bazaar-dev/lib/python2.5/site-packages/bzrlib/plugins/bzrtools/upstream_import.py",
line 165, in import_tar
import_archive(tree, tar_file)
File
"/usr/local/stow/bazaar-dev/lib/python2.5/site-packages/bzrlib/plugins/bzrtools/upstream_import.py",
line 201, in import_archive
trans_id = tt.trans_id_tree_path(relative_path)
File
"/usr/local/stow/bazaar-dev/lib/python2.5/site-packages/bzrlib/transform.py",
line 240, in trans_id_tree_path
path = self.canonical_path(path)
File
"/usr/local/stow/bazaar-dev/lib/python2.5/site-packages/bzrlib/transform.py",
line 234, in canonical_path
relpath = self._tree.relpath(abs)
File "/usr/local/lib/python2.5/site-packages/bzrlib/workingtree.py",
line 449, in relpath
return osutils.relpath(self.basedir, path)
File "/usr/local/lib/python2.5/site-packages/bzrlib/osutils.py", line
822, in relpath
raise errors.PathNotChild(rp, base)
PathNotChild: Path '/' is not a child of path u'/home/user/my-branch'
bzr 0.15.0dev0 on python 2.5.0.final.0 (linux2)
arguments: ['/usr/local/bin/bzr', 'import', '../upstream-1.0.1.tar.gz']
** please send this report to bazaar at lists.ubuntu.com
/usr/local/lib/python2.5/site-packages/bzrlib/lockable_files.py:110:
UserWarning: file group
LockableFiles(<bzrlib.transport.local.LocalTransport
url=file:///home/user/my-branch/.bzr/checkout/>) was not explicitly unlocked
warn("file group %r was not explicitly unlocked" % self)
/usr/local/lib/python2.5/site-packages/bzrlib/lockable_files.py:110:
UserWarning: file group
LockableFiles(<bzrlib.transport.local.LocalTransport
url=file:///home/user/my-branch/.bzr/branch/>) was not explicitly unlocked
warn("file group %r was not explicitly unlocked" % self)
/usr/local/lib/python2.5/site-packages/bzrlib/lockable_files.py:110:
UserWarning: file group
LockableFiles(<bzrlib.transport.local.LocalTransport
url=file:///home/user/my-branch/.bzr/repository/>) was not explicitly
unlocked
warn("file group %r was not explicitly unlocked" % self)
I think this is because TarFile.getmembers() contains "upstream-1.0.1//"
(two slashes). A quick fix that works for me is:
--- upstream_import.py 2007-01-08 17:08:42 +0000
+++ upstream_import.py 2007-01-29 12:03:54 +0000
@@ -193,7 +193,7 @@
continue
relative_path = member.name
if prefix is not None:
- relative_path = relative_path[len(prefix)+1:]
+ relative_path = relative_path[len(prefix):].lstrip('/')
if relative_path == '':
continue
add_implied_parents(implied_parents, relative_path)
bye, matthias
More information about the bazaar
mailing list