[PATCH] more informative error for bzr add (when parent is unversioned)

Robert Collins robertc at robertcollins.net
Fri Sep 9 15:12:28 BST 2005


On Thu, 2005-09-08 at 12:36 -0400, David Clymer wrote:
> I found the following error somewhat cryptic. This patch contains a
> slightly friendlier one.

I'm not going to merge this at this point, though it would be good to
get in. There was a PEP-8 (the coding standard we use) issue - below is
an updated copy of the patch showing the correction (line wrap at or
before 80 characters). More imporantly though, there are two actual
problems with the patch.
The first is that this takes a specialised error that is useful for any
front end OR program-control of bzr and turns it into a general error
that is only useful for front ends. The way to fix that is to put the
try/except block in 'bzrlib/builtins.py', in the cmd_add class.

Secondly, this is something we would not want to regress - so if you
could do a blackbox test to ensure that the ui shows the sane error,
that would help immensely.

Cheers,
Rob

--- bzrlib/add.py
+++ bzrlib/add.py 
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 from bzrlib.trace import mutter, note, warning
-from bzrlib.errors import NotBranchError
+from bzrlib.errors import BzrError, NotBranchError, NotVersionedError
 from bzrlib.branch import Branch
 from bzrlib.osutils import quotefn
 
@@ -129,7 +129,11 @@
         elif sub_tree:
             mutter("%r is a bzr tree" %f)
         else:
-            entry = inv.add_path(rf, kind=kind)
+            try:
+                entry = inv.add_path(rf, kind=kind)
+            except NotVersionedError, e:
+                raise BzrError('parent directory %s is not versioned. cannot '
+                               'add file %s' % (os.sep.join(e.args[0]), f))
             mutter("added %r kind %r file_id={%s}" % (rf, kind, entry.file_id))
             count += 1 
             reporter(rf, kind, entry)




-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050910/26218ece/attachment.pgp 


More information about the bazaar mailing list