Mercurial 工作流程是否可以通过未提交的更改进行更新?

发布于 2024-11-15 21:07:34 字数 406 浏览 0 评论 0原文

因此,我的网站从 CVS 切换到 Mercurial。

我遇到的最大问题是,如果我正在处理一些我不想提交的文件,我只需保存它们..然后我还有其他文件想要推送到服务器,但是如果其他人已经制作了对存储库进行更改,然后我将它们拉下来。它要求我合并或变基。这些选项中的任何一个都会导致我丢失尚未提交的本地更改。

我读过,我应该在本地主机上克隆每个项目的存储库,并在准备好时将其合并到实时中。这不仅看起来很乏味,而且还需要很长时间,因为它是一个很大的存储库。

对此有更好的解决方案吗?

我希望 Mercurial 能够看到我没有提交更改(即使我已经更改了服务器上的文件),因此它只会忽略该文件。

对此的任何意见将不胜感激。谢谢你!

另外,我正在使用 hg eclipse 插件来处理我的文件并从服务器推送/拉取。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

只是我以为 2024-11-22 21:07:34

我想 hg shelve 是你的朋友。

它来自

概述中的搁置扩展(可能 - 见下文):

搁架扩展提供了
搁置命令让您选择
哪些部分发生了变化
您要设置的工作目录
暂时放在一边,在粒度上
补丁帅哥。您可以稍后恢复
搁置的补丁帅哥使用
取消搁置命令。

搁架扩展已进行调整
来自 Mercurial 的 RecordExtension。

或者可能是阁楼扩展

该模块处理一组
文件夹 .hg/attic 中的补丁。在
任何时候你可以搁置当前的
工作副本在那里更改或取消搁置
文件夹中的补丁。

它似乎与搁置扩展具有相同的语法,所以我不确定我使用的是哪一个

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

无可置疑 2024-11-22 21:07:34

我赞同@Sam 的回答。但是,如果您更喜欢使用标准 Mercurial,一个简单的工作流程是将

  1. 工作目录更改保存在临时文件中,
  2. 将工作目录与特定版本同步,然后
  3. 推送、拉取、合并......无论您想要做什么以及需要做什么一个干净的工作副本,并将
  4. 临时文件中的更改返回到工作目录中。

例如:

$ 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

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
停滞 2024-11-22 21:07:34

首先,您是通过命令行工作,还是使用 Tortoise 之类的工具?

如果您从命令行工作,并且已经完成了拉取,则 Mercurial 不会要求您执行任何操作,因为它只会更新您的本地存储库。

如果您随后进行 hg 更新并进行本地更改,它应该执行您在 CVS 中习惯的操作。它将更新到当前分支的尖端,并尝试合并您未完成的更改。对此有一些注意事项,因此请参阅官方文档 http://www.selenic.com/mercurial/hg.1.html#update

另外,为了临时存储更改,我建议使用 MQ 而不是 shelve。 Shelve只提供一个存储区域,而MQ可以提供任意数量的存储区域。 MQ 需要一些时间来适应,但值得投资。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文