3

I have some changed files I don't want to commit (e.g. web.config). Before I pull and update to new changesets, I have to shelve them. After the pull & update, I have to unshelve them.

I'm currently using TortoiseHG. Is there any extension which can do this automatically?

StayOnTarget
  • 7,829
  • 8
  • 42
  • 59
Jan-Patrick Ahnen
  • 1,230
  • 5
  • 17
  • 30
  • This is a common scenario for other kinds of files as well; VB6 project files (VBP) are notorious for being modified automatically by the IDE so that they become particular the the developer's PC; but you usually don't want to commit those changes. – StayOnTarget Dec 07 '18 at 14:42
  • @DaveInCaz Wouldn’t those be better handled by `.hgignore` then? – Daniel H May 21 '19 at 21:00
  • @DanielH no, because they are part of project and must be source controlled. And sometimes on a case-by-case basis you do need to commit changes to them., – StayOnTarget May 28 '21 at 16:27

4 Answers4

5

I'd suggest something else: instead of always shelving and unshelving, you could use two different config files: one which is part of the repository and contains dummy/example data, and another one which each user really uses locally, which is ignored by Mercurial.

Check out this answer for a more detailed explanation what I mean.
The example I'm giving there is for Visual Studio, and I see from your other questions and answers that you're apparently using .net and Visual Studio, so you can just use my example exactly as written.

Community
  • 1
  • 1
Christian Specht
  • 33,837
  • 14
  • 123
  • 176
  • That was a good solution. We keep web.config.default in the repository and we create locally a copy and name it web.config with any changes we need. – Jan-Patrick Ahnen Feb 16 '12 at 16:31
  • This is a good solution for the config file scenario in particular, but it may not be the best general solution to dealing with locally modified tracked files which should not be committed. – StayOnTarget Dec 07 '18 at 14:43
2

In Mercurial, just hg pull -u. Uncommitted changes are merged with the tip. Same result as shelve, pull/update, unshelve. With TortoiseHg a dialog will come up prompting for discard/shelve/merge.

You may get a merge dialog this way but that would be true with the shelving approach because unshelve may have to merge as well. From the command line you won't get a prompt if there are no conflicts. TortoiseHg may have an option to suppress the dialog if there are no conflicts, but I haven't checked.

StayOnTarget
  • 7,829
  • 8
  • 42
  • 59
Mark Tolonen
  • 132,868
  • 21
  • 152
  • 208
0

Direct answer: https://pypi.org/project/hg-autoshelve/

But a dedicated repository for configuration files seems a better idea as suggested by Christian Specht there

alain
  • 629
  • 6
  • 8
0

I would try a few different things with this.

Regarding the Web.config file in particular, you might want to look at using local configuration files for overrides instead of leaving local changes uncommitted. (e.g. referencing an separate file that is in .hgignore). Projects I've worked on in the past did this to separate test/prod configurations from the settings for development, or vice-versa.

I don't think there is any extension which will do this for you, but you might be better off writing a quick batch or powershell script to do this workflow for you. On previous projects, I had a script which would do something similar in that it would do a pull/update/rebase to keep my changes at the tip (I was working with hg against an SVN server which made that important.)

I know I didn't answer your question directly, but I hope this helps!

MattGWagner
  • 1,137
  • 1
  • 13
  • 16
  • Haven't fully researched it, but I saw something about secret changes in Mercurial's newest version -> http://stackoverflow.com/a/9000662/51270 – MattGWagner Feb 10 '12 at 15:19