Rev 3938: Better/faster status after merge (Ian Clatworthy) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Jan 14 05:13:18 GMT 2009


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

------------------------------------------------------------
revno: 3938
revision-id: pqm at pqm.ubuntu.com-20090114051315-92k8x1bysxbvs0mu
parent: pqm at pqm.ubuntu.com-20090113051424-nrk3zkfe09h46i9y
parent: ian.clatworthy at canonical.com-20090114040552-aclggp7hqv33ckwc
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-01-14 05:13:15 +0000
message:
  Better/faster status after merge (Ian Clatworthy)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/status.py               status.py-20050505062338-431bfa63ec9b19e6
  bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
  bzrlib/tests/test_status.py    test_status.py-20060516190614-fbf6432e4a6e8aa5
    ------------------------------------------------------------
    revno: 3937.1.1
    revision-id: ian.clatworthy at canonical.com-20090114040552-aclggp7hqv33ckwc
    parent: pqm at pqm.ubuntu.com-20090113051424-nrk3zkfe09h46i9y
    parent: ian.clatworthy at canonical.com-20090114035748-z3m9blehvve4rbk4
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: ianc-integration
    timestamp: Wed 2009-01-14 14:05:52 +1000
    message:
      Better/faster status after merge (Ian Clatworthy)
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/status.py               status.py-20050505062338-431bfa63ec9b19e6
      bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
      bzrlib/tests/test_status.py    test_status.py-20060516190614-fbf6432e4a6e8aa5
    ------------------------------------------------------------
    revno: 3936.2.3
    revision-id: ian.clatworthy at canonical.com-20090114035748-z3m9blehvve4rbk4
    parent: ian.clatworthy at canonical.com-20090113012847-3l1iu3jbhjousg7m
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: bzr.pending-heads
    timestamp: Wed 2009-01-14 13:57:48 +1000
    message:
      feedback from jameinel
    modified:
      bzrlib/status.py               status.py-20050505062338-431bfa63ec9b19e6
      bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
      bzrlib/tests/test_status.py    test_status.py-20060516190614-fbf6432e4a6e8aa5
    ------------------------------------------------------------
    revno: 3936.2.2
    revision-id: ian.clatworthy at canonical.com-20090113012847-3l1iu3jbhjousg7m
    parent: ian.clatworthy at canonical.com-20090113004442-16lkilw5fk8ba9mc
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: bzr.pending-heads
    timestamp: Tue 2009-01-13 11:28:47 +1000
    message:
      add NEWS item & improve status help
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3936.2.1
    revision-id: ian.clatworthy at canonical.com-20090113004442-16lkilw5fk8ba9mc
    parent: pqm at pqm.ubuntu.com-20090112185737-d6kwagahecadwfce
    committer: Ian Clatworthy <ian.clatworthy at canonical.com>
    branch nick: bzr.pending-heads
    timestamp: Tue 2009-01-13 10:44:42 +1000
    message:
      verbose flag for status - code & tests
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/status.py               status.py-20050505062338-431bfa63ec9b19e6
      bzrlib/tests/blackbox/test_status.py teststatus.py-20050712014354-508855eb9f29f7dc
      bzrlib/tests/test_status.py    test_status.py-20060516190614-fbf6432e4a6e8aa5
=== modified file 'NEWS'
--- a/NEWS	2009-01-13 03:11:04 +0000
+++ b/NEWS	2009-01-14 04:05:52 +0000
@@ -8,7 +8,12 @@
 NOT RELEASED YET
 ----------------
 
-  COMPATABILITY BREAKS:
+  COMPATIBILITY BREAKS:
+
+    * By default, ``bzr status`` after a merge now shows just the pending
+      merge tip revisions. This improves the signal-to-noise ratio after
+      merging from trunk and completes much faster. To see all merged
+      revisions, use the new ``-v`` flag.  (Ian Clatworthy)
 
   NEW FEATURES:
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-01-09 06:00:28 +0000
+++ b/bzrlib/builtins.py	2009-01-14 04:05:52 +0000
@@ -178,6 +178,11 @@
     files or directories is reported.  If a directory is given, status
     is reported for everything inside that directory.
 
