Rev 3201: (bialix) new formatting of `bzr plugins` output. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Jan 25 19:59:48 GMT 2008


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

------------------------------------------------------------
revno: 3201
revision-id:pqm at pqm.ubuntu.com-20080125195940-iwy2onaiiges6k4t
parent: pqm at pqm.ubuntu.com-20080124050323-gsgsp2em7v1ugtnz
parent: bialix at ukr.net-20080125181906-hnbj8fkesuxz94bc
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2008-01-25 19:59:40 +0000
message:
  (bialix) new formatting of `bzr plugins` output.
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
  bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
    ------------------------------------------------------------
    revno: 3193.2.4
    revision-id:bialix at ukr.net-20080125181906-hnbj8fkesuxz94bc
    parent: bialix at ukr.net-20080121233447-2iw2a1jcj0gs1f9f
    parent: pqm at pqm.ubuntu.com-20080124050323-gsgsp2em7v1ugtnz
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: plugins.output
    timestamp: Fri 2008-01-25 20:19:06 +0200
    message:
      merge bzr.dev
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
      bzrlib/commands.py             bzr.py-20050309040720-d10f4714595cf8c3
      bzrlib/debug.py                debug.py-20061102062349-vdhrw9qdpck8cl35-1
      bzrlib/doc/api/__init__.py     __init__.py-20051224020744-7b87d590843855bc
      bzrlib/help_topics/__init__.py help_topics.py-20060920210027-rnim90q9e0bwxvy4-1
      bzrlib/reconfigure.py          reconfigure.py-20070908040425-6ykgo7escxhyrg9p-1
      bzrlib/smart/client.py         client.py-20061116014825-2k6ada6xgulslami-1
      bzrlib/smart/medium.py         medium.py-20061103051856-rgu2huy59fkz902q-1
      bzrlib/smart/protocol.py       protocol.py-20061108035435-ot0lstk2590yqhzr-1
      bzrlib/tests/__init__.py       selftest.py-20050531073622-8d0e3c8845c97a64
      bzrlib/tests/blackbox/test_selftest.py test_selftest.py-20060123024542-01c5f1bbcb596d78
      bzrlib/tests/test_osutils.py   test_osutils.py-20051201224856-e48ee24c12182989
      bzrlib/tests/test_reconfigure.py test_reconfigure.py-20070908040425-6ykgo7escxhyrg9p-2
      bzrlib/tests/test_remote.py    test_remote.py-20060720103555-yeeg2x51vn0rbtdp-2
      bzrlib/tests/test_selftest.py  test_selftest.py-20051202044319-c110a115d8c0456a
      bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
      bzrlib/tests/test_trace.py     testtrace.py-20051110225523-a21117fc7a07eeff
      bzrlib/trace.py                trace.py-20050309040759-c8ed824bdcd4748a
    ------------------------------------------------------------
    revno: 3193.2.3
    revision-id:bialix at ukr.net-20080121233447-2iw2a1jcj0gs1f9f
    parent: bialix at ukr.net-20080121110518-6i2xovfoqjjh75nr
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: plugins.output
    timestamp: Tue 2008-01-22 01:34:47 +0200
    message:
      another formatting variant suggested by John Meinel.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3193.2.2
    revision-id:bialix at ukr.net-20080121110518-6i2xovfoqjjh75nr
    parent: bialix at ukr.net-20080121104632-ipdnpm6z4k5piv3q
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: plugins.output
    timestamp: Mon 2008-01-21 13:05:18 +0200
    message:
      new formatting of `bzr plugins` output.
    modified:
      bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
    ------------------------------------------------------------
    revno: 3193.2.1
    revision-id:bialix at ukr.net-20080121104632-ipdnpm6z4k5piv3q
    parent: pqm at pqm.ubuntu.com-20080118055224-sskoia4bcpxd8wzu
    committer: Alexander Belchenko <bialix at ukr.net>
    branch nick: plugins.output
    timestamp: Mon 2008-01-21 12:46:32 +0200
    message:
      show path to plugin module as *.py instead of *.pyc if python source available
      
      (e.g. C:\bzr.dev\bzrlib\plugins\multiparent.py)
    modified:
      bzrlib/plugin.py               plugin.py-20050622060424-829b654519533d69
      bzrlib/tests/test_plugins.py   plugins.py-20050622075746-32002b55e5e943e9
=== modified file 'NEWS'
--- a/NEWS	2008-01-23 16:25:18 +0000
+++ b/NEWS	2008-01-25 18:19:06 +0000
@@ -12,13 +12,17 @@
     * Fetching via bzr+ssh will no longer fill ghosts by default (this is
       consistent with pack-0.92 fetching over SFTP). (Robert Collins)
 
