Shelves in Tortoise and Mercurial command line don't seem to interoperate?

409 Views Asked by At

If I add something to a Mercurial shelf on the command line:

C:> hg shelve ...

when I then look in TortoiseHG Workbench under the Repository > Shelve > menu, there is NO new corresponding entry (in the dropdown).

Likewise, if I do the opposite and perform a shelving operation in THG, and then run hg shelve -l or just hg unshelve on the command line, it seems to ignore the new shelf.

Why is this happening? Is there a setting or something like that which is affecting this?

2

There are 2 best solutions below

0
On

To add to the existing answer, here is a config to add a context command to shelve selected files from the commit UI:

[tortoisehg]
...
workbench.commit.custom-menu = HG_shelve_selected

[tortoisehg-tools]
...
HG_shelve_selected.command = hg shelve {SELECTEDFILES}
HG_shelve_selected.enable = istrue
HG_shelve_selected.icon = thg-shelve-move-right-file
HG_shelve_selected.label = hg shelve
HG_shelve_selected.showoutput = False
HG_shelve_selected.tooltip = hg shelve

There is still no clean way (that I know of) to unshelve individual files.

0
On

The shelving features in 'core' Mercurial (command line hg) and the TortoiseHG GUI are totally independent of each other, as far as I am aware.

(Historically, this strange-seeming situation resulted from, I believe, the THG feature being created first before an equivalent / similar feature with the same name was later added to HG proper).


IMO the HG shelving feature works better than the THG feature from the standpoint of efficiently using HG merge logic to apply shelved changes to the local working folder during an unshelve operation. Once I realized that, I never use the THG shelf any longer, and that is what I recommend.


It is possible to configure THG Workbench to integrate (to a certain extent) with the HG shelving feature. Instructions:

Edit your mercurial.ini settings file. (Either through File > Settings > Gobal Settings > Edit File button, OR open the file in an editor manually).

Add the following sections & items:

[tortoisehg]
...
workbench.custom-toolbar = HG_shelve HG_unshelve

and

[tortoisehg-tools]
HG_shelve.command = hg shelve
HG_shelve.enable = istrue
HG_shelve.icon = go-next
HG_shelve.label = HG_shelve
HG_shelve.showoutput = True
HG_shelve.tooltip = HG_shelve
HG_unshelve.command = hg unshelve
HG_unshelve.enable = istrue
HG_unshelve.icon = go-previous
HG_unshelve.label = HG_unshelve
HG_unshelve.showoutput = True
HG_unshelve.tooltip = HG_unshelve

(careful not to duplicate any existing [tortoisehg] or [tortoisehg-tools] sections).

This will yield new buttons on the toolbar:

enter image description here

One arrow will shelve the current working folder, the other will unshelve.

Obviously running shelve/unshelve this way is rather coarse-grained but I find that 99% of the time that's all I need.


Notes:

The .INI edits above can also be done through the THG Workbench File > Settings > Tools GUI section.: enter image description here

You don't have to use these particular icons if you prefer something else, THG has other choices.