bzr shelve some files that are being worked on - bazaar

Lets say I have 6 files that I'm working on and I only want to shelve 3 of the 6
Is this correct bzr shelve file1.txt file2.txt file5.txt -m "this is the thing"
How do I unshelve it later?
How do I delete the shelve if I do not need it?

Is this correct bzr shelve file1.txt file2.txt file5.txt -m "this is the thing"
Yes, that's correct. It will shelve the changes to the specified files and directories only. Furthermore:
If there are no changes in those, it will do nothing, just tell you No changes to shelve.
To skip the interactive questions for every change in those files, the --all flag is convenient, for example: bzr shelve file1.txt file2.txt file5.txt -m "this is the thing" --all
How do I unshelve it later?
Find the id of the shelf with bzr shelve --list. Then unshelve with bzr unshelve THE_ID. Btw, if you don't specify an id, then bzr unshelve will unshelve the most recent shelf.
How do I delete the shelve if I do not need it?
Using the --delete-only flag of bzr unshelve, for example:
bzr unshelve --delete-only THE_ID

Related

See files affected by previous commits in bzr

When using bazaar you can easily see uncommited changes with the bzr diff command. You can also see changes since a specific revision, or use bzr status to see the filenames only.
bzr diff -c 2169
bzr status -c 2169
Instead of looking for a specific commit number, using bzr log is there a simple way to look at all changes in a number of commits, the previous 2 commits for example?
You can view log of the previous 2 commits like this:
bzr log -l2
You can view all the logs from a specific revision until the end with:
bzr log -r2169..
You can of course specify an end range as well.
You might also find useful some interesting revision specifiers for example last:N. You can view the diff or status of the last 2 revisions with:
bzr diff -rlast:3
bzr status -rlast:3
You can read more about revision specifiers in bzr help revisionspec.
Let me know if you were looking for something else.
You can do this using verbose. With --verbose (-v), bzr log will print all affected paths.
To get the files affected only in last commit, use
bzr log --verbose -l1
To get the files affected is level of commits, use
bzr log --verbose -l<level-of-commit>
To get the files affected in specific commit
bzr log --verbose -r<rev-of-commit>
you can use either flag --verbose or --v

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
Can I name that shelve set as I see it gets an ID? eg bzr shelve "this is my first attempt"
how do I view all shelve sets?
How do I view specific changes to a specific shelve set
Are shelve sets relative to the repository that I am in?
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.

How to undo bzr mv --auto

After doing a bzr mv --auto a deleted file and a new file have been incorrectly picked up as a moved file, and now show up as renamed under bzr status. How can I change this so that the new file is marked as new again (and the deleted as deleted)?
Given:
$ bzr status
renamed:
a => b
you would need to do:
$ bzr mv b a
b => a
~$ mv a b
$ bzr add b
adding b
$ bzr status
removed:
a
added:
b
You can do a simple revert on the file.
Note that this will revert the rename, but also the modification you made inside, so be careful !

Converting bzr's triple revision numbers

bzr annotate gives revision numbers of the form a.b.c where a is the revision that was branched off; for our workflow it's more interesting to know in which revision this changed was merged back into the current repo. Can I get bzr to tell me this info?
You can use revision prefix mainline:, see bzr help revisionspec for details.
For example,
bzr revno -r 1.2.3
prints 1.2.3, but
bzr revno -r mainline:1.2.3
prints revision number for revision that merged 1.2.3.

How to undo bzr add

Sometimes I type bzr add and don't notice that I am not in the root of the branch but an ignored sub-folder. This then adds all files in that folders - often it is a build folder, with lots of files. Hence the question: how to undo a bzr add.
There is built-in way without need of xargs: bzr remove --new --keep
This answer is shamelessly stolen from here to make it more accessible (to me as well).
This will undo an erroneous bzr add:
bzr added -0 | xargs -0 bzr rm --keep