-   * ``merge`` now prefers to use the submit branch, but will fall back to
-     parent branch.  For many users, this has no effect.  But some users who
-     pull and merge on the same branch will notice a change.  This change
-     makes it easier to work on a branch on two different machines, pulling
-     between the machines, while merging from the upstream.
-     ``merge --remember`` can now be used to set the submit_branch.
-     (Aaron Bentley)
+    * Formatting of ``bzr plugins`` output is changed to be more human-
+      friendly. Full path of plugins locations will be shown only with
+      ``--verbose`` command-line option. (Alexander Belchenko)
+
+    * ``merge`` now prefers to use the submit branch, but will fall back to
+      parent branch.  For many users, this has no effect.  But some users who
+      pull and merge on the same branch will notice a change.  This change
+      makes it easier to work on a branch on two different machines, pulling
+      between the machines, while merging from the upstream.
+      ``merge --remember`` can now be used to set the submit_branch.
+      (Aaron Bentley)
 
   FEATURES:
 

=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2008-01-23 16:25:18 +0000
+++ b/bzrlib/builtins.py	2008-01-25 18:19:06 +0000
@@ -3345,8 +3345,10 @@
 class cmd_plugins(Command):
     """List the installed plugins.
     
-    This command displays the list of installed plugins including the
-    path where each one is located and a short description of each.
+    This command displays the list of installed plugins including
+    version of plugin and a short description of each.
+
+    --verbose shows the path where each plugin is located.
 
     A plugin is an external component for Bazaar that extends the
     revision control system, by adding or replacing code in Bazaar.
@@ -3359,16 +3361,30 @@
     install them. Instructions are also provided there on how to
     write new plugins using the Python programming language.
     """
+    takes_options = ['verbose']
 
     @display_command
-    def run(self):
+    def run(self, verbose=False):
         import bzrlib.plugin
         from inspect import getdoc
+        result = []
         for name, plugin in bzrlib.plugin.plugins().items():
-            print plugin.path(), "[%s]" % plugin.__version__
+            version = plugin.__version__
+            if version == 'unknown':
+                version = ''
+            name_ver = '%s %s' % (name, version)
             d = getdoc(plugin.module)
             if d:
-                print '\t', d.split('\n')[0]
+                doc = d.split('\n')[0]
+            else:
+                doc = '(no description)'
+            result.append((name_ver, doc, plugin.path()))
+        for name_ver, doc, path in sorted(result):
+            print name_ver
+            print '   ', doc
+            if verbose:
+                print '   ', path
+            print
 
 
 class cmd_testament(Command):

=== modified file 'bzrlib/plugin.py'
--- a/bzrlib/plugin.py	2007-11-23 12:01:44 +0000
+++ b/bzrlib/plugin.py	2008-01-21 10:46:32 +0000
@@ -390,7 +390,12 @@
         if getattr(self.module, '__path__', None) is not None:
             return os.path.abspath(self.module.__path__[0])
         elif getattr(self.module, '__file__', None) is not None:
-            return os.path.abspath(self.module.__file__)
+            path = os.path.abspath(self.module.__file__)
+            if path[-4:] in ('.pyc', '.pyo'):
+                pypath = path[:-4] + '.py'
+                if os.path.isfile(pypath):
+                    path = pypath
+            return path
         else:
             return repr(self.module)
 

=== modified file 'bzrlib/tests/test_plugins.py'
--- a/bzrlib/tests/test_plugins.py	2007-11-13 01:49:34 +0000
+++ b/bzrlib/tests/test_plugins.py	2008-01-21 10:46:32 +0000
@@ -273,6 +273,28 @@
         plugin_path = self.test_dir + '/plugin.py'
         self.assertIsSameRealPath(plugin_path, normpath(plugin.path()))
 
+    def test_plugin_get_path_py_not_pyc(self):
+        self.setup_plugin()         # after first import there will be plugin.pyc
+        self.teardown_plugin()
+        bzrlib.plugin.load_from_path(['.']) # import plugin.pyc
+        plugins = bzrlib.plugin.plugins()
+        plugin = plugins['plugin']
+        plugin_path = self.test_dir + '/plugin.py'
+        self.assertIsSameRealPath(plugin_path, normpath(plugin.path()))
+
+    def test_plugin_get_path_pyc_only(self):
+        self.setup_plugin()         # after first import there will be plugin.pyc
+        self.teardown_plugin()
+        os.unlink(self.test_dir + '/plugin.py')
+        bzrlib.plugin.load_from_path(['.']) # import plugin.pyc
+        plugins = bzrlib.plugin.plugins()
+        plugin = plugins['plugin']
+        if __debug__:
+            plugin_path = self.test_dir + '/plugin.pyc'
+        else:
+            plugin_path = self.test_dir + '/plugin.pyo'
+        self.assertIsSameRealPath(plugin_path, normpath(plugin.path()))
+
     def test_no_test_suite_gives_None_for_test_suite(self):
         self.setup_plugin()
         plugin = bzrlib.plugin.plugins()['plugin']




More information about the bazaar-commits mailing list