[Fwd: bzrtools: "import" fails on simple archive]

Bug #82644 reported by Robert Collins
4
Affects Status Importance Assigned to Milestone
bzrtools (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

 affects bzrtools

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 <email address hidden>
/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

--
GPG key available at: <http://www.robertcollins.net/keys.txt>.

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 <email address hidden>
/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

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I'm closing this report because this has been fixed a while ago.

March 9 2007
* Handle broken python tar implementations in upstream_import
* RELEASE: bzrtools 0.15.2

Thanks for your report.

Changed in bzrtools:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.