+    Before merges are committed, the pending merge tip revisions are
+    shown. To see all pending merge revisions, use the -v option.
+    To skip the display of pending merge information altogether, use
+    the no-pending option or specify a file/directory.
+
     If a revision argument is given, the status is calculated against
     that revision, or between two revisions if two are provided.
     """
@@ -185,7 +190,7 @@
     # TODO: --no-recurse, --recurse options
     
     takes_args = ['file*']
-    takes_options = ['show-ids', 'revision', 'change',
+    takes_options = ['show-ids', 'revision', 'change', 'verbose',
                      Option('short', help='Use short status indicators.',
                             short_name='S'),
                      Option('versioned', help='Only show versioned files.',
@@ -200,7 +205,7 @@
     
     @display_command
     def run(self, show_ids=False, file_list=None, revision=None, short=False,
-            versioned=False, no_pending=False):
+            versioned=False, no_pending=False, verbose=False):
         from bzrlib.status import show_tree_status
 
         if revision and len(revision) > 2:
@@ -220,7 +225,7 @@
         show_tree_status(tree, show_ids=show_ids,
                          specific_files=relfile_list, revision=revision,
                          to_file=self.outf, short=short, versioned=versioned,
-                         show_pending=(not no_pending))
+                         show_pending=(not no_pending), verbose=verbose)
 
 
 class cmd_cat_revision(Command):

=== modified file 'bzrlib/status.py'
--- a/bzrlib/status.py	2008-10-01 05:40:45 +0000
+++ b/bzrlib/status.py	2009-01-14 03:57:48 +0000
@@ -41,6 +41,7 @@
                      show_pending=True,
                      revision=None,
                      short=False,
+                     verbose=False,
                      versioned=False):
     """Display summary of changes.
 
@@ -67,6 +68,8 @@
         If one revision, compare with working tree.
         If two revisions, show status between first and second.
     :param short: If True, gives short SVN-style status lines.
