[Extension] Dirty hack of 'shelve' and 'unshelve' command

Michael Ellerman michael at ellerman.id.au
Thu May 19 07:52:43 BST 2005

Hi All,

I'm a big nut fan of Darc's support for partial commits. If you've never used 
it, it allows you to choose which hunks of the diff you want to commit - how 

However it has one drawback, which is that it allows you to commit to history 
tree states that never actually existed in your working tree/repository. 
Usually that's exactly why you use it, but it can lead to embarassing errors, 
like if you forget to check in a new file but *do* check in the change to the 
Makefile that references it.

So I thought I'd try a different interface to solve basically the same 
problem. And so we have the 'shelve' and 'unshelve' commands.

I know the names a bit dicky, I thought of 'postpone' and 'reinstate' or 
something, but 'shelve' and 'unshelve' are at least obviously symetrical.

Basically you can run 'bzr shelve' and it will prompt you which hunks you want 
to 'place on the shelf', ie. put away for the moment. You can then make sure 
your tree still builds, run any tests, and then use the regular 'bzr commit'.

You can the unshelve the hunks on your shelf, and repeat. You end up with more 
or less the same end result as partial commit, but with less chance of error.

I haven't really used this much yet, so I don't know if I like it. And the 
implementation is very hacky at the moment, it's just a proof of concept.

I stole Aaron's code for parsing patches, which I think was part of his 
annotate patch, and munged it a bit. Thanks Aaron.

Stick the attached files in a directory and put that in your $BZRPATH, then yo 
u should be able to run 'shelve' and 'unshelve'.

Bug reports welcome, although I'm really just throwing this over the wall to 
see if anyone thinks it's a good way of doing this. Let me know.


Michael Ellerman
IBM OzLabs

email: michael:ellerman.id.au
inmsg: mpe:jabber.org
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patches.py
Type: application/x-python
Size: 9421 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050519/04b5827f/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shelf.py
Type: application/x-python
Size: 3107 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050519/04b5827f/attachment-0001.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unshelve
Type: application/x-python
Size: 246 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050519/04b5827f/attachment-0002.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shelve
Type: application/x-python
Size: 244 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050519/04b5827f/attachment-0003.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050519/04b5827f/attachment.pgp 

More information about the bazaar mailing list