Search code examples
repositorybazaar

bzr how to shelve?


according to the documentation I have questions http://doc.bazaar.canonical.com/beta/en/user-reference/shelve-help.html

I can shelve by going bzr shelve

  1. Can I name that shelve set as I see it gets an ID? eg bzr shelve "this is my first attempt"
  2. how do I view all shelve sets?
  3. How do I view specific changes to a specific shelve set
  4. Are shelve sets relative to the repository that I am in?

Solution

  • First, let's create a shared repository and grab a sample branch to play with:

    $ bzr init-repo /tmp/shared-repo
    Shared repository with trees (format: 2a)
    Location:
      shared repository: /tmp/shared-repo
    $ cd /tmp/shared-repo
    $ bzr branch lp:~bzrbook/bzrbook-examples/shelving
    Branched 6 revisions.
    $ cd shelving
    

    Your questions:

    Can I name that shelve set as I see it gets an ID? eg bzr shelve "this is my first attempt"

    Yes, using the -m flag, for example:

    $ date >> menu.txt
    $ bzr shelve -m 'menu change' --all
    Selected changes:
     M  menu.txt
    Changes shelved with id "1".
    

    how do I view all shelve sets?

    Using the --list flag, for example:

    $ bzr shelve --list
      1: menu change
    

    Now you can see that giving a name to the shelf worked. If we hadn't given a name:

    $ bzr rm guests.txt
    deleted guests.txt
    $ bzr shelve --all
    Selected changes:
    +N  guests.txt
    Changes shelved with id "2".
    $ bzr shelve --list
      2: <no message>
      1: menu change
    

    Btw, when you have shelves, the bzr status command tells you about them, and how to list:

    $ bzr st
    2 shelves exist. See "bzr shelve --list" for details.
    

    How do I view specific changes to a specific shelve set

    Using bzr unshelve --preview, for example:

    $ bzr unshelve --preview 1
    Using changes with id "1".
    Message: menu change
     M  menu.txt
    === modified file 'menu.txt'
    --- a/menu.txt  2014-04-11 05:34:17 +0000
    +++ b/menu.txt  2014-04-11 05:37:55 +0000
    @@ -16,3 +16,4 @@
     Mixed burrito
     Onion soup
     Tacoz
    +Fri Apr 11 07:34:13 CEST 2014
    

    Are shelve sets relative to the repository that I am in?

    Shelve sets are saved in your working tree. They are not part of the repository, in other words they are not version controlled. If you delete the working directory of the branch where you created your shelves, they will be lost. This is mentioned in the first paragraph of the Description in bzr shelve -h and the link you included.