hooks fired by smart server can't easily obtain absolute path to branch on the server.

Bug #270267 reported by Marius Kruger on 2008-09-14
Affects Status Importance Assigned to Milestone

Bug Description

I have a http smart server with a post_change_branch_tip hook which gets fired.
I'm trying to obtain a url to the branch which I can pass to a php script which
will then call `bzr log ...` with the url.

This is my hook:

def branch_post_change_branch_tip(result):
    trace.mutter("*** branch_post_change_branch_tip ***")
    from bzrlib import transport
    tr = transport.get_transport(result.branch.base)
    trace.mutter("tr: %s"% tr)
    eu = tr.external_url()
    trace.mutter("eu: %s"% eu)
    trace.mutter("la: %s"% tr.local_abspath('.'))

which gives the following output:
2.158 *** branch_post_change_branch_tip ***
2.160 tr: <bzrlib.transport.chroot.ChrootTransport url=chroot--1211093524:///bazaartest/trunk/>
2.160 eu: file:///var/lib/gforge/bzrroot/
2.166 Traceback (most recent call last):
  File "/opt/bzr/bzrlib/smart/protocol.py", line 885, in accept_bytes
    _StatefulDecoder.accept_bytes(self, bytes)
  File "/opt/bzr/bzrlib/smart/protocol.py", line 396, in accept_bytes
  File "/opt/bzr/bzrlib/smart/protocol.py", line 1019, in _state_accept_expecting_structure
    raise errors.SmartMessageHandlerError(sys.exc_info())
SmartMessageHandlerError: The message handler raised an exception: chroot--1211093524:///bazaartest/trunk is not a local path..

I had a discussion on IRC with lifeless:

[23:09] <lifeless> I think you should file a bug; it is reasonable to want to run an external script on a branch being pushed to by the smart server
[23:09] <AmanicA> where do you think the problem/solution would be?
[23:10] <lifeless> we need to look at the security implications
[23:10] <AmanicA> oh you mean that method should be implemented?!
[23:10] <lifeless> and then likely both fix local_abspath to support the chroot transport type
[23:11] <lifeless> and possibly provide a public method to get the backing location

Marius Kruger (amanica) on 2008-09-29
Changed in bzr:
status: New → Confirmed
Andrew Bennetts (spiv) on 2010-04-13
Changed in bzr:
importance: Undecided → High
Andrew Bennetts (spiv) wrote :

Making local_abspath work would be good. Also, we should make it so that branch.get_config() Just Works w.r.t. to absolute paths in locations.conf.

tags: added: hooks
Jelmer Vernooij (jelmer) on 2017-11-08
tags: added: check-for-breezy
Jelmer Vernooij (jelmer) on 2017-11-11
Changed in brz:
status: New → Triaged
importance: Undecided → Medium
tags: removed: check-for-breezy
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers