您可以使用 Mercurial 从一个项目更新另一个项目吗
我将尝试尽可能简洁地解释我的情况:
我有一个模板项目,在开始新项目时将其用作模板(废话)。 这个模板项目不断发展,有时我会在处理另一个项目时更新它。
所以想象一下:
- 模板项目:template.file
- 项目 A:template.file &项目A.file
- 项目B:template.file & projectB.file
(所有项目都在修订控制之下)现在,当我更改项目 A 中的 template.file 时,我希望所有其他项目中的所有其他 template.file 都更新
我在 Windows 上,使用 tortoisehg 并且我在这方面相对较新版本控制游戏。我想我会用分支来做这个?但是,projectA.file 和 ProjectB.file 是否也会添加到模板项目中?
I'll try to explain my situation as concise as possible:
I have a template project that I use as a template (duh) when starting a new project.
This template project evolves, and sometimes I update it as I am working on another project.
So imagine that:
- Template project: template.file
- Project A: template.file & projectA.file
- Project B: template.file & projectB.file
(all projects are under revision control) Now when I change template.file in project A, I would like all other template.files in all other projects to update
I am on windows, using tortoisehg and I am relatively new at this versioning game. I suppose I would do this with branches? But then wouldn't the projectA.file and ProjectB.file also get added to the template project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以执行以下操作:
进入模板项目并合并到项目 A 中,然后在提交之前删除您不需要的所有内容。这是相当费力和费时的。
然后您可以进入项目 be 并从模板项目中提取并非常仔细地合并。
出于多种原因,我不会这样做。首先,它很混乱并且容易出错。其次,它会导致两个项目都包含所有其他项目的所有文件,即使在最新修订中这些文件被视为已删除。历史仍然在那里。
您还可以执行以下操作:
使用
hg export
从项目 A 导出修改模板文件的更改。然后使用hg import
将该更改导入到您的模板项目中。然后从模板项目拉入项目 A 和项目 B 并合并。
这就要求您在修改项目 A 时严格要求自己,并且始终对模板文件进行修改。
或者,您可以手动修改导出的更改以删除无关的更改。
这是您可以做的第三件事:
始终仅在模板项目中修改模板文件。然后,您可以从模板项目拉取项目 A 和 B 并合并。
Here is something you could do:
Go into the template project and merge in project A, then prune everything you didn't want before committing. This is rather laborious and time consuming.
Then you can go into project be and pull from the template project and very carefully merge.
I would not do this for any number of reasons. First, it's messy and error prone. Secondly it results in both projects containing all the files of all the other projects, even if in the tip revisions those files are considered deleted. The history is still all there.
Here is another thing you could do:
Use
hg export
to export the change that modifies the template file from project A. Then usehg import
to import that change into your template project.Then pull from the template project into both project A and project B and merge.
This requires that you discipline yourself when modifying project A and always make modifications to template files their own change.
Alternatively, you can hand modify the exported change to remove extraneous changes.
Here is a third thing you could do:
Always modify template files only in the template project. Then you can pull from the template project into projects A and B and merge.
Mercurial 中没有任何东西可以让您干净利落地开箱即用。
您可以:
在这三个中的任何一个中,没有什么可以帮助您确保每个存储库中的文件同步。
在第一种情况下,您将拥有 template.file 的 3 个不同副本,更新一个副本不会更新其他两个副本,并且 Mercurial 中没有任何内容可以帮助您解决此问题。
在第三种情况下,三个存储库完全不同且独立,这意味着一个存储库中的更改不会传播到另一个存储库中。
然而,第二种情况是可以完成的,但如果您需要在项目 A/B 存储库中拥有该文件的副本,那么您将回到第三种情况。
但是,您可以将模板项目设为项目 A 的子存储库,而不是从模板项目复制文件并将其复制到项目 A 中,而是引用子存储库中的文件。
这就是 Mercurial 处理此类事情的方式。
There's nothing in Mercurial that will you out of the box with this, cleanly.
You could:
In either of these 3, there's nothing that will help you make sure a file inside each repository is in sync.
In the first case, you would have 3 distinct copies of the template.file, and updating one will not update the other two, and there's nothing in Mercurial that will help you with that.
In the third case, the three repositories are completely distinct and separate, which means changes in one does not propagate into the other.
The second case, however, can be done, but if you need to have a copy of the file inside the Project A/B repositories, you're back to the third case.
However, you can make the template project a sub-repository of Project A, and instead of making a copy of the file, out of the template project and into Project A, you refer to the one you have in the sub-repository.
This is the way Mercurial handles such things.