Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在mercurial中区分单个目录_Mercurial_Diff_Dvcs - Fatal编程技术网

如何在mercurial中区分单个目录

如何在mercurial中区分单个目录,mercurial,diff,dvcs,Mercurial,Diff,Dvcs,我有两个本地mercurial回购协议,我们称之为产品和臭鼬。Skunkworks是产品的克隆,最近有很多针对它的提交活动。我需要能够从目录树的一小部分打包差异,并将其作为补丁文件取出 我在磁盘上有以下布局: c:/dev/product c:/dev/skunkworks 我要打包的差异区域来自c:/dev/skunkworks/buildstuff。此目录存在于产品回购中。我现在还不想让其他人看到其他臭鼬作品的变化,但我需要能够分享我的新构建优势 我已经尝试了许多不同的参数设置和'hg d

我有两个本地mercurial回购协议,我们称之为产品和臭鼬。Skunkworks是产品的克隆,最近有很多针对它的提交活动。我需要能够从目录树的一小部分打包差异,并将其作为补丁文件取出

我在磁盘上有以下布局:

c:/dev/product
c:/dev/skunkworks
我要打包的差异区域来自c:/dev/skunkworks/buildstuff。此目录存在于产品回购中。我现在还不想让其他人看到其他臭鼬作品的变化,但我需要能够分享我的新构建优势

我已经尝试了许多不同的参数设置和'hg diff'命令的组合,但显然我做错了什么。如有任何指示或建议,将不胜感激


谢谢

这可以很容易地完成,但首先,我建议下次你做独立的工作(构建工作和其他臭鼬工作)时,你可以在不同的头上进行——然后你可以使用hg push直接将构建工作推到产品上,而不移动臭鼬。这种模式看起来像:

hg clone product skunkworks
cd skunkworks
... build hacking ...
hg commit
... build hacking ...
hg commit
hg update REVNUMBER # where revnumber is the last revision that exists in product
... skunkworks hacking ...
hg commit  # at this point you'll see (+1 heads)
... more skunkworks hacking ...
hg commit
在这一点上,你的臭鼬克隆将有两个头,一个是构建工作,一个是臭鼬工作。您可以在工作时来回切换,在build和sunkworks之间交替切换,同时在同一个克隆中保持它们的分离。如果在处理臭鼬作品时,您也想要构建细节,您可以这样做:

hg update SKUNKWORKSHEAD
hg merge BUILDHEAD
这将建筑作品合并到臭鼬作品中,但建筑作品仍然没有任何臭鼬作品作为其父对象,因此您可以随时执行以下操作:

cd ../product
hg pull -r BUILDHEAD ../skunkworks
您只需将构建内容移动到产品中,而不需要对skunkworks进行任何其他更改

这是做这样一件事的最佳方式(技术上称为匿名分支),因为当您准备好将skunkworks移动到产品中时,它将确切地知道构建更改来自何处,以及如何正确地将它们集成到skunkworks中

呼,你现在想做的可能是:

cd skunkworks
hg diff -I buildstuff/** -r LAST_REV_IN_PRODUCT -r tip > ../applyme.patch
cd ../product
hg import --no-commit ../applyme.patch
hg commit

缺点是,当您将skunkworks重新合并到产品中时,所有的构建更改都已经存在,这将降低合并的自动化程度。

我认为您只想在skunkworks
hg diff buildstuff-r
中运行,其中
是与产品报告匹配的最后一个版本

下面创建了许多代表原始存储库的文件和目录:

C:\>hg init test
C:\>cd test
C:\test>echo >file1
C:\test>echo >file2
C:\test>md dir1
C:\test>md dir2
C:\test>echo >dir1\file3
C:\test>echo >dir1\file4
C:\test>echo >dir2\file5
C:\test>echo >dir2\file6
C:\test>hg ci -Am 1
adding dir1/file3
adding dir1/file4
adding dir2/file5
adding dir2/file6
adding file1
adding file2
我们将克隆并更改每个子目录中的一个文件:

C:\test>cd ..
C:\>hg clone test skunk
updating to branch default
6 files updated, 0 files merged, 0 files removed, 0 files unresolved

C:\>cd skunk
C:\skunk>echo >>dir1\file4
C:\skunk>echo >>dir2\file5
C:\skunk>hg st
M dir1\file4
M dir2\file5

C:\skunk>hg ci -m skunk
现在只需显示dir2与上一次签入相比的差异:

C:\skunk>hg diff dir2 -r 0
diff --git a/dir2/file5 b/dir2/file5
--- a/dir2/file5
+++ b/dir2/file5
@@ -1,1 +1,2 @@
 ECHO is on.
+ECHO is on.

哇,非常感谢您花时间解释匿名分支方法。我来自SVN,所以我仍然在尝试克隆和mercurial中不同的“分支”选项。谢谢