[MERGE] Give nicer errors for some write operations on read-only transports.

Martin Pool mbp at canonical.com
Mon Sep 3 10:30:29 BST 2007


Martin Pool has voted resubmit.
Status is now: Resubmit
Comment:
Thanks for doing this, there is at least one open bug report complaining 
about the ugly message:
https://bugs.launchpad.net/bzr/+bug/129701

 >Perhaps send could use the last log message as the message to start 
editing,
>or at least have an option to. Any comments?

I think that would be good.  Or maybe it should even show all the 
unmerged messages.  Fairly often my last message before I submit 
something is just 'update docs' and so not very interesting.  If it's 
useful some of the time it's probably a win as deleting unwanted text is 
fast compared to searching for the right thing to include.

+def ensure_transport_writable(transport):
+    """Ensure that the transport is writable.
+
+    If it is not (transport.is_readonly() is False) then it raises
+    errors.ReadonlyTransport, otherwise it does nothing.
+
+    :param transport: the transport to test.
+    :return: None
+    :raise errors.ReadonlyTransport: if the transport is readonly.
+    """
+    if transport.is_readonly():
+      raise errors.ReadonlyTransport(transport)
+
+

I think this should be a Transport method rather than a function.

We normally use the word 'ensure' to mean 'make it so', and
'require' for 'raise an error'.  (That should maybe be in the
developer guide, if other people agree it's the standard.)

So in summary,

   transport.require_writable()


+    _fmt = ("The transport %(transport)s is read-only. This operation "
+            "needs to write to the transport. Please see 'bzr help "
+            "urlspec' for a list of the available transports.")
+

I'd just say '%(transport)s is read only. etc'

Aside from that it looks good, thanks!



For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C20070902160411.242522900DD%40twitch%3E



More information about the bazaar mailing list