~abentley/bzrtools/bzrtools.dev

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
$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@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