开发者

Mercurial workflow for updating with uncommitted changes?

So i've made the switch from CVS to mercurial for my website.

The biggest issue I am having is that if i'm working on some files that I don't want to commit, I just save them.. I then have other files I want to push to the server, however if someone else has made changes to the repository, and I pull them down.. It asks me to merge or rebase.. either of these options will cause me to lose my local changes that I have not committed.

I've read that I should clone the repository for each project on my local host and merge it into the live when it's ready to do so. This not only seems tedious, but also takes a long time as it's a large repository.

Are there better solutions to this?

I would have hoped that Mercurial would see that I haven't committed my changes (even though I have changed the file from what's on the server) so it'd just overlook the file开发者_开发问答.

Any input on this would be greatly appreciated. Thank you!

Also, i'm using the hg eclipse plugin to work on my files and push/pull from the server.


hg shelve is your friend here I think.

which comes from the shelve extention (maybe - see below)

from the overview:

The shelve extension provides the shelve command to lets you choose which parts of the changes in a working directory you'd like to set aside temporarily, at the granularity of patch hunks. You can later restore the shelved patch hunks using the unshelve command.

The shelve extension has been adapted from Mercurial's RecordExtension.

or maybe its the attic extension

This module deals with a set of patches in the folder .hg/attic. At any time you can shelve your current working copy changes there or unshelve a patch from the folder.

it seems to have the same syntax as the shelve extension, so I'm not certain which one I've used


I second @Sam's answer. However, if you prefer to use standard Mercurial, a simple workflow is to

  1. save your working dir changes in a temporary file,
  2. sync your working dir with a specific revision, then
  3. push, pull, merge .. whatever you want to do and which requires a clean working copy, and
  4. get back your changes from the temporary file into the working dir.

For instance:

$ hg diff > snapshot.patch # save your uncommited changes
$ hg up -C                 # get a clean working copy
$ hg pull                  # do things ..
$ hg merge                 # .. you need a clean ..
$ hg commit -m "merge"     # .. working copy for
$ hg import snapshot.patch # get back your uncommited work


First, are you working from the commandline, or using something like Tortoise?

If you're working from the commandline, and you've done a pull, mercurial will not ask you to do anything, as it merely updates your local repository.

If you then do an hg update and have local changes, it should do what you're used to from CVS. It will update to the tip of the current branch, and attempt to merge your outstanding changes in. There are some caveats to that, so refer to the official docs at http://www.selenic.com/mercurial/hg.1.html#update.

Also, for temporarily storing changes, I would recommend MQ over shelve. Shelve only provides one storage area, whereas MQ provides as many as you need. MQ takes some getting used to, but worth the investment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