Tom's Blog

From tech to non-tech

Mercurial Shelve Extension for the Lazy

| Comments

Have you ever been in this situation that that you want to hg pull some changes but you have uncommited changes and you don’t want to commit the local changes yet? I know I have and I’ve usually caved in and just modified my code to a state that I can commit my local changes and then pull.

Yesterday I was lazy enough to look up the Shelve Extension which comes bundled now with the 2.8 release of Mercurial. The idea is fairly simple. When you have uncommited changes you put them on a shelf, hence the name shelve. Here is what the workflow looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
toomasr@cigarillo ~/project » hg pull
abort: outstanding uncommitted changes

toomasr@cigarillo ~/project » hg shelve
shelved as default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

toomasr@cigarillo ~/project » hg pull
pulling from ssh://hg@bitbucket.org/zeroturnaround/project
searching for changes
adding changesets
adding manifests
adding file changes
added 42 changesets with 457 changes to 152 files (-1 heads)
13 files updated, 0 files merged, 0 files removed, 0 files unresolved

toomasr@cigarillo ~/project » hg unshelve
unshelving change 'default'
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 2 files (+1 heads)

So I was able to shelve away my local changes, run the pull and update and unshelve my changes! Go enable the extension in your ~/.hgrc and start shelving.

1
2
[extensions]
shelve=

For more features go check out the Shelve Extension page!

Comments