“因式分解”窑炉上的水银储存库
问题总结:
将一组文件从现有存储库转移到新的子存储库的最简单(也是最好)的方法是什么,以便这些文件可以与其他父存储库集成,其中一些可能还不存在?
子存储库中的文件是否需要位于单独的文件夹中,或者它们可以与其他文件一起存在吗?
详细问题:
我已经开始创建代表多个共享组件的多个项目的多个存储库,并且进展顺利,这要归功于SO以及对我的问题的一些有用的答案此处
当我继续添加第二个项目时,我注意到我的项目中有一些文件是重复的,并且本质上是相同的,有足够的文件与逮捕令相似从主项目存储库中取出并创建一个新的子存储库,以便
- 我开始的任何新项目都可以使用它们,并
- 从其他现有存储库中删除它们,因为它们是相同的。
我假设最好的方法是简单地创建一个新存储库,在本地文件系统上移动文件,推送两个存储库,然后创建一个 .hgsub 文件并按照 我之前的问题。显然,这会将相关文件转移到每个主项目下本地文件系统中的子文件夹中,我可以接受它,但它确实提出了一个假设的问题 - 是否有可能在存储库中拥有有效的文件列表子存储库的一部分,但与其他文件一起驻留(即不在子文件夹中)。
如果我想(例如)在属于另一个存储库的每个项目中都有一个“acme.h”文件,我可以这样做吗?碰巧的是,我现在不需要这样做,并且在我目前的情况下,从设计的角度来看,拥有我需要“重构”的文件会更好到他们自己的子文件夹中的另一个存储库中,但是情况可能并不总是如此。我在这里使用引号引起来的重构,严格来说,它更多的是重构重复的文件,也就是重构代码——但是同样的原则也适用。
希望我的问题足够简洁,无需太多解释即可得到解答。
Summarized questions:
What is the simplest (and best) way to shift a group of files from an existing repository to a new sub repository, so those files can be integrated with other parent repositories, some of which may not yet exist?
Do files in subrepositories need to be in discrete folders, or can they exist alongside other files?
Detailed Questions:
I have begun the process of creating multiple repositories representing several projects that have shared components, and that is going well, thanks to SO and some helpful answers to my question here
As I move on to adding a second project I notice there are a few files in my projects that are duplicated, and are essentially the same thing, with enough similarity to warrant taking them out of a main project repository and creating a new subrepository so they can be
- used by any new projects I begin, and
- removed from other existing repositories, since they are identical.
I am assuming the best way is to simply create a new repository, move the files across on the local file system, push both repositories, and then create a .hgsub file and proceeed as in the answer to my earlier question. This would obviously then shift the files concerned to a subfolder in the local file system under each main project, which i can live with, but it does raise the hypothetical question - is it possible to have a list of files in a repository that are effectively part of a sub repository but reside alongside other files (i.e. not in a sub folder).
If I wanted to (for example) have a "acme.h" file in each project that is part of another repository could I do this? as it happens, I don't need to do this at this point in time, and in my current situation it would be better from a design point of view to have the files I need to "refactor" into another repository in their own subfolder, however that might not always be the case. I use refactor in quotes here, as strictly speaking it's more about refactoring duplicated files that is refactoring code - however the same principle applies.
hopefully my questions are succinct enough to be answered without too much more explanation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢您的总结,使回答更容易!
您可以使用转换扩展从现有 Mercurial 存储库中提取目录。您需要使用
--filemap
标志,并在文件映射中包含所需的目录并将其重命名为根目录。请参阅hg help conversion
了解更多信息。当你获得一个较小的存储库后
它们必须位于自己的文件夹中。这只是因为这就是 Mercurial、Git、Subversion 中存储库的样子……当您处理 subrepositories,那么 Mercurial 不会跟踪子存储库内的文件:它只是要求某个(其他)系统在某个位置签出存储库
foo
。因此,当您的
.hgsub
文件包含此内容时,Mercurial 会在
hg update
上注意到这一点并为您运行。这解释了为什么子存储库是外部存储库中的目录:这就是当今克隆/签出的样子。
正如您所看到的,子存储库可以有不同的类型。可以想象,有人可以添加 RCS 子存储库类型来跟踪单个文件。这样他们就不必住在目录中。
Thanks for summary, makes it much easier to answer!
You can use the convert extension to extract a directory from an existing Mercurial repository. You'll want to use the
--filemap
flag and in the filemap you include the directory you want and rename it to the root. Seehg help convert
for more info.After you get a smaller repository with the
They must be in their own folders. This is simply because that's how a repository looks like in Mercurial, Git, Subversion, ... When you're dealing with subrepositories, then Mercurial is not tracking the files inside the subrepo: it's just asking some (other) system to make a checkout of repository
foo
at some location.So when your
.hgsub
file hasthen Mercurial will notice this on
hg update
and runfor your. This explains why subrepostories are directories in the outer repository: that's simply what a clone/checkout looks like these days.
As you can see, subrepositories can be of different types. It's conceivable that someone could add a RCS subrepository type for tracking individual files. They would then not have to live in a directory.