Sophie

Sophie

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

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>Switch –store &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="Shelving Changes" href="shelving_changes.html" />
    <link rel="prev" title="Pseudo merging" href="adv_merging.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="shelving_changes.html" title="Shelving Changes"
             accesskey="N">next</a></li>
        <li class="right" >
          <a href="adv_merging.html" title="Pseudo merging"
             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="switch-store">
<h1>Switch &#8211;store<a class="headerlink" href="#switch-store" title="Permalink to this headline">¶</a></h1>
<p>In workflows that a single working tree, like co-located branches, sometimes
you want to switch while you have uncommitted changes.  By default, <tt class="docutils literal"><span class="pre">switch</span></tt>
will apply your uncommitted changes to the new branch that you switch to.  But
often you don&#8217;t want that.  You just want to do some work in the other branch,
and eventually return to this branch and work some more.</p>
<p>You could run <tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">shelve</span> <span class="pre">--all</span></tt> before switching, to store the changes
safely.  So you have to know that there are uncommitted changes present, and
you have to remember to run <tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">shelve</span> <span class="pre">--all</span></tt>.  Then when you switch back to
the branch, you need to remember to unshelve the changes, and you need to know
what their shelf-id was.</p>
<p>Using <tt class="docutils literal"><span class="pre">switch</span> <span class="pre">--store</span></tt> takes care of all of this for you.  If there are any
uncommitted changes in your tree, it stores them in your branch.  It then
restores any uncommitted changes that were stored in the branch of your target
tree.  It&#8217;s almost like having two working trees and using <tt class="docutils literal"><span class="pre">cd</span></tt> to switch
between them.</p>
<p>To take an example, first we&#8217;d set up a co-located branch:</p>
<div class="highlight-python"><div class="highlight"><pre>$ bzr init foo
Created a standalone tree (format: 2a)
$ cd foo
$ bzr switch -b foo
</pre></div>
</div>
<p>Now create committed and uncommitted changes:</p>
<div class="highlight-python"><div class="highlight"><pre>$ touch committed
$ bzr add
adding committed
$ bzr commit -m &quot;Add committed&quot;
Committing to: /home/abentley/sandbox/foo/
added committed
Committed revision 1.
$ touch uncommitted
$ bzr add
adding uncommitted
$ ls
committed  uncommitted
</pre></div>
</div>
<p>Now create a new branch using <tt class="docutils literal"><span class="pre">--store</span></tt>.  The uncommitted changes are stored
in &#8220;foo&#8221;, but the committed changes are retained.</p>
<div class="highlight-python"><div class="highlight"><pre>$ bzr switch -b --store bar
Uncommitted changes stored in branch &quot;foo&quot;.
Tree is up to date at revision 1.
Switched to branch: /home/abentley/sandbox/foo/
abentley@speedy:~/sandbox/foo$ ls
committed
</pre></div>
</div>
<p>Now, create uncommitted changes in &#8220;bar&#8221;:</p>
<div class="highlight-python"><div class="highlight"><pre>$ touch uncommitted-bar
$ bzr add
adding uncommitted-bar
</pre></div>
</div>
<p>Finally, switch back to &#8220;foo&#8221;:</p>
<div class="highlight-python"><div class="highlight"><pre>$ bzr switch --store foo
Uncommitted changes stored in branch &quot;bar&quot;.
Tree is up to date at revision 1.
Switched to branch: /home/abentley/sandbox/foo/
$ ls
committed  uncommitted
</pre></div>
</div>
<p>Each branch holds only one set of stored changes.  If you try to store a second
set, you get an error.  If you use <tt class="docutils literal"><span class="pre">--store</span></tt> all the time, this can&#8217;t happen.
But if you use plain switch, then it won&#8217;t restore the uncommitted changes
already present:</p>
<div class="highlight-python"><div class="highlight"><pre>$ bzr switch bar
Tree is up to date at revision 1.
Switched to branch: /home/abentley/sandbox/foo/
$ bzr switch --store foo
bzr: ERROR: Cannot store uncommitted changes because this branch already
stores uncommitted changes.
</pre></div>
</div>
<p>If you&#8217;re working in a branch that already has stored changes, you can restore
them with <tt class="docutils literal"><span class="pre">bzr</span> <span class="pre">switch</span> <span class="pre">.</span> <span class="pre">--store</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre>$ bzr shelve --all -m &quot;Uncommitted changes from foo&quot;
Selected changes:
-D  uncommitted
Changes shelved with id &quot;1&quot;.
$ bzr switch . --store
Tree is up to date at revision 1.
Switched to branch: /home/abentley/sandbox/foo/
$ ls
committed  uncommitted-bar
</pre></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="adv_merging.html"
                        title="previous chapter">Pseudo merging</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="shelving_changes.html"
                        title="next chapter">Shelving Changes</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/user-guide/switch_store.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="shelving_changes.html" title="Shelving Changes"
             >next</a></li>
        <li class="right" >
          <a href="adv_merging.html" title="Pseudo merging"
             >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>