hg shelve equivalent of git stash drop
Asked Answered
C

4

41

I have the hg shelve (not attic) extension installed, and I want to drop a patch. In git it would be git stash drop. How do I do this using the shelve extension?

Cordovan answered 3/4, 2012 at 20:38 Comment(0)
C
26

The Mercurial shelve extension stores patches under .hg/shelved. Each is a simple patch file, and the filename is the name of the patch. So to remove a patch called 'mypatch' I can simply remove the file 'mypatch' from .hg/shelved:

rm .hg/shelved/mypatch

Cordovan answered 3/4, 2012 at 20:41 Comment(1)
See BennyMcBenBen's answer for a way to remove shelves using the hg shelve UI.Fendley
F
42

From the Mercurial shelve documentation (or using hg help shelve):

To delete specific shelved changes, use "--delete". To delete all shelved changes, use "--cleanup".

options:

-d --delete delete the named shelved change(s)

So if your patch was called my-patch, then you would delete it using:

hg shelve -d my-patch
Flyover answered 28/8, 2014 at 21:23 Comment(0)
M
32

If you don't want to use shelves, you can do it the following way.

hg diff > mylocalchanges.txt
hg revert -a
# Do your merge here, once you are done, import back your local mods
hg import --no-commit mylocalchanges.txt
Marylyn answered 1/5, 2012 at 19:22 Comment(1)
To avoid creation *.orig files use: hg revert -aCDulciana
C
26

The Mercurial shelve extension stores patches under .hg/shelved. Each is a simple patch file, and the filename is the name of the patch. So to remove a patch called 'mypatch' I can simply remove the file 'mypatch' from .hg/shelved:

rm .hg/shelved/mypatch

Cordovan answered 3/4, 2012 at 20:41 Comment(1)
See BennyMcBenBen's answer for a way to remove shelves using the hg shelve UI.Fendley
E
0

I created two shell scripts based on minaz's answer:

hgshelve

#!/bin/sh
hg diff > $1 && hg revert -a

hgunshelve

#!/bin/sh
hg import --no-commit $1 && trash $1

Put them in ~/bin. You need sudo apt-get install trash-cli for the trash command (or modify the script to either not remove the patch file, or use rm if you prefer).

Erythema answered 31/1, 2013 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.