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

------------------------------------------------------------
revno: 5
revision-id: [email protected]
parent: [email protected]
committer: John Arbash Meinel <[email protected]>
branch nick: raf
timestamp: Wed 2009-01-14 14:53:07 -0600
message:
  A function to handle opening the target branch.
=== modified file 'raf.py'
--- a/raf.py    2009-01-14 20:44:39 +0000
+++ b/raf.py    2009-01-14 20:53:07 +0000
@@ -88,3 +88,17 @@
             trans.stat(archived_name)
         except errors.NoSuchFile: # This path doesn't exist
             return trans, trans.abspath(archived_name)
+
+
+def get_target_branch(target, possible_transports=[]):
+    """Find the branch that we want to be merged into.
+
+    :param target: The target as specified by the user. If None, then we will
+        use the value in bzrlib.plugins.raf.DEFAULT_TARGET_BRANCH.
+    :param possible_transports: A list of transports that we can try to re-use
+        rather than opening a new connection to a remote location.
+    """
+    if target is None:
+        from bzrlib.plugins.raf import DEFAULT_TARGET_BRANCH
+        target = DEFAULT_TARGET_BRANCH
+    return branch.Branch.open(target, possible_transports=possible_transports)

=== modified file 'test_raf.py'
--- a/test_raf.py       2009-01-14 20:44:39 +0000
+++ b/test_raf.py       2009-01-14 20:53:07 +0000
@@ -132,3 +132,25 @@
                                 b, None)
         finally:
             plugin_raf.DEFAULT_ARCHIVE_BASE = orig_default
+
+
+class TestGetTargetBranch(tests.TestCaseWithTransport):
+
+    def test_get_direct_target(self):
+        b = self.make_branch('target')
+        target_b = raf.get_target_branch('target')
+        self.assertEqual(b.base, target_b.base)
+        target_b = raf.get_target_branch(b.base)
+        self.assertEqual(b.base, target_b.base)
+
+    def test_none_uses_default(self):
+        b = self.make_branch('target')
+        from bzrlib.plugins import raf as plugin_raf
+        orig_default = plugin_raf.DEFAULT_TARGET_BRANCH
+        try:
+            plugin_raf.DEFAULT_TARGET_BRANCH = b.base
+
+            target_b = raf.get_target_branch(None)
+            self.assertEqual(b.base, target_b.base)
+        finally:
+            plugin_raf.DEFAULT_TARGET_BRANCH = orig_default

-- 
bazaar-commits mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/bazaar-commits

Reply via email to