18

I am using Mercurial Shelve extension to shelve changes from command line. It works nice except when the changes that i like to shelve contain new added files(a) in working directory. Basically, it shelves everything except the new added files. I checked this by looking at the .hg/shelve stored changes.

How to shelve new added files (a status)?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
latvian
  • 3,161
  • 9
  • 33
  • 62

5 Answers5

13

This response is overdue, but you can use the following command to shelve all files (track / untrack) :

hg shelve -A

or

hg shelve --addremove

About this command, documentation says :

mark new/missing files as added/removed before shelving

You must pay attention by using this feature because after unshelving, your old untracked files are track. These file are already to be commited in the last commit if no files are specified in hg commit command. You should use hg forget if you want untracked them again.

Samuel Dauzon
  • 10,744
  • 13
  • 61
  • 94
  • Note that adding does not commit them! – noelicus Jun 20 '18 at 07:19
  • Yes, after hg shelve -A untracked files are tracked but not commited. They are already to be commited in the last commit if no files are specified in hg commit command. I complete my answer to be more specific. Thanks for comment :) – Samuel Dauzon Jun 20 '18 at 07:21
  • Thanks :) ... It's obvious, but normally I add files as part of the commit, so this point had kind of passed me by :S – noelicus Jun 20 '18 at 09:38
9

I assume you are talking about currently untracked files? You need to add the first.

So just do hg add for your new files and then hg shelve will also shelve them.

Chronial
  • 66,706
  • 14
  • 93
  • 99
4

Thank you Tom. I am using Mac, so it didn't really worked. What did work was another mercurial extension 'hgattic' about which you can read more in my blog

http://margotskapacs.com/2012/10/shelving-uncommitted-changes-in-mercurial/

(see section 'Bug – Added Files Unable Shelve')

latvian
  • 3,161
  • 9
  • 33
  • 62
0

If the command line isn't absolutely necessary:

then just type (on Linux)

thg shelve

This allows you to easily shelve added (but not yet committed) files.

Tom
  • 6,325
  • 4
  • 31
  • 55
0

As a mostly Git user, I find Atlassian SourceTree the easiest way to deal with the odd Mercurial repo that I have to work with. It has shelving built in. The price is right, too (free).

Disclaimer: I work for Atlassian

Andrew Swan
  • 13,427
  • 22
  • 69
  • 98