Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > 27647990744ebd9cfe32398f37f67e20 > files > 3057

bzr-2.6.0-11.1.mga5.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Writing a plugin &mdash; Bazaar 2.6.0 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.6.0',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/bzr.ico"/>
    <link rel="top" title="Bazaar 2.6.0 documentation" href="../index.html" />
    <link rel="up" title="Bazaar User Guide" href="index.html" />
    <link rel="next" title="Licence" href="licence.html" />
    <link rel="prev" title="Serving Bazaar with Apache" href="http_smart_server.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="licence.html" title="Licence"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="http_smart_server.html" title="Serving Bazaar with Apache"
             accesskey="P">previous</a> |</li>
<li><a href="http://bazaar.canonical.com/">
    <img src="../_static/bzr icon 16.png" /> Home</a>&nbsp;|&nbsp;</li>
<a href="http://doc.bazaar.canonical.com/en/">Documentation</a>&nbsp;|&nbsp;</li>

        <li><a href="../index.html">Table of Contents (2.6.0)</a> &raquo;</li>

          <li><a href="index.html" accesskey="U">Bazaar User Guide</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="writing-a-plugin">
<h1>Writing a plugin<a class="headerlink" href="#writing-a-plugin" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>Plugins are very similar to bzr core functionality.  They can import
anything in bzrlib.  A plugin may simply override standard functionality,
but most plugins supply new commands.</p>
</div>
<div class="section" id="creating-a-new-command">
<h2>Creating a new command<a class="headerlink" href="#creating-a-new-command" title="Permalink to this headline">¶</a></h2>
<p>To create a command, make a new object that derives from
<tt class="docutils literal"><span class="pre">bzrlib.commands.Command</span></tt>, and name it <tt class="docutils literal"><span class="pre">cmd_foo</span></tt>, where foo is the name of
your command.  If you create a command whose name contains an underscore,
it will appear in the UI with the underscore turned into a hyphen.  For
example, <cite>cmd_baz_import</cite> will appear as <cite>baz-import</cite>.  For examples of how
to write commands, please see <tt class="docutils literal"><span class="pre">builtins.py</span></tt>.</p>
<p>Once you&#8217;ve created a command you must register the command with
<tt class="docutils literal"><span class="pre">bzrlib.commands.register_command(cmd_foo)</span></tt>.  You must register the
command when your file is imported, otherwise bzr will not see it.</p>
</div>
<div class="section" id="installing-a-hook">
<h2>Installing a hook<a class="headerlink" href="#installing-a-hook" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference external" href="hooks.txt">Using hooks</a>.</p>
<blockquote>
<div></div></blockquote>
</div>
<div class="section" id="specifying-a-plugin-version-number">
<h2>Specifying a plugin version number<a class="headerlink" href="#specifying-a-plugin-version-number" title="Permalink to this headline">¶</a></h2>
<p>Simply define <tt class="docutils literal"><span class="pre">version_info</span></tt> to be a tuple defining the current version
number of your plugin. eg.
<tt class="docutils literal"><span class="pre">version_info</span> <span class="pre">=</span> <span class="pre">(0,</span> <span class="pre">9,</span> <span class="pre">0)</span></tt>
<tt class="docutils literal"><span class="pre">version_info</span> <span class="pre">=</span> <span class="pre">(0,</span> <span class="pre">9,</span> <span class="pre">0,</span> <span class="pre">'dev',</span> <span class="pre">0)</span></tt></p>
</div>
<div class="section" id="plugin-searching-rules">
<h2>Plugin searching rules<a class="headerlink" href="#plugin-searching-rules" title="Permalink to this headline">¶</a></h2>
<p>Bzr will scan <tt class="docutils literal"><span class="pre">~/.bazaar/plugins</span></tt>  and <tt class="docutils literal"><span class="pre">bzrlib/plugins</span></tt> for plugins
by default.  You can override this with  <tt class="docutils literal"><span class="pre">BZR_PLUGIN_PATH</span></tt>
(see <a class="reference external" href="../user-reference/configuration-help.html#bzr-plugin-path">User Reference</a> for details).</p>
<p>Plugins may be either modules or packages.  If your plugin is a single
file, you can structure it as a module.  If it has multiple files, or if
you want to distribute it as a bzr branch, you should structure it as a
package, i.e. a directory with an <tt class="docutils literal"><span class="pre">__init__.py</span></tt> file.</p>
</div>
<div class="section" id="more-information">
<h2>More information<a class="headerlink" href="#more-information" title="Permalink to this headline">¶</a></h2>
<p>Please feel free to contribute your plugin to BzrTools, if you think it
would be useful to other people.</p>
<p>See the <a class="reference external" href="../developer-guide/HACKING.html">Bazaar Developer Guide</a> for details on Bazaar&#8217;s development
guidelines and policies.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Writing a plugin</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#creating-a-new-command">Creating a new command</a></li>
<li><a class="reference internal" href="#installing-a-hook">Installing a hook</a></li>
<li><a class="reference internal" href="#specifying-a-plugin-version-number">Specifying a plugin version number</a></li>
<li><a class="reference internal" href="#plugin-searching-rules">Plugin searching rules</a></li>
<li><a class="reference internal" href="#more-information">More information</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="http_smart_server.html"
                        title="previous chapter">Serving Bazaar with Apache</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="licence.html"
                        title="next chapter">Licence</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/user-guide/writing_a_plugin.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="licence.html" title="Licence"
             >next</a></li>
        <li class="right" >
          <a href="http_smart_server.html" title="Serving Bazaar with Apache"
             >previous</a> |</li>
<li><a href="http://bazaar.canonical.com/">
    <img src="../_static/bzr icon 16.png" /> Home</a>&nbsp;|&nbsp;</li>
<a href="http://doc.bazaar.canonical.com/en/">Documentation</a>&nbsp;|&nbsp;</li>

        <li><a href="../index.html">Table of Contents (2.6.0)</a> &raquo;</li>

          <li><a href="index.html" >Bazaar User Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2011 Canonical Ltd.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>