UnboundLocalError pushing to dir with some .bzr dirs. ('dir_to')

Bug #423563 reported by Gary van der Merwe
28
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Andrew Bennetts
2.0
Fix Released
High
Andrew Bennetts

Bug Description

I tried to push to a dir that had this folder structure in it (which I, for some reason was not able to delete from the server):

.bzr/
  branch/
    lock/
  repository/
    indices/

There were no other files, just the above folders.

I ran:
/var/www/pdt $ bzr push --use-existing-dir

and go this error:

Using saved push location: ftp://......
bzr: ERROR: exceptions.UnboundLocalError: local variable 'dir_to' referenced before assignment

Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 835, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1030, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 647, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 1161, in run
    use_existing_dir=use_existing_dir)
  File "/usr/lib/python2.6/dist-packages/bzrlib/push.py", line 92, in _show_push_branch
    create_prefix=create_prefix, use_existing_dir=use_existing_dir)
  File "/usr/lib/python2.6/dist-packages/bzrlib/branch.py", line 1256, in create_clone_on_transport
    return dir_to.open_branch()
UnboundLocalError: local variable 'dir_to' referenced before assignment

bzr 1.17 on python 2.6.2 (linux2)
arguments: ['/usr/bin/bzr', 'push', '--use-existing-dir']
encoding: 'UTF-8', fsenc: 'UTF-8', lang: 'en_ZA.UTF-8'
plugins:
  bookmarks /home/garyvdm/.bazaar/plugins/bookmarks [unknown]
  builddeb /home/garyvdm/.bazaar/plugins/builddeb [2.1.1dev]
  bzrtools /home/garyvdm/.bazaar/plugins/bzrtools [1.17]
  colocated /home/garyvdm/.bazaar/plugins/colocated [0.4.16dev]
  difftools /home/garyvdm/.bazaar/plugins/difftools [0.91]
  explorer /home/garyvdm/.bazaar/plugins/explorer [0.5dev]
  extmerge /home/garyvdm/.bazaar/plugins/extmerge [unknown]
  gtk /home/garyvdm/.bazaar/plugins/gtk [0.97.0.dev.1]
  launchpad /usr/lib/python2.6/dist-packages/bzrlib/plugins/launchpad [1.17]
  loom /home/garyvdm/.bazaar/plugins/loom [1.4dev]
  netrc_credential_store /usr/lib/python2.6/dist-packages/bzrlib/plugins/netrc_credential_store [1.17]
  qbzr /home/garyvdm/.bazaar/plugins/qbzr [0.15dev]
  rebase /home/garyvdm/.bazaar/plugins/rebase [0.5.2dev]
  search /home/garyvdm/.bazaar/plugins/search [1.7dev]
  stats /home/garyvdm/.bazaar/plugins/stats [unknown]
  upload /home/garyvdm/.bazaar/plugins/upload [0.1.1]
*** Bazaar has encountered an internal error.
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
    including this traceback, and a description of what you
    were doing when the error occurred.

Tags: easy

Related branches

Martin Pool (mbp)
Changed in bzr:
status: New → Confirmed
importance: Undecided → High
tags: added: easy
Revision history for this message
Andrew Bennetts (spiv) wrote :

It turned out that "easy" was perhaps a bit optimistic (the patch is fairly small, but identifying the correct thing to do was surprisingly tricky), but I have proposed a fix for this now.

Changed in bzr:
assignee: nobody → Andrew Bennetts (spiv)
status: Confirmed → Fix Committed
John A Meinel (jameinel)
Changed in bzr:
milestone: none → 2.1.0b4
status: Fix Committed → Fix Released
Revision history for this message
shemgp (shemgp) wrote :

I got this bug, so I upgraded didn't get it anymore but still got a different bug

Traceback:
 Traceback (most recent call last):
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
     return the_callable(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
     ret = run(*run_argv)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
     return self.run_direct(**all_cmd_args)
   File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
     return self._operation.run_simple(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
     self.cleanups, self.func, *args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
     result = func(*args, **kwargs)
   File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 1146, in run
     use_existing_dir=use_existing_dir)
   File "/usr/lib/python2.6/dist-packages/bzrlib/push.py", line 119, in _show_push_branch
     push_result.stacked_on = br_to.get_stacked_on_url()
 UnboundLocalError: local variable 'br_to' referenced before assignment

I was running bzr push http+webdav://someserver --use-existing-dir --create-prefix

using Bazaar (bzr) 2.1.0dev5

Revision history for this message
Andrew Bennetts (spiv) wrote :

Hmm, you're somehow getting a NoSuchFile exception from br_from.create_clone_on_transport despite using --create-prefix.

I've pushed up a trivial improvement to reveal the underlying NoSuchFile error, because it's not immediately clear to me how this case can happen, but giving the NoSuchFile error is at least going to be a touch more informative than the UnboundLocalError. We already do this for the FileExists case as part of the original fix for this bug report. The branch is <lp:~spiv/bzr/br_to-again-423563-2.0> (branched off lp:bzr/2.0), and a direct URL for the diff is <http://bazaar.launchpad.net/~spiv/bzr/br_to-again-423563-2.0/diff/4730>.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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