Rev 2720: Restore bundle info -v and fix multiparent stats in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Thu Aug 16 20:58:42 BST 2007


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

------------------------------------------------------------
revno: 2720
revision-id: pqm at pqm.ubuntu.com-20070816195834-vvgmajr1s1uk4m9w
parent: pqm at pqm.ubuntu.com-20070816181641-xfrq0orpmlde6nuk
parent: abentley at panoramicfeedback.com-20070816182313-6zd5awxp1ssuu2ku
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Thu 2007-08-16 20:58:34 +0100
message:
  Restore bundle info -v and fix multiparent stats
added:
  bzrlib/tests/blackbox/test_bundle_info.py test_bundle_info.py-20070816181255-eiuodwxuqu7w7gxf-1
modified:
  bzrlib/bundle/commands.py      __init__.py-20050617152058-1b6530d9ab85c11c
  bzrlib/tests/blackbox/__init__.py __init__.py-20051128053524-eba30d8255e08dc3
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.77.1.3.1.5
    merged: abentley at panoramicfeedback.com-20070816182313-6zd5awxp1ssuu2ku
    parent: abentley at panoramicfeedback.com-20070816165129-hz6spgwskmj2ztsd
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-08-16 14:23:13 -0400
    message:
      Add test cases for bzr bundle-info
    ------------------------------------------------------------
    revno: 1551.2.49.1.40.1.22.1.42.1.31.1.39.1.17.1.77.1.3.1.4
    merged: abentley at panoramicfeedback.com-20070816165129-hz6spgwskmj2ztsd
    parent: abentley at panoramicfeedback.com-20070815173112-dod4h1sgegz3n3av
    committer: Aaron Bentley <abentley at panoramicfeedback.com>
    branch nick: Aaron's mergeable stuff
    timestamp: Thu 2007-08-16 12:51:29 -0400
    message:
      Restore bundle-info -v, fix multiparent detection
=== added file 'bzrlib/tests/blackbox/test_bundle_info.py'
--- a/bzrlib/tests/blackbox/test_bundle_info.py	1970-01-01 00:00:00 +0000
+++ b/bzrlib/tests/blackbox/test_bundle_info.py	2007-08-16 18:23:13 +0000
@@ -0,0 +1,53 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+from bzrlib import (
+    merge_directive,
+    tests,
+    )
+
+
+class TestBundleInfo(tests.TestCaseWithTransport):
+
+    def test_bundle_info(self):
+        source = self.make_branch_and_tree('source')
+        self.build_tree(['source/foo'])
+        source.add('foo')
+        source.commit('added file', rev_id='rev1')
+        bundle = open('bundle', 'wb')
+        try:
+            source.branch.repository.create_bundle('rev1', 'null:', bundle,
+                                                   '4')
+        finally:
+            bundle.close()
+        info = self.run_bzr('bundle-info bundle')[0]
+        self.assertContainsRe(info, 'file: 1 .0 multiparent.')
+        self.assertContainsRe(info, 'nicks: source')
+        self.assertNotContainsRe(info, 'foo')
+        self.run_bzr_error(['Verbose requires a merge directive'],
+                           'bundle-info -v bundle')
+        target = self.make_branch('target')
+        md = merge_directive.MergeDirective2.from_objects(
+            source.branch.repository, 'rev1', 0, 0, 'target',
+            base_revision_id='null:')
+        directive = open('directive', 'wb')
+        try:
+            directive.writelines(md.to_lines())
+        finally:
+            directive.close()
+        info = self.run_bzr('bundle-info -v directive')[0]
+        self.assertContainsRe(info, 'foo')

=== modified file 'bzrlib/bundle/commands.py'
--- a/bzrlib/bundle/commands.py	2007-07-17 13:27:14 +0000
+++ b/bzrlib/bundle/commands.py	2007-08-16 16:51:29 +0000
@@ -45,7 +45,7 @@
 
     hidden = True
     takes_args = ['location']
-    takes_options = []
+    takes_options = ['verbose']
     encoding_type = 'exact'
 
     def run(self, location, verbose=False):
@@ -55,7 +55,12 @@
         term_encoding = osutils.get_terminal_encoding()
         bundle_info = read_mergeable_from_url(location)
         if isinstance(bundle_info, merge_directive._BaseMergeDirective):
-            bundle_info = read_bundle(StringIO(bundle_info.get_raw_bundle()))
+            bundle_file = StringIO(bundle_info.get_raw_bundle())
+            bundle_info = read_bundle(bundle_file)
+        else:
+            if verbose:
+                raise errors.BzrCommandError('Verbose requires a merge'
+                                             ' directive')
         reader_method = getattr(bundle_info, 'get_bundle_reader', None)
         if reader_method is None:
             raise errors.BzrCommandError('Bundle format not supported')
@@ -70,7 +75,8 @@
                 file_ids.add(file_id)
         print >> self.outf, 'Records'
         for kind, records in sorted(by_kind.iteritems()):
-            multiparent = sum(1 for b, p, k, r, f in records if len(p) > 1)
+            multiparent = sum(1 for b, m, k, r, f in records if
+                              len(m.get('parents', [])) > 1)
             print >> self.outf, '%s: %d (%d multiparent)' % \
                 (kind, len(records), multiparent)
         print >> self.outf, 'unique files: %d' % len(file_ids)

=== modified file 'bzrlib/tests/blackbox/__init__.py'
--- a/bzrlib/tests/blackbox/__init__.py	2007-07-27 05:17:06 +0000
+++ b/bzrlib/tests/blackbox/__init__.py	2007-08-16 18:23:13 +0000
@@ -50,6 +50,7 @@
                      'bzrlib.tests.blackbox.test_break_lock',
                      'bzrlib.tests.blackbox.test_breakin',
                      'bzrlib.tests.blackbox.test_bound_branches',
+                     'bzrlib.tests.blackbox.test_bundle_info',
                      'bzrlib.tests.blackbox.test_cat',
                      'bzrlib.tests.blackbox.test_cat_revision',
                      'bzrlib.tests.blackbox.test_checkout',




More information about the bazaar-commits mailing list