Rev 4: Change 'bzr-register' to 'lp-register'. More master_config updates. in http://bzr.arbash-meinel.com/plugins/register

John Arbash Meinel john at arbash-meinel.com
Fri Mar 23 16:32:18 GMT 2007


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

------------------------------------------------------------
revno: 4
revision-id: john at arbash-meinel.com-20070323163205-0xk06kc7txaol1ww
parent: john at arbash-meinel.com-20070323155639-iacfnxdk9f70nhbi
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: register
timestamp: Fri 2007-03-23 11:32:05 -0500
message:
  Change 'bzr-register' to 'lp-register'. More master_config updates.
modified:
  __init__.py                    __init__.py-20060816173937-anpuzdybrrnsbg5x-1
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2007-03-23 15:56:39 +0000
+++ b/__init__.py	2007-03-23 16:32:05 +0000
@@ -32,7 +32,7 @@
     )
 
 
-class cmd_bzr_register(commands.Command):
+class cmd_lp_register(commands.Command):
     """Register a bzr branch with launchpad.
 
     This looks up the public location for the branch, including using
@@ -72,13 +72,15 @@
             bug=None):
         a_branch, relpath = branch.Branch.open_containing('.')
 
-        branch_config, repo_config = get_branch_and_repo_config(a_branch)
+        branch_config, repo_config, master_config = get_configs(a_branch)
         if location is None:
-            location = get_public_location(a_branch, branch_config, repo_config)
+            location = get_public_location(a_branch, branch_config,
+                                           repo_config, master_config)
 
         check_public_exists(location)
 
-        product = get_product(a_branch, branch_config, repo_config)
+        product = get_product(a_branch, branch_config, repo_config,
+                              master_config)
 
         cmd = ['register-branch']
         if dry_run:
@@ -111,7 +113,7 @@
         return commands.run_bzr_catch_errors(cmd)
 
 
-commands.register_command(cmd_bzr_register)
+commands.register_command(cmd_lp_register)
 
 
 def get_location(a_branch):
@@ -125,19 +127,22 @@
     return repo_loc, branch_relpath
 
 
-def get_branch_and_repo_config(a_branch):
-    """Get a ConfigObj for both the branch and the repository"""
+def get_configs(a_branch):
+    """Get a ConfigObj for both the branch, repository, and a master branch"""
     branch_config = a_branch.get_config()
     repo_loc, branch_relpath = get_location(a_branch)
     repo_config = config.LocationConfig(repo_loc)
-    return branch_config, repo_config
-
-
-def get_public_location(a_branch, branch_config, repo_config):
-    """Determine what the public location for this branch is"""
     master_location = a_branch.get_bound_location()
     if master_location is not None:
         master_config = config.LocationConfig(master_location)
+    else:
+        master_location = None
+    return branch_config, repo_config, master_config
+
+
+def get_public_location(a_branch, branch_config, repo_config, master_config):
+    """Determine what the public location for this branch is"""
+    if master_config is not None:
         target_base = master_config.get_user_option('public_branch')
         if target_base is not None:
             return target_base
@@ -154,9 +159,13 @@
     return target_base
 
 
-def get_product(a_branch, branch_config, repo_config):
+def get_product(a_branch, branch_config, repo_config, master_config):
     """Determine what product is associated with this branch"""
-    product = branch_config.get_user_option('product')
+    product = None
+    if master_config is not None:
+        product = master_config.get_user_option('product')
+    if product is None:
+        product = branch_config.get_user_option('product')
     if product is None:
         product = repo_config.get_user_option('product')
     return product



More information about the bazaar-commits mailing list