bzr subdirectory export fails on launchpad

Bug #403857 reported by Duncan McGreggor
This bug report is a duplicate of:  Bug #269746: "bzr cat lp:foo/bar" fails. Edit Remove
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned
Launchpad itself
Triaged
Low
Unassigned

Bug Description

bzr export is failing for the following subdir use cases:
 * bzr export localname bzr+ssh://bazaar.launchpad.net/~oubiwann/project/branch/subdir
 * bzr export localname lp:~oubiwann/project/branch/subdir

In contrast, the following works perfectly:
 * bzr export localname path/to/project-branch/subdir

The error message returned from the failing cases is the following:

bzr: ERROR: Permission denied: "Cannot create 'localname'. Only Bazaar branches are allowed."

Changed in bzr:
assignee: nobody → Robert Collins (lifeless)
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 403857] [NEW] bzr subdirectory export fails on launchpad

 assignee
 affects launchpad-code

-Rob

Revision history for this message
Robert Collins (lifeless) wrote :

 assignee nobody
 affects launchpad-code

-Rob

Changed in bzr:
assignee: Robert Collins (lifeless) → nobody
Revision history for this message
Aaron Bentley (abentley) wrote :

This behaviour is deliberate. Launchpad is meant to host Bazaar branches, not arbitrary files.

Changed in launchpad-code:
status: New → Invalid
Revision history for this message
James Westby (james-w) wrote :

Hi,

I believe the original bug report was slightly wrong, re-opening as I think it is
still an issue.

It should have been

   bzr export localname bzr+ssh://bazaar.launchpad.net/~oubiwann/project/branch/subdir
   bzr: ERROR: Permission denied: "Cannot create 'subdir'. Only Bazaar branches are allowed."

Consider

   bzr ls lp:~bzr/bzr/trunk/bzrlib/
   bzr: ERROR: Permission denied: "Cannot create 'bzrlib'. Only Bazaar branches are allowed."

Traceback (most recent call last):
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 835, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 1030, in run_bzr
    ret = run(*run_argv)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/commands.py", line 647, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/builtins.py", line 2735, in run
    b, subdir = Branch.open_containing(branch_or_subdir)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/branch.py", line 181, in open_containing
    possible_transports)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/bzrdir.py", line 891, in open_containing
    return BzrDir.open_containing_from_transport(transport)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/bzrdir.py", line 912, in open_containing_from_transport
    result = BzrDir.open_from_transport(a_transport)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/bzrdir.py", line 871, in open_from_transport
    return format.open(transport, _found=True)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/bzrdir.py", line 2052, in open
    return self._open(transport)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/bzrdir.py", line 3279, in _open
    return remote.RemoteBzrDir(transport, self)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/remote.py", line 110, in __init__
    response = self._call('BzrDir.open', path)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/remote.py", line 56, in _call
    self._translate_error(err, **err_context)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/remote.py", line 128, in _translate_error
    _translate_error(err, bzrdir=self, **context)
  File "/home/jw2328/devel/bzr/bzr.dev/bzrlib/remote.py", line 2668, in _translate_error
    raise errors.PermissionDenied(path, extra=extra)

so calling BzrDir.open on a path that is "under" a branch is rejected by LP.
Presumably if it just says "not found" to the open request then bzr would continue
and open the containing branch.

I'm not sure how this would affect the ability to reject pushes to arbitrary locations
though.

Thanks,

James

Changed in launchpad-code:
status: Invalid → New
Revision history for this message
Aaron Bentley (abentley) wrote : Re: [Bug 403857] Re: bzr subdirectory export fails on launchpad

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> Hi,
>
> I believe the original bug report was slightly wrong, re-opening as I think it is
> still an issue.
>
> It should have been
>
> bzr export localname bzr+ssh://bazaar.launchpad.net/~oubiwann/project/branch/subdir
> bzr: ERROR: Permission denied: "Cannot create 'subdir'. Only Bazaar branches are allowed."

Export to launchpad is not supported. If you want to file a bug about
ls, that's cool.

