/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6538.1.32 by Aaron Bentley
Add docs on switch --store.
1
Switch --store
2
==============
3
4
In workflows that a single working tree, like co-located branches, sometimes
6538.1.33 by Aaron Bentley
Tweak docs.
5
you want to switch while you have uncommitted changes.  By default, ``switch``
6
will apply your uncommitted changes to the new branch that you switch to.  But
7
often you don't want that.  You just want to do some work in the other branch,
8
and eventually return to this branch and work some more.
9
6622.1.24 by Jelmer Vernooij
More doc renames.
10
You could run ``brz shelve --all`` before switching, to store the changes
6538.1.33 by Aaron Bentley
Tweak docs.
11
safely.  So you have to know that there are uncommitted changes present, and
6622.1.24 by Jelmer Vernooij
More doc renames.
12
you have to remember to run ``brz shelve --all``.  Then when you switch back to
6538.1.33 by Aaron Bentley
Tweak docs.
13
the branch, you need to remember to unshelve the changes, and you need to know
14
what their shelf-id was.
15
16
Using ``switch --store`` takes care of all of this for you.  If there are any
17
uncommitted changes in your tree, it stores them in your branch.  It then
18
restores any uncommitted changes that were stored in the branch of your target
19
tree.  It's almost like having two working trees and using ``cd`` to switch
20
between them.
6538.1.32 by Aaron Bentley
Add docs on switch --store.
21
22
To take an example, first we'd set up a co-located branch::
23
6622.1.24 by Jelmer Vernooij
More doc renames.
24
  $ brz init foo
6538.1.32 by Aaron Bentley
Add docs on switch --store.
25
  Created a standalone tree (format: 2a)
26
  $ cd foo
6622.1.24 by Jelmer Vernooij
More doc renames.
27
  $ brz switch -b foo
6538.1.32 by Aaron Bentley
Add docs on switch --store.
28
29
Now create committed and uncommitted changes::
30
31
  $ touch committed
6622.1.24 by Jelmer Vernooij
More doc renames.
32
  $ brz add
6538.1.32 by Aaron Bentley
Add docs on switch --store.
33
  adding committed
6622.1.24 by Jelmer Vernooij
More doc renames.
34
  $ brz commit -m "Add committed"
6538.1.32 by Aaron Bentley
Add docs on switch --store.
35
  Committing to: /home/abentley/sandbox/foo/
36
  added committed
37
  Committed revision 1.
38
  $ touch uncommitted
6622.1.24 by Jelmer Vernooij
More doc renames.
39
  $ brz add
6538.1.32 by Aaron Bentley
Add docs on switch --store.
40
  adding uncommitted
41
  $ ls
42
  committed  uncommitted
43
6538.1.33 by Aaron Bentley
Tweak docs.
44
Now create a new branch using ``--store``.  The uncommitted changes are stored
45
in "foo", but the committed changes are retained.
6538.1.32 by Aaron Bentley
Add docs on switch --store.
46
::
47
6622.1.24 by Jelmer Vernooij
More doc renames.
48
  $ brz switch -b --store bar
6538.1.32 by Aaron Bentley
Add docs on switch --store.
49
  Uncommitted changes stored in branch "foo".
50
  Tree is up to date at revision 1.
51
  Switched to branch: /home/abentley/sandbox/foo/
52
  abentley@speedy:~/sandbox/foo$ ls
53
  committed
54
55
Now, create uncommitted changes in "bar"::
56
57
  $ touch uncommitted-bar
6622.1.24 by Jelmer Vernooij
More doc renames.
58
  $ brz add
6538.1.32 by Aaron Bentley
Add docs on switch --store.
59
  adding uncommitted-bar
60
61
Finally, switch back to "foo"::
62
6622.1.24 by Jelmer Vernooij
More doc renames.
63
  $ brz switch --store foo
6538.1.32 by Aaron Bentley
Add docs on switch --store.
64
  Uncommitted changes stored in branch "bar".
65
  Tree is up to date at revision 1.
66
  Switched to branch: /home/abentley/sandbox/foo/
67
  $ ls
68
  committed  uncommitted
69
70
Each branch holds only one set of stored changes.  If you try to store a second
6538.1.33 by Aaron Bentley
Tweak docs.
71
set, you get an error.  If you use ``--store`` all the time, this can't happen.
6538.1.32 by Aaron Bentley
Add docs on switch --store.
72
But if you use plain switch, then it won't restore the uncommitted changes
73
already present::
74
6622.1.24 by Jelmer Vernooij
More doc renames.
75
  $ brz switch bar
6538.1.32 by Aaron Bentley
Add docs on switch --store.
76
  Tree is up to date at revision 1.
77
  Switched to branch: /home/abentley/sandbox/foo/
6622.1.24 by Jelmer Vernooij
More doc renames.
78
  $ brz switch --store foo
79
  brz: ERROR: Cannot store uncommitted changes because this branch already
6538.1.32 by Aaron Bentley
Add docs on switch --store.
80
  stores uncommitted changes.
81
82
If you're working in a branch that already has stored changes, you can restore
6622.1.24 by Jelmer Vernooij
More doc renames.
83
them with ``brz switch . --store``::
6538.1.32 by Aaron Bentley
Add docs on switch --store.
84
6622.1.24 by Jelmer Vernooij
More doc renames.
85
  $ brz shelve --all -m "Uncommitted changes from foo"
6538.1.32 by Aaron Bentley
Add docs on switch --store.
86
  Selected changes:
87
  -D  uncommitted
88
  Changes shelved with id "1".
6622.1.24 by Jelmer Vernooij
More doc renames.
89
  $ brz switch . --store
6538.1.32 by Aaron Bentley
Add docs on switch --store.
90
  Tree is up to date at revision 1.
91
  Switched to branch: /home/abentley/sandbox/foo/
92
  $ ls
93
  committed  uncommitted-bar