Rev 4895: (nmb) update displays the branch it works with in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Mon Dec 14 17:00:06 GMT 2009


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

------------------------------------------------------------
revno: 4895 [merge]
revision-id: pqm at pqm.ubuntu.com-20091214170001-i0n06gmfsiv2tw00
parent: pqm at pqm.ubuntu.com-20091214121014-5j9tx0x9tr1dkyh5
parent: v.ladeuil+lp at free.fr-20091214160427-qpk12j88zskx98qa
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2009-12-14 17:00:01 +0000
message:
  (nmb) update displays the branch it works with
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_filtered_view_ops.py test_filtered_view_o-20081110012645-5t7ogtola0l33lkg-1
  bzrlib/tests/blackbox/test_update.py test_update.py-20060212125639-c4dad1a5c56d5919
  bzrlib/tests/commands/test_update.py test_update.py-20070910091045-8uyp8v73j926l1g2-1
=== modified file 'NEWS'
--- a/NEWS	2009-12-14 09:31:20 +0000
+++ b/NEWS	2009-12-14 16:04:27 +0000
@@ -111,6 +111,9 @@
 
 * ``bzr log`` is now faster. (Ian Clatworthy)
 
+* ``bzr update`` provides feedback on which branch it is up to date with.
+  (Neil Martinsen-Burrell)
+
 * ``bzrlib.urlutils.local_path_from_url`` now accepts
   'file://localhost/' as well as 'file:///' URLs on POSIX.  (Michael
   Hudson)

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-12-11 05:48:21 +0000
+++ b/bzrlib/builtins.py	2009-12-14 16:04:27 +0000
@@ -1400,8 +1400,13 @@
             possible_transports=possible_transports)
         if master is not None:
             tree.lock_write()
+            branch_location = master.base
         else:
             tree.lock_tree_write()
+            branch_location = tree.branch.base
+        # get rid of the final '/' and be ready for display
+        branch_location = urlutils.unescape_for_display(branch_location[:-1],
+                                                        self.outf.encoding)
         try:
             existing_pending_merges = tree.get_parent_ids()[1:]
             last_rev = _mod_revision.ensure_null(tree.last_revision())
@@ -1411,7 +1416,8 @@
                 if master is None or last_rev == _mod_revision.ensure_null(
                     master.last_revision()):
                     revno = tree.branch.revision_id_to_revno(last_rev)
-                    note("Tree is up to date at revision %d." % (revno,))
+                    note('Tree is up to date at revision %d of branch %s'
+                         % (revno, branch_location))
                     return 0
             view_info = _get_view_info_for_change_reporter(tree)
             conflicts = tree.update(
@@ -1419,7 +1425,8 @@
                 view_info=view_info), possible_transports=possible_transports)
             revno = tree.branch.revision_id_to_revno(
                 _mod_revision.ensure_null(tree.last_revision()))
-            note('Updated to revision %d.' % (revno,))
+            note('Updated to revision %d of branch %s' %
+                 (revno, branch_location))
             if tree.get_parent_ids()[1:] != existing_pending_merges:
                 note('Your local commits will now show as pending merges with '
                      "'bzr status', and can be committed with 'bzr commit'.")

=== modified file 'bzrlib/tests/blackbox/test_filtered_view_ops.py'
--- a/bzrlib/tests/blackbox/test_filtered_view_ops.py	2009-04-08 03:34:31 +0000
+++ b/bzrlib/tests/blackbox/test_filtered_view_ops.py	2009-12-14 15:51:36 +0000
@@ -18,19 +18,20 @@
 
 import os
 
-from bzrlib import bzrdir
-from bzrlib.tests import TestCaseWithTransport
-from bzrlib.workingtree import WorkingTree
-
-
-class TestViewFileOperations(TestCaseWithTransport):
+from bzrlib import (
+    bzrdir,
+    osutils,
+    tests,
+    )
+
+
+class TestViewFileOperations(tests.TestCaseWithTransport):
 
     def make_abc_tree_with_ab_view(self):
         # we need to use a specific format because the default format
         # doesn't support views yet
         format = bzrdir.format_registry.make_bzrdir('development6-rich-root')
-        wt = TestCaseWithTransport.make_branch_and_tree(self, '.',
-            format=format)
+        wt = self.make_branch_and_tree( '.', format=format)
         self.build_tree(['a', 'b', 'c'])
         wt.views.set_view('my', ['a', 'b'])
         return wt
@@ -152,15 +153,14 @@
         self.assertEquals('b', out_lines[1])
 
 
