来自非嵌套/同级目录的Mercurial子存储库? [英] Mercurial subrepository from a non-nested / sibling directory?
问题描述
是否可以使用同级路径创建子存储库?
Is it possible to create a subrepository using a sibling path?
Subversion是我们在这里选择的" VCS,但是我已经有很多关于过期提交的问题.使用Hg和SVN对文件进行双重版本对我来说更加方便,并且在此方面我取得了巨大的成功.但是,我还有其他几个使用Hg的同事,除了他们可能没有注意到的一个人之外,我们在那里没有其他问题.
Subversion is our "chosen" VCS here, but I've already had quite a few issues with out of date commits. It's much more convenient for me to dual version my files under Hg and SVN, and I have had great success with it. However, I've got a few other co-workers using Hg, and we've had no problems there except for one they probably haven't noticed.
我们的SVN布局看起来像这样
Our SVN layout looks like this
Area/
trunk/
Program1/
Program2/
...
Services/
Program1ServiceA/
Program1ServiceB/
branches/
Program/
Program/
...
Services/
Program1ServiceA/
Program1ServiceB/
tags/
Program1/
Program2/
...
Services/
Program1ServiceA/
Program1ServiceB/
当您在处理项目时,这会使您变得很愚蠢,因为如果您的主项目由Program1
和Program2
以及更多的服务组成,...我将无法获得所有的一键式更改集,因为我们有一个与目录匹配的存储库.因此,我必须确保4个或5个存储库是同步的,尤其是在某些服务引用中.
Which makes it kind of stupid when you're working on a project, because if your main project is comprised of Program1
and Program2
, and a few more services... I can't get all of the changesets in one go, because we've got a repository that matches the directories. So I have to make sure 4 or 5 repos are in sync, especially with some service references.
我在单个目录下使用subrepos感到很幸运:
I've had some good luck using subrepos beneath a single directory:
MainRepo/
Subrepo1/
Subrepo2/
但是我想做的是指定一个相对路径,这样我就可以使用子目录到子存储库,这样我就可以拥有这样的东西:
But what I would like to do is specify a relative path so I can use sibling directories to the subrepository, so I could have something like this:
Area/
Project1/
Program1/ (points to ../trunk/Program1)
Program2/ (points to ../trunk/Program2)
Service1/ (... You get the idea)
Service2/
trunk/
Program1/
Program2/
Services/
Service1/
Service2/
但是到目前为止,它没有像我期望的那样工作. trunk/Program1
是汞仓库,而我的Project1/.hgsub
文件包含
But so far it hasn't worked like I expected it to. trunk/Program1
is an Hg repo, and my Project1/.hgsub
file contains
Program1 = ../trunk/Program1
我也尝试过../../trunk/Program1
但是其中任何一个的结果是创建了一个新目录:Area/Program1/Project1
,该目录为空.
But the result of either of those is that a new directory is created: Area/Program1/Project1
that is empty.
到目前为止,我唯一能找到的搜索结果是使用基于http
的存储库作为子存储库,因此我不确定从何而来.我们的开发环境是Windows 7,因此简单"的答案是创建联结,但是我主要关心的是使这种 easy 这样的事情容易做,因此进入的门槛尽可能低,甚至像从管理员cmd窗口中的mklink /J Program1 ..\trunk\Program1
这样简单的事情,都会阻止人们迁移到更好的工作流程.
So far, the only search results I've been able to find use http
based repositories for subrepos, so I'm not sure where to go from here. Our dev env is Windows 7, so the "easy" answer is to create junctions, but my primary concern is to make things like this easy to do, so the barrier to entry is as low as possible, and even something as easy as mklink /J Program1 ..\trunk\Program1
from an administrator cmd window is one more thing that would prevent people from migrating to a better workflow.
是否可以像我想要的那样添加一个子存储库,或者有更好的方法来执行我们正在做的事情?
Is it possible to add a subrepository like I want, or is there a better way to do what we're doing?
推荐答案
子存储库总是始终在另一个存储库中.换句话说,子存储库使您可以对存储库的版本进行版本控制,其中某些存储库嵌套在其他存储库中.因此,如果不创建外部存储库,子存储库就不能成为同级兄弟.
Subrepositories are always inside another repository. In other words, subrepositories lets you version a collection of repositories where some repositories are nested inside other repositories. Subrepositories can thus not be siblings without creating an outer repository.
您正在谈论的相对路径是在Mercurial需要找出位置来获取新的子存储库时使用的.也就是说,当您运行hg update
(或作为hg clone
的一部分为您运行)时,Mercurial会注意到一个.hgsub
文件,然后它需要在此创建子存储库.要创建子仓库,Mercurial使用右侧的路径:
The relative paths you're talking about are used when Mercurial needs to figure out where to get a new subrepository from. That is, when you run hg update
(or when it's run for you as part of hg clone
) and Mercurial notices a .hgsub
file, then it needs to create the subrepositories mentioned there. To create the subrepo, Mercurial uses the path on right-hand side:
sub-A = relative/path
sub-B = C:/absolute/path
此处sub-A
将使用命令在工作副本的根目录中检出
Here sub-A
will be checked out in the root of your working copy using the command
hg clone <default path for main repo>/relative/path sub-A
使用命令检出
和sub-B
hg clone C:/absolute/path sub-B
仅此而已-这是一个非常简单的机制.我试图在我的子存储库指南中对此进行描述,并且在该Wiki .
That's all — it's a very simple mechanism. I've tried to describe this in my subrepository guide and it's also explained in the wiki.
对于您的情况,您可以为所属零件制作一个薄壳存储库一起.此仓库类似于上面的Project1
,并具有Program1
,Program2
,Service1
等作为子仓库. .hgsub
看起来像这样:
For your case, you can make a thin shell repository for the parts that belong together. This repo will be like Project1
above and have Program1
, Program2
, Service1
, etc as subrepos. The .hgsub
will look like this:
Program1 = Program1
Program2 = Program2
Service1 = Service1
Service2 = Service2
通过使用平凡的子存储路径",您可以轻松进行操作:克隆看起来就像克隆源一样,并且所有内容都保持在一起.
By using "trivial subrepo paths" you make things easy: a clone looks just like the clone source and everything is kept together.
最后一点:除非您在其他项目中使用Program1
或Service1
,否则您应该将所有内容都放入一个存储库中.
A final note: unless you use Program1
or Service1
in other projects, then you should just put everything into a single repository.
这篇关于来自非嵌套/同级目录的Mercurial子存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!