商业子存储库是否必须是主存储库的子目录? [英] Does a mercurial subrepository have to be a subdirectory of the main repository?

查看:77
本文介绍了商业子存储库是否必须是主存储库的子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目由以下位置的代码组成

My project is made up of code in the following locations

C:\Dev\ProjectA
C:\Lib\LibraryB
C:\Lib\LibraryC

当前,每个文件夹都是一个完全独立的Mercurial存储库.项目A一直在变化,图书馆B和图书馆C很少变化.

Presently each of these folders is a completely independent Mercurial repository. Project A changes all the time, Library B and Library C change rarely.

我目前在发布项目A的每个版本时都对其进行标记,并且(当我记得时)在库B和C的存储库中放置了相应的标记.

I currently tag each version of Project A as it is released and (when I remember) put a corresponding tag in the Library B and C repositories.

我可以通过使用子存储库来对此进行改进吗?是否需要我将库B和C设置为项目A的子目录?

Can I improve upon this by using subrepositories? Would that require me to make Library B and C a subdirectory of Project A?

如果库B和C必须是项目A的子目录,如果我想启动一个使用库B但与项目A完全无关的项目D,该怎么办?

If Library B and C must be subdirectories of Project A what do I do if I want to start a Project D that uses Library B but isn't otherwise affiliated with Project A at all?

推荐答案

如果库B和C必须是 项目A的子目录我该怎么办 如果我想启动一个项目D,该怎么办 使用库B,但不是这样 完全隶属于Project A?

If Library B and C must be subdirectories of Project A what do I do if I want to start a Project D that uses Library B but isn't otherwise affiliated with Project A at all?

任何项目都可以同时作为另一个项目的子存储库独立存在.我将通过建议工作流程进行解释.

Any project can exist both independently and as subrepository of another project at the same time. I'll explain by suggesting a workflow.

首先,您的每个项目(A,B,C)都应该有一个受祝福的存储库,该存储库发布在以下位置:

First of all, each of your projects (A, B, C) should have a blessed repository that is published somewhere:

您可以在自己的服务器上运行 hgwebdir 或使用Mercurial托管服务,例如 Bitbucket

You could run hgwebdir on your own server, or make use of a Mercurial hosting service like Bitbucket or Kiln. This way developers have a central authorative point to pull/push changes from, and you have something to make backups of.

现在,您可以克隆这些存储库,以两种不同的方式进行处理:

Now you can make clones of these repositories to work on in two different ways:

  • 直接克隆您的项目.例如:

hg clone http://bitbucket.org/LachlanG/LibraryB C:\Lib\LibraryB

通过将.hgsub文件放在ProjectA的根目录中,

  • 和/或创建子存储库定义:

  • and/or create subrepository definitions by putting a .hgsub file in the root of ProjectA with the following content:

    libraries/libraryB = http://bitbucket.org/LachlanG/LibraryB
    libraries/libraryC = http://bitbucket.org/LachlanG/LibraryC
    

  • 这些子存储库定义告诉Mercurial,无论何时克隆Project A,都必须将库B和库C的克隆放在libraries文件夹中.

    These subrepository definitions tell Mercurial that whenever Project A is cloned, it also has to put clones of Library B and Library C in the libraries folder.

    如果您在Project A中工作并提交,那么您在libraries/LibraryBlibraries/LibraryC中所做的更改也将被提交. Mercurial将在.hgsubstate文件中记录项目A正在使用哪个版本的库.结果是,如果您hg update到项目的旧版本以查看上周的工作方式,则还将获得相应版本的库.您甚至不需要制作标签:-)

    If you are working in Project A and commit, then your changes in libraries/LibraryB and libraries/LibraryC will be committed as well. Mercurial will record which version of the libraries is being used by Project A in the .hgsubstate file. The result is that if you hg update to an old version of the project to see how things worked last week, you also get the corresponding version of your libraries. You don't even need to make tags :-)

    当您hg push将项目A更改为受祝福的存储库时,Mercurial还将确保首先将子存储库更改推入其自身位置.这样,您就不会意外地发布依赖于未发布的库更改的项目更改.

    When you hg push the Project A changes to the blessed repository, Mercurial will also make sure to push the subrepository changes first to their own origin. That way you never accidentally publish project changes which depend on unpublished library changes.

    如果您希望将所有内容都保留在本地,则仍可以通过使用相对路径而不是子存储库定义中的URL来使用此工作流程.

    If you prefer to keep everything local, you can still use this workflow by using relative paths instead of URLs in the subrepository definitions.

    这篇关于商业子存储库是否必须是主存储库的子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