Rev 3716: In checkouts, switch uses master branch context (awilkins) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Sep 20 19:21:17 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3716
revision-id: pqm at pqm.ubuntu.com-20080920182113-2mnuiiv5bg6x97fe
parent: pqm at pqm.ubuntu.com-20080920174109-rrml3htu12o56j1h
parent: aaron at aaronbentley.com-20080920175123-uwkdfa9i97k6g5es
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2008-09-20 19:21:13 +0100
message:
  In checkouts, switch uses master branch context (awilkins)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_switch.py test_switch.py-20071122111948-0c5en6uz92bwl76h-1
    ------------------------------------------------------------
    revno: 3714.1.2
    revision-id: aaron at aaronbentley.com-20080920175123-uwkdfa9i97k6g5es
    parent: aaron at aaronbentley.com-20080920175049-0bchxyf8oeqjzylr
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Sat 2008-09-20 13:51:23 -0400
    message:
      Update NEWS
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
    ------------------------------------------------------------
    revno: 3714.1.1
    revision-id: aaron at aaronbentley.com-20080920175049-0bchxyf8oeqjzylr
    parent: pqm at pqm.ubuntu.com-20080919110131-v81t8izemtywe4vu
    parent: adrian.wilkins at gmail.com-20080807091247-ka2b7thkrsap69jr
    committer: Aaron Bentley <aaron at aaronbentley.com>
    branch nick: bzr.ab.integration
    timestamp: Sat 2008-09-20 13:50:49 -0400
    message:
      Merge awilkins' changes
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_switch.py test_switch.py-20071122111948-0c5en6uz92bwl76h-1
    ------------------------------------------------------------
    revno: 3602.3.4
    revision-id: adrian.wilkins at gmail.com-20080807091247-ka2b7thkrsap69jr
    parent: adrian.wilkins at gmail.com-20080804150515-0kstr2dih843lzob
    committer: Adrian Wilkins <adrian.wilkins at gmail.com>
    branch nick: bzr.switch-heavy-checkout-sibling
    timestamp: Thu 2008-08-07 10:12:47 +0100
    message:
      Improved comments and documentation
      Used urlutils.join to join the url
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/tests/blackbox/test_switch.py test_switch.py-20071122111948-0c5en6uz92bwl76h-1
    ------------------------------------------------------------
    revno: 3602.3.3
    revision-id: adrian.wilkins at gmail.com-20080804150515-0kstr2dih843lzob
    parent: adrian.wilkins at gmail.com-20080804142844-bvxt4avnorzks2dx
    committer: Adrian Wilkins <adrian.wilkins at gmail.com>
    branch nick: bzr.switch_heavy_checkout_siblings
    timestamp: Mon 2008-08-04 16:05:15 +0100
    message:
      Tweaked as suggested to be more lightweight about opening branches.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3602.3.2
    revision-id: adrian.wilkins at gmail.com-20080804142844-bvxt4avnorzks2dx
    parent: adrian.wilkins at gmail.com-20080804142739-dkdnqdhvrhxsb449
    committer: Adrian Wilkins <adrian.wilkins at gmail.com>
    branch nick: bzr.switch_heavy_checkout_siblings
    timestamp: Mon 2008-08-04 15:28:44 +0100
    message:
      `bzr switch` now finds the sibling of the bound branch of a heavy checkout when passed a location that does not immediately resolve to a branch.
      
      It no longer finds siblings of the heavy checkout itself, which could be considered a regression if this was the intended function of this convenience feature.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3602.3.1
    revision-id: adrian.wilkins at gmail.com-20080804142739-dkdnqdhvrhxsb449
    parent: pqm at pqm.ubuntu.com-20080804032751-myaykx8azatkvlf8
    committer: Adrian Wilkins <adrian.wilkins at gmail.com>
    branch nick: bzr.switch_heavy_checkout_siblings
    timestamp: Mon 2008-08-04 15:27:39 +0100
    message:
      Test that `bzr switch` finds the sibling of the bound branch of heavy checkout.
    modified:
      bzrlib/tests/blackbox/test_switch.py test_switch.py-20071122111948-0c5en6uz92bwl76h-1
=== modified file 'NEWS'
--- a/NEWS	2008-09-19 11:01:31 +0000
+++ b/NEWS	2008-09-20 17:51:23 +0000
@@ -13,6 +13,9 @@
 
   IMPROVEMENTS:
 
+    * Switching in heavyweight checkouts uses the master branch's context, not
+      the checkout's context.  (Adrian Wilkins)
+
   BUG FIXES:
 
     * Branching from a shared repository on a smart server into a new

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-09-17 07:18:20 +0000
+++ b/bzrlib/builtins.py	2008-09-20 17:50:49 +0000
@@ -4559,8 +4559,14 @@
         try:
             to_branch = Branch.open(to_location)
         except errors.NotBranchError:
+            this_branch = control_dir.open_branch()
+            # This may be a heavy checkout, where we want the master branch
+            this_url = this_branch.get_bound_location()
+            # If not, use a local sibling
+            if this_url is None:
+                this_url = this_branch.base
             to_branch = Branch.open(
-                control_dir.open_branch().base + '../' + to_location)
+                urlutils.join(this_url, '..', to_location))
         switch.switch(control_dir, to_branch, force)
         note('Switched to branch: %s',
             urlutils.unescape_for_display(to_branch.base, 'utf-8'))

=== modified file 'bzrlib/tests/blackbox/test_switch.py'
--- a/bzrlib/tests/blackbox/test_switch.py	2008-03-03 11:35:47 +0000
+++ b/bzrlib/tests/blackbox/test_switch.py	2008-08-07 09:12:47 +0000
@@ -62,4 +62,23 @@
         self.assertEqual(branchb_id, checkout.last_revision())
         checkout = checkout.bzrdir.open_workingtree()
         self.assertEqual(tree2.branch.base, checkout.branch.base)
-        
+
+    def test_switch_finds_relative_bound_branch(self):
+        """Using switch on a heavy checkout should find master sibling
+
+        The behaviour of lighweight and heavy checkouts should be 
+        consistentwhen using the convenient "switch to sibling" feature
+        Both should switch to a sibling of the branch
+        they are bound to, and not a sibling of themself"""
+
+        self.build_tree(['repo/',
+                         'heavyco/'])
+        tree1 = self.make_branch_and_tree('repo/brancha')
+        tree1.commit('foo')
+        tree2 = self.make_branch_and_tree('repo/branchb')
+        tree2.pull(tree1.branch)
+        branchb_id = tree2.commit('bar')
+        checkout = tree1.branch.create_checkout('heavyco/a', lightweight=False)
+        self.run_bzr(['switch', 'branchb'], working_dir='heavyco/a')
+        self.assertEqual(branchb_id, checkout.last_revision())
+        self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location())




More information about the bazaar-commits mailing list