+    :param verbose: If True, show all merged revisions, not just
+        the merge tips
     :param versioned: If True, only shows versioned files.
     """
     if show_unchanged is not None:
@@ -135,7 +138,7 @@
                     prefix = ' '
                 to_file.write("%s %s\n" % (prefix, conflict))
             if (new_is_working_tree and show_pending):
-                show_pending_merges(new, to_file, short)
+                show_pending_merges(new, to_file, short, verbose=verbose)
         finally:
             old.unlock()
             new.unlock()
@@ -169,7 +172,7 @@
     return sorter.iter_topo_order()
 
 
-def show_pending_merges(new, to_file, short=False):
+def show_pending_merges(new, to_file, short=False, verbose=False):
     """Write out a display of pending merges in a working tree."""
     parents = new.get_parent_ids()
     if len(parents) < 2:
@@ -188,7 +191,10 @@
     branch = new.branch
     last_revision = parents[0]
     if not short:
-        to_file.write('pending merges:\n')
+        if verbose:
+            to_file.write('pending merges:\n')
+        else:
+            to_file.write('pending merge tips: (use -v to see all merge revisions)\n')
     graph = branch.repository.get_graph()
     other_revisions = [last_revision]
     log_formatter = log.LineLogFormatter(to_file)
@@ -205,6 +211,9 @@
         log_message = log_formatter.log_string(None, rev,
                         term_width - len(first_prefix))
         to_file.write(first_prefix + log_message + '\n')
+        if not verbose:
+            continue
+
         # Find all of the revisions in the merge source, which are not in the
         # last committed revision.
         merge_extra = graph.find_unique_ancestors(merge, other_revisions)

=== modified file 'bzrlib/tests/blackbox/test_status.py'
--- a/bzrlib/tests/blackbox/test_status.py	2008-10-01 05:40:45 +0000
+++ b/bzrlib/tests/blackbox/test_status.py	2009-01-14 03:57:48 +0000
@@ -45,22 +45,23 @@
 class BranchStatus(TestCaseWithTransport):
     
     def assertStatus(self, expected_lines, working_tree,
-        revision=None, short=False, pending=True):
+        revision=None, short=False, pending=True, verbose=False):
         """Run status in working_tree and look for output.
         
         :param expected_lines: The lines to look for.
         :param working_tree: The tree to run status in.
         """
         output_string = self.status_string(working_tree, revision, short,
-                pending)
+                pending, verbose)
         self.assertEqual(expected_lines, output_string.splitlines(True))
     
-    def status_string(self, wt, revision=None, short=False, pending=True):
+    def status_string(self, wt, revision=None, short=False, pending=True,
+        verbose=False):
         # use a real file rather than StringIO because it doesn't handle
         # Unicode very well.
         tof = codecs.getwriter('utf-8')(TemporaryFile())
         show_tree_status(wt, to_file=tof, revision=revision, short=short,
-                show_pending=pending)
+                show_pending=pending, verbose=verbose)
         tof.seek(0)
         return tof.read().decode('utf-8')
 
@@ -95,10 +96,18 @@
                 'unknown:\n',
                 '  bye.c\n',
                 '  hello.c\n',
+                'pending merge tips: (use -v to see all merge revisions)\n',
+                '  (ghost) pending at pending-0-0\n',
+            ],
+            wt)
+        self.assertStatus([
+                'unknown:\n',
+                '  bye.c\n',
+                '  hello.c\n',
                 'pending merges:\n',
                 '  (ghost) pending at pending-0-0\n',
             ],
-            wt)
+            wt, verbose=True)
         self.assertStatus([
                 '?   bye.c\n',
                 '?   hello.c\n',
@@ -159,7 +168,7 @@
         wt2 = b_2_dir.open_workingtree()
         wt.commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
         wt2.merge_from_branch(wt.branch)
-        message = self.status_string(wt2)
+        message = self.status_string(wt2, verbose=True)
         self.assertStartsWith(message, "pending merges:\n")
         self.assertEndsWith(message, "Empty commit 2\n")
         wt2.commit("merged")
@@ -167,7 +176,7 @@
         wt.commit("Empty commit 3 " +
                    "blah blah blah blah " * 100)
         wt2.merge_from_branch(wt.branch)
-        message = self.status_string(wt2)
+        message = self.status_string(wt2, verbose=True)
         self.assertStartsWith(message, "pending merges:\n")
         self.assert_("Empty commit 3" in message)
         self.assertEndsWith(message, "...\n")
@@ -470,9 +479,9 @@
         tree.merge_from_branch(alt.branch)
         output = self.make_utf8_encoded_stringio()
         show_tree_status(tree, to_file=output)
-        self.assertContainsRe(output.getvalue(), 'pending merges:')
+        self.assertContainsRe(output.getvalue(), 'pending merge')
         out, err = self.run_bzr('status tree/a')
-        self.assertNotContainsRe(out, 'pending merges:')
+        self.assertNotContainsRe(out, 'pending merge')
 
 
 class TestStatusEncodings(TestCaseWithTransport):

=== modified file 'bzrlib/tests/test_status.py'
--- a/bzrlib/tests/test_status.py	2008-08-16 22:28:01 +0000
+++ b/bzrlib/tests/test_status.py	2009-01-14 03:57:48 +0000
@@ -42,7 +42,7 @@
             tree2.unlock()
         self.assertContainsRe(output.getvalue(), 'empty commit')
 
-    def test_multiple_pending(self):
+    def make_multiple_pending_tree(self):
         config.GlobalConfig().set_user_option('email', 'Joe Foo <joe at foo.com>')
         tree = self.make_branch_and_tree('a')
         tree.commit('commit 1', timestamp=1196796819, timezone=0)
@@ -54,10 +54,27 @@
         tree3.commit('commit 3c', timestamp=1196796819, timezone=0)
         tree.merge_from_branch(tree2.branch)
         tree.merge_from_branch(tree3.branch)
+        return tree
+
+    def test_multiple_pending(self):
+        tree = self.make_multiple_pending_tree()
         output = StringIO()
         tree.lock_read()
         self.addCleanup(tree.unlock)
         show_pending_merges(tree, output)
+        # 2b doesn't appear because it's an ancestor of 3b
+        self.assertEqualDiff(
+            'pending merge tips: (use -v to see all merge revisions)\n'
+            '  Joe Foo 2007-12-04 commit 3b\n'
+            '  Joe Foo 2007-12-04 commit 3c\n',
+            output.getvalue())
+
+    def test_multiple_pending_verbose(self):
+        tree = self.make_multiple_pending_tree()
+        output = StringIO()
+        tree.lock_read()
+        self.addCleanup(tree.unlock)
+        show_pending_merges(tree, output, verbose=True)
         # Even though 2b is in the ancestry of 3c, it should only be displayed
         # under the first merge parent.
         self.assertEqualDiff('pending merges:\n'
@@ -75,9 +92,10 @@
         self.addCleanup(tree.unlock)
         output = StringIO()
         show_pending_merges(tree, output)
-        self.assertEqualDiff('pending merges:\n'
-                             '  (ghost) a-ghost-revision\n',
-                             output.getvalue())
+        self.assertEqualDiff(
+            'pending merge tips: (use -v to see all merge revisions)\n'
+            '  (ghost) a-ghost-revision\n',
+            output.getvalue())
 
     def test_pending_with_ghosts(self):
         """Test when a pending merge's ancestry includes ghosts."""
@@ -93,7 +111,7 @@
         tree.lock_read()
         self.addCleanup(tree.unlock)
         output = StringIO()
-        show_pending_merges(tree, output)
+        show_pending_merges(tree, output, verbose=True)
         self.assertEqualDiff('pending merges:\n'
                              '  Joe Foo 2007-12-04 another non-ghost\n'
                              '    Joe Foo 2007-12-04 commit with ghost\n'




More information about the bazaar-commits mailing list