-class TestViewTreeOperationss(TestCaseWithTransport):
+class TestViewTreeOperations(tests.TestCaseWithTransport):
 
     def make_abc_tree_and_clone_with_ab_view(self):
         # we need to use a specific format because the default format
         # doesn't support views yet
         format = bzrdir.format_registry.make_bzrdir('development6-rich-root')
         # Build the first tree
-        wt1 = TestCaseWithTransport.make_branch_and_tree(self, 'tree_1',
-            format=format)
+        wt1 = self.make_branch_and_tree('tree_1', format=format)
         self.build_tree(['tree_1/a', 'tree_1/b', 'tree_1/c'])
         wt1.add(['a', 'b', 'c'])
         wt1.commit("adding a b c")
@@ -186,15 +186,16 @@
 
     def test_view_on_update(self):
         tree_1, tree_2 = self.make_abc_tree_and_clone_with_ab_view()
-        os.chdir("tree_2")
-        self.run_bzr("bind ../tree_1")
-        out, err = self.run_bzr('update')
+        self.run_bzr("bind ../tree_1", working_dir='tree_2')
+        out, err = self.run_bzr('update', working_dir='tree_2')
         self.assertEqualDiff(
-            "Operating on whole tree but only reporting on 'my' view.\n"
-            " M  a\n"
-            "All changes applied successfully.\n"
-            "Updated to revision 2.\n", err)
-        self.assertEqualDiff("", out)
+            """Operating on whole tree but only reporting on 'my' view.
+ M  a
+All changes applied successfully.
+Updated to revision 2 of branch %s
+""" % osutils.pathjoin(self.test_dir, 'tree_1'),
+            err)
+        self.assertEqual("", out)
 
     def test_view_on_merge(self):
         tree_1, tree_2 = self.make_abc_tree_and_clone_with_ab_view()
@@ -203,4 +204,4 @@
             "Operating on whole tree but only reporting on 'my' view.\n"
             " M  a\n"
             "All changes applied successfully.\n", err)
-        self.assertEqualDiff("", out)
+        self.assertEqual("", out)

=== modified file 'bzrlib/tests/blackbox/test_update.py'
--- a/bzrlib/tests/blackbox/test_update.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/blackbox/test_update.py	2009-12-14 15:51:36 +0000
@@ -19,38 +19,58 @@
 """Tests for the update command of bzr."""
 
 import os
-
-from bzrlib import branch, bzrdir
-from bzrlib.tests.blackbox import ExternalBase
-from bzrlib.workingtree import WorkingTree
-
-
-class TestUpdate(ExternalBase):
+import re
+
+from bzrlib import (
+    branch,
+    bzrdir,
+    osutils,
+    tests,
+    urlutils,
+    workingtree,
+    )
+
+
+class TestUpdate(tests.TestCaseWithTransport):
 
     def test_update_standalone_trivial(self):
         self.make_branch_and_tree('.')
         out, err = self.run_bzr('update')
-        self.assertEqual('Tree is up to date at revision 0.\n', err)
+        self.assertEqual(
+            'Tree is up to date at revision 0 of branch %s\n' % self.test_dir,
+            err)
+        self.assertEqual('', out)
+
+    def test_update_quiet(self):
+        self.make_branch_and_tree('.')
+        out, err = self.run_bzr('update --quiet')
+        self.assertEqual('', err)
         self.assertEqual('', out)
 
     def test_update_standalone_trivial_with_alias_up(self):
         self.make_branch_and_tree('.')
         out, err = self.run_bzr('up')
-        self.assertEqual('Tree is up to date at revision 0.\n', err)
+        self.assertEqual('Tree is up to date at revision 0 of branch %s\n'
+                         % self.test_dir,
+                         err)
         self.assertEqual('', out)
 
     def test_update_up_to_date_light_checkout(self):
         self.make_branch_and_tree('branch')
         self.run_bzr('checkout --lightweight branch checkout')
         out, err = self.run_bzr('update checkout')
-        self.assertEqual('Tree is up to date at revision 0.\n', err)
+        self.assertEqual('Tree is up to date at revision 0 of branch %s\n'
+                         % osutils.pathjoin(self.test_dir, 'branch'),
+                         err)
         self.assertEqual('', out)
 
     def test_update_up_to_date_checkout(self):
         self.make_branch_and_tree('branch')
         self.run_bzr('checkout branch checkout')
         out, err = self.run_bzr('update checkout')
-        self.assertEqual('Tree is up to date at revision 0.\n', err)
+        self.assertEqual('Tree is up to date at revision 0 of branch %s\n'
+                         % osutils.pathjoin(self.test_dir, 'branch'),
+                         err)
         self.assertEqual('', out)
 
     def test_update_out_of_date_standalone_tree(self):
@@ -65,9 +85,11 @@
         # now branch should be out of date
         out,err = self.run_bzr('update branch')
         self.assertEqual('', out)
