UnlockableTransport error trying to commit in checkout of readonly branch

Bug #129701 reported by Andrew Cowie
4
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Martin Pool

Bug Description

If a developer has checked out a branch (rather than having branched it), and then attempts to make a commit to that branch, the error message is two screenfulls of Python gibberish:

"""
bzr: ERROR: bzrlib.errors.UnlockableTransport: Cannot lock: transport is read only: <bzrlib.transport.http._pycurl.PyCurlTransport url=http://research.operationaldynamics.com/bzr/java-gnome/.bzr/repository/>

Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 718, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 679, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.4/site-packages/bzrlib/commands.py", line 375, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.4/site-packages/bzrlib/builtins.py", line 2226, in run
    reporter=reporter, revprops=properties)
  File "/usr/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/workingtree_4.py", line 245, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/mutabletree.py", line 195, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/lib/python2.4/site-packages/bzrlib/commit.py", line 253, in commit
    self._check_bound_branch()
  File "/usr/lib/python2.4/site-packages/bzrlib/commit.py", line 434, in _check_bound_branch
    self.master_branch.lock_write()
  File "/usr/lib/python2.4/site-packages/bzrlib/branch.py", line 1315, in lock_write
    repo_token = self.repository.lock_write()
  File "/usr/lib/python2.4/site-packages/bzrlib/repository.py", line 252, in lock_write
    return self.control_files.lock_write(token=token)
  File "/usr/lib/python2.4/site-packages/bzrlib/lockable_files.py", line 258, in lock_write
    token_from_lock = self._lock.lock_write(token=token)
  File "/usr/lib/python2.4/site-packages/bzrlib/lockdir.py", line 453, in lock_write
    self.wait_lock()
  File "/usr/lib/python2.4/site-packages/bzrlib/lockdir.py", line 392, in wait_lock
    self.attempt_lock()
  File "/usr/lib/python2.4/site-packages/bzrlib/lockdir.py", line 198, in attempt_lock
    raise UnlockableTransport(self.transport)
UnlockableTransport: Cannot lock: transport is read only: <bzrlib.transport.http._pycurl.PyCurlTransport url=http://research.operationaldynamics.com/bzr/java-gnome/.bzr/repository/>

bzr 0.17.0 on python 2.4.4.final.0 (linux2)
arguments: ['/usr/bin/bzr', 'commit', 'README']
"""

Instead of all that nonsense, it might be more helpful to output a usable (and, for that matter, translatable) message indicating what the problem actually is and what to do about it. Perhaps:

"""
Error: this is a checkout, so you can't commit here. What you want to do is create your own full power branch to which you can make changes, make as many commits as you like, and then submit your code to the upstream project using bzr bundle. To make a branch (assuming you're in a directory called mainline which is what you checked out), just do

cd ..
bzr branch mainline working
cd working

And you're all set. That way you can keep using the ../mainline directory as a branch where you can do bzr pull to track the upstream project, and this new full powered branch as your playground
"""

However, going even further, since the result of checkout and branch differ by _only_ by:

bound = True

perhaps the right thing to actually do is to deprecate the whole checkout thing and just make it a synonym of branch like clone is. After all, if upstream has diverged, big deal - they have to merge and better that they resolve any conflicts rather than the poor upstream maintained having to.

AfC

Revision history for this message
Matthew East (mdke) wrote :

I've just encountered this one too. Confirming.

Changed in bzr:
status: New → Confirmed
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I've helped a number of people through this confusion in the last few days, I think Something Should Be Done.

I'm not sure I agree with the suggested fixes, though. I think the error message should talk about bind and unbind -- "if you have access to the branch via a url that supports writing such as sftp or bzr+ssh, try bzr bind <that url>, or if you do not wish your commits to go to another branch, type "bzr unbind". See bzr help checkouts for more."

Or something.

Martin Pool (mbp)
Changed in bzr:
importance: Undecided → Medium
Revision history for this message
Martin Pool (mbp) wrote :

James posted a patch that improves this.

Changed in bzr:
assignee: nobody → jw+debian
status: Confirmed → In Progress
Revision history for this message
James Westby (james-w) wrote :

My patch was rejected.

Changed in bzr:
assignee: jw+debian → nobody
status: In Progress → Confirmed
Martin Pool (mbp)
Changed in bzr:
assignee: nobody → mbp
Martin Pool (mbp)
Changed in bzr:
status: Confirmed → In Progress
Revision history for this message
Martin Pool (mbp) wrote :
Changed in bzr:
status: In Progress → Fix Committed
Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 0.92
status: Fix Committed → 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.