Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > 3ad95df1b9ec0c823807557dbacf5694 > files > 639

bzr-doc-2.2.4-1.fc14.noarch.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>Exporting version information &mdash; Bazaar v2.2.4 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.2.4',
        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 v2.2.4 documentation" href="../index.html" />
    <link rel="up" title="Bazaar User Guide" href="index.html" />
    <link rel="next" title="BzrTools" href="bzrtools_plugin.html" />
    <link rel="prev" title="Using hooks" href="hooks.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="bzrtools_plugin.html" title="BzrTools"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="hooks.html" title="Using hooks"
             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.2.4)</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="exporting-version-information">
<h1>Exporting version information<a class="headerlink" href="#exporting-version-information" title="Permalink to this headline">¶</a></h1>
<div class="section" id="getting-the-last-revision-number">
<h2>Getting the last revision number<a class="headerlink" href="#getting-the-last-revision-number" title="Permalink to this headline">¶</a></h2>
<p>If you only need the last revision number in your build scripts, you can
use the <tt class="docutils literal"><span class="pre">revno</span></tt> command to get that value like this:</p>
<div class="highlight-python"><pre>$ bzr revno
3104</pre>
</div>
</div>
<div class="section" id="getting-more-version-information">
<h2>Getting more version information<a class="headerlink" href="#getting-more-version-information" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">version-info</span></tt> command can be used to output more information
about the latest version like this:</p>
<div class="highlight-python"><pre>$ bzr version-info
revision-id: pqm@pqm.ubuntu.com-20071211175118-s94sizduj201hrs5
date: 2007-12-11 17:51:18 +0000
build-date: 2007-12-13 13:14:51 +1000
revno: 3104
branch-nick: bzr.dev</pre>
</div>
<p>You can easily filter that output using operating system tools or
scripts. For example:</p>
<div class="highlight-python"><pre>$ bzr version-info | grep ^date
date: 2007-12-11 17:51:18 +0000</pre>
</div>
<p>The <tt class="docutils literal"><span class="pre">--all</span></tt> option will actually dump version information about
every revision if you need that information for more advanced
post-processing.</p>
</div>
<div class="section" id="python-projects">
<h2>Python projects<a class="headerlink" href="#python-projects" title="Permalink to this headline">¶</a></h2>
<p>If using a Makefile to build your project, you can generate the version
information file as simply as:</p>
<div class="highlight-python"><pre>library/_version.py:
      bzr version-info --format python &gt; library/_version.py</pre>
</div>
<p>This generates a file which contains 3 dictionaries:</p>
<blockquote>
<div><ul class="simple">
<li><cite>version_info</cite>: A dictionary containing the basic information about the
current state.</li>
<li><cite>revisions</cite>: A dictionary listing all of the revisions in the
history of the tree, along with the commit times and commit
message.  This defaults to being empty unless <tt class="docutils literal"><span class="pre">--all</span></tt> or
<tt class="docutils literal"><span class="pre">--include-history</span></tt> is supplied. This is useful if you want to
track what bug fixes, etc, might be included in the released
version. But for many projects it is more information than needed.</li>
<li><cite>file_revisions</cite>: A dictionary listing the last-modified revision
for all files in the project. This can be used similarly to how
<tt class="docutils literal"><span class="pre">$Id$</span></tt> keywords are used in CVS-controlled files. The last
modified date can be determined by looking in the <tt class="docutils literal"><span class="pre">revisions</span></tt>
map. This is also empty by default, and enabled only by <tt class="docutils literal"><span class="pre">--all</span></tt>
or <tt class="docutils literal"><span class="pre">--include-file-revisions</span></tt>.</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="getting-version-info-in-other-formats">
<h2>Getting version info in other formats<a class="headerlink" href="#getting-version-info-in-other-formats" title="Permalink to this headline">¶</a></h2>
<p>Bazaar supports a template-based method for getting version information in
arbitrary formats.  The <tt class="docutils literal"><span class="pre">--custom</span></tt> option to <tt class="docutils literal"><span class="pre">version-info</span></tt> can be
used by providing a <tt class="docutils literal"><span class="pre">--template</span></tt> argument that contains variables that
will be expanded based on the status of the working tree.  For example, to
generate a C header file with a formatted string containing the current
revision number:</p>
<div class="highlight-python"><pre>bzr version-info --custom \
     --template="#define VERSION_INFO \"Project 1.2.3 (r{revno})\"\n" \
     &gt; version_info.h</pre>
</div>
<p>where the <tt class="docutils literal"><span class="pre">{revno}</span></tt> will be replaced by the revision number of the
working tree.  (If the example above doesn&#8217;t work on your OS, try
entering the command all on one line.) For more information on the
variables that can be used in templates, see <a class="reference external" href="../user-reference/index.html#version-info">Version Info</a> in the
Bazaar User Reference.</p>
<p>Predefined formats for dumping version information in specific languages
are currently in development. Please contact us on the mailing list about
your requirements in this area.</p>
</div>
<div class="section" id="check-clean">
<h2>Check clean<a class="headerlink" href="#check-clean" title="Permalink to this headline">¶</a></h2>
<p>Most information about the contents of the project can be cheaply
determined by just reading the revision entry. However, it can be useful
to know if the working tree was completely up-to-date when it was
packaged, or if there was a local modification. By supplying either
<tt class="docutils literal"><span class="pre">--all</span></tt> or <tt class="docutils literal"><span class="pre">--check-clean</span></tt>, <tt class="docutils literal"><span class="pre">bzr</span></tt> will inspect the working tree, and
set the <tt class="docutils literal"><span class="pre">clean</span></tt> flag in <tt class="docutils literal"><span class="pre">version_info</span></tt>, as well as set entries in
<tt class="docutils literal"><span class="pre">file_revisions</span></tt> as <tt class="docutils literal"><span class="pre">modified</span></tt> where appropriate.</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="#">Exporting version information</a><ul>
<li><a class="reference internal" href="#getting-the-last-revision-number">Getting the last revision number</a></li>
<li><a class="reference internal" href="#getting-more-version-information">Getting more version information</a></li>
<li><a class="reference internal" href="#python-projects">Python projects</a></li>
<li><a class="reference internal" href="#getting-version-info-in-other-formats">Getting version info in other formats</a></li>
<li><a class="reference internal" href="#check-clean">Check clean</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="hooks.html"
                        title="previous chapter">Using hooks</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="bzrtools_plugin.html"
                        title="next chapter">BzrTools</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/user-guide/version_info.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" size="18" />
      <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="bzrtools_plugin.html" title="BzrTools"
             >next</a></li>
        <li class="right" >
          <a href="hooks.html" title="Using hooks"
             >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.2.4)</a> &raquo;</li>

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