> Consider
>
> bzr ls lp:~bzr/bzr/trunk/bzrlib/
> bzr: ERROR: Permission denied: "Cannot create 'bzrlib'. Only Bazaar branches are allowed."
> so calling BzrDir.open on a path that is "under" a branch is rejected by LP.
> Presumably if it just says "not found" to the open request then bzr would continue
> and open the containing branch.

But also consider:

$ bzr init foo
Created a standalone tree (format: pack-0.92)

$ mkdir foo/bar
$ touch foo/bar/baz
$ bzr add foo
adding bar
adding bar/baz
$ bzr commit -m 'added bar' foo
Committing to: /home/abentley/foo/

added bar
added bar/baz
abentley@lumpy:~$ bzr push -d foo sftp://localhost/home/abentley/qux
Created new branch.

abentley@lumpy:~$ bzr ls qux/bar
qux/bar/baz
abentley@lumpy:~$ mkdir qux/bar
abentley@lumpy:~$ chmod a-rwx qux/bar
abentley@lumpy:~$ bzr ls qux/bar
bzr: ERROR: Permission denied:
"/home/abentley/qux/bar/.bzr/branch-format": [Errno 13] Permission
denied: u'/home/abentley/qux/bar/.bzr/branch-format'

So I think that bzr should not be stopping if it encounters Permission
denied. Ultimately, it would make sense to emit NoSuchFile for
operations that refer to a non-existant path, and only emit Permission
denied for attempts to create forbidden paths.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkppxPkACgkQ0F+nu1YWqI3bmACfYily+qlNu7MBpWeA0DTe/+Za
DYEAoIiwMDuu1jV9cgshEurvuVVg+dEn
=eYCS
-----END PGP SIGNATURE-----

Revision history for this message
James Westby (james-w) wrote :

Aaron Bentley wrote:
> James Westby wrote:
>> Hi,
>
>> I believe the original bug report was slightly wrong, re-opening as I think it is
>> still an issue.
>
>> It should have been
>
>> bzr export localname bzr+ssh://bazaar.launchpad.net/~oubiwann/project/branch/subdir
>> bzr: ERROR: Permission denied: "Cannot create 'subdir'. Only Bazaar branches are allowed."
>
> Export to launchpad is not supported. If you want to file a bug about
> ls, that's cool.

This is not export to launchpad. This is export *from* LP, only
exporting part of the branch.

bzr help export:

Usage: bzr export DEST [BRANCH_OR_SUBDIR]

It is the same root cause. Branch.open_containing on LP throws a
permission error if it points "below" a branch, and bzr stops searching
up when it encounters this.

Thanks,

James

Revision history for this message
Aaron Bentley (abentley) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> Aaron Bentley wrote:
>> James Westby wrote:
>>> Hi,
>>> I believe the original bug report was slightly wrong, re-opening as I think it is
>>> still an issue.
>>> It should have been
>>> bzr export localname bzr+ssh://bazaar.launchpad.net/~oubiwann/project/branch/subdir
>>> bzr: ERROR: Permission denied: "Cannot create 'subdir'. Only Bazaar branches are allowed."
>> Export to launchpad is not supported. If you want to file a bug about
>> ls, that's cool.
>
> This is not export to launchpad. This is export *from* LP, only
> exporting part of the branch.

Oh, thanks for pointing that out.

Still, I think my other arguments re:ls still apply here.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpp3o8ACgkQ0F+nu1YWqI2JjACcDOSuw/D368P1Hmir688BM2pU
STIAnRI1K/6nAY9+5hfqFhcmdo//942f
=z5Fz
-----END PGP SIGNATURE-----

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

The reason we give PermissionDenied in situations where NoSuchFile might seem more reasonable have, IIRC, to do with the client suggesting --create-prefix in some situations where --create-prefix will not in fact work. We should revisit this, and consider fixing the client, if that's possible.

There's also the issue that the message we give is the same for attempts to create and attempts to read non .bzr filenames at the top level of a branch, and that's a bit silly. Not sure if this is directly related though.

Tim Penhey (thumper)
Changed in launchpad-code:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Martin Pool (mbp) wrote :

bzr should probably keep searching upwards if it gets "permission denied" while trying to open a particular path.

Changed in bzr:
importance: Undecided → Low
status: New → Confirmed
tags: added: easy export
Changed in launchpad:
importance: Medium → Low
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.