Rev 2: Override the default branch name, to use one with dashes instead of underscores. in http://bzr.arbash-meinel.com/plugins/register

John Arbash Meinel john at arbash-meinel.com
Fri Mar 23 15:45:34 GMT 2007


At http://bzr.arbash-meinel.com/plugins/register

------------------------------------------------------------
revno: 2
revision-id: john at arbash-meinel.com-20070323153843-vanmpj8ff0r0l5m1
parent: john at arbash-meinel.com-20060816173956-2730fe34b0062188
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: register
timestamp: Fri 2007-03-23 10:38:43 -0500
message:
  Override the default branch name, to use one with dashes instead of underscores.
modified:
  __init__.py                    __init__.py-20060816173937-anpuzdybrrnsbg5x-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2006-08-16 17:39:56 +0000
+++ b/__init__.py	2007-03-23 15:38:43 +0000
@@ -25,6 +25,7 @@
     branch,
     commands,
     config,
+    errors,
     option,
     osutils,
     urlutils,
@@ -94,6 +95,14 @@
         if description is not None:
             cmd.extend(['--branch-description', description])
 
+        base, name = urlutils.split(location)
+        # LP will create branches named with underscores, but if you go to edit
+        # the branch name, it will complain, and make you change them all.
+        # So be helpful and do this pre-emptively.
+        name = name.replace('_', '-')
+
+        cmd.extend(['--branch-name', name])
+
         cmd.append(location)
 
         if dry_run:
@@ -151,7 +160,7 @@
     """Check that the predicted public location really is a branch"""
     try:
         branch.Branch.open(location)
-    except errors.NotABranch:
+    except errors.NotBranchError:
         raise errors.BzrCommandError('Target location %s is not a branch.'
             ' Consider configuring public_repository or public_branch, or'
-            ' using --location')
+            ' using --location' % (location,))



More information about the bazaar-commits mailing list