-        self.assertContainsRe(err, '\+N  file')
-        self.assertEndsWith(err, 'All changes applied successfully.\n'
-                         'Updated to revision 1.\n')
+        self.assertEqualDiff("""+N  file
+All changes applied successfully.
+Updated to revision 1 of branch %s
+""" % osutils.pathjoin(self.test_dir, 'branch',),
+                         err)
         self.failUnlessExists('branch/file')
 
     def test_update_out_of_date_light_checkout(self):
@@ -80,9 +102,11 @@
         self.run_bzr('commit -m add-file checkout')
         # now checkout2 should be out of date
         out,err = self.run_bzr('update checkout2')
-        self.assertContainsRe(err, '\+N  file')
-        self.assertEndsWith(err, 'All changes applied successfully.\n'
-                         'Updated to revision 1.\n')
+        self.assertEqualDiff('''+N  file
+All changes applied successfully.
+Updated to revision 1 of branch %s
+''' % osutils.pathjoin(self.test_dir, 'branch',),
+                         err)
         self.assertEqual('', out)
 
     def test_update_conflicts_returns_2(self):
@@ -104,11 +128,12 @@
         a_file.write('Bar')
         a_file.close()
         out,err = self.run_bzr('update checkout2', retcode=1)
-        self.assertContainsRe(err, 'M  file')
-        self.assertEqual(['1 conflicts encountered.',
-                          'Updated to revision 2.'],
-                         err.split('\n')[-3:-1])
-        self.assertContainsRe(err, 'Text conflict in file\n')
+        self.assertEqualDiff(''' M  file
+Text conflict in file
+1 conflicts encountered.
+Updated to revision 2 of branch %s
+''' % osutils.pathjoin(self.test_dir, 'branch',),
+                         err)
         self.assertEqual('', out)
 
     def test_smoke_update_checkout_bound_branch_local_commits(self):
@@ -118,11 +143,11 @@
         # make a bound branch
         self.run_bzr('checkout master child')
         # get an object form of child
-        child = WorkingTree.open('child')
+        child = workingtree.WorkingTree.open('child')
         # check that out
         self.run_bzr('checkout --lightweight child checkout')
         # get an object form of the checkout to manipulate
-        wt = WorkingTree.open('checkout')
+        wt = workingtree.WorkingTree.open('checkout')
         # change master
         a_file = file('master/file', 'wt')
         a_file.write('Foo')
@@ -145,11 +170,14 @@
         # get all three files and a pending merge.
         out, err = self.run_bzr('update checkout')
         self.assertEqual('', out)
-        self.assertContainsRe(err, '\+N  file')
-        self.assertContainsRe(err, '\+N  file_b')
-        self.assertContainsRe(err, 'Updated to revision 1.\n'
-                                   'Your local commits will now show as'
-                                   ' pending merges')
+        self.assertEqualDiff("""+N  file
+All changes applied successfully.
++N  file_b
+All changes applied successfully.
+Updated to revision 1 of branch %s
+Your local commits will now show as pending merges with 'bzr status', and can be committed with 'bzr commit'.
+""" % osutils.pathjoin(self.test_dir, 'master',),
+                         err)
         self.assertEqual([master_tip, child_tip], wt.get_parent_ids())
         self.failUnlessExists('checkout/file')
         self.failUnlessExists('checkout/file_b')
@@ -195,9 +223,11 @@
         # merges, because they were real merges
         out, err = self.run_bzr('update')
         self.assertEqual('', out)
-        self.assertEndsWith(err, 'All changes applied successfully.\n'
-                         'Updated to revision 2.\n')
-        self.assertContainsRe(err, r'\+N  file3')
+        self.assertEqualDiff('''+N  file3
+All changes applied successfully.
+Updated to revision 2 of branch %s
+''' % osutils.pathjoin(self.test_dir, 'master',),
+                         err)
         # The pending merges should still be there
         self.assertEqual(['o2'], checkout1.get_parent_ids()[1:])
 

=== modified file 'bzrlib/tests/commands/test_update.py'
--- a/bzrlib/tests/commands/test_update.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/commands/test_update.py	2009-12-14 15:51:36 +0000
@@ -18,6 +18,7 @@
 from bzrlib import (
     branch,
     builtins,
+    tests,
     )
 from bzrlib.tests import transport_util
 
@@ -36,6 +37,8 @@
         self.start_logging_connections()
 
         update = builtins.cmd_update()
+        # update needs the encoding from outf to print URLs
+        update.outf = tests.StringIOWrapper()
         # update calls it 'dir' where other commands calls it 'directory'
         update.run(dir='local')
         self.assertEquals(1, len(self.connections))




More information about the bazaar-commits mailing list