如何在 Mercurial 中区分单个目录

发布于 2024-10-07 06:28:32 字数 376 浏览 5 评论 0原文

我有两个本地 Mercurial 存储库,我们称它们为产品和 Skunkworks。 Skunkworks 是产品的克隆,最近有很多针对它的提交活动。我需要能够将目录树的一小部分的差异打包起来,并将其作为补丁文件取出。

我在磁盘上有以下布局:

c:/dev/product
c:/dev/skunkworks

我想要打包的差异区域来自 c:/dev/skunkworks/buildstuff。该目录存在于产品存储库中。我还不想让其他人了解 Skunkworks 其余部分的变化,但需要能够分享我的新构建的优点。

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

谢谢!

I have two local mercurial repos, let's call them product and skunkworks. Skunkworks is a clone of product and has a lot of recent commit activity against it. I need to be able to package up the diffs from one small part of the directory tree and pull those out as a patch file.

I've got the following layout on disk:

c:/dev/product
c:/dev/skunkworks

The area of diffs I want to package up is from c:/dev/skunkworks/buildstuff. This directory exists in the product repo. I don't want to expose everyone else to the changes in the rest of skunkworks just yet, but need to be able to share my new build goodness.

I've tried a number of different parameter settings and combinations of the 'hg diff' command but am obviously doing something wrong. Any pointers or suggestions would be greatly appreciated.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

给妤﹃绝世温柔 2024-10-14 06:28:32

这可以很容易地完成,但首先让我建议,下次您进行独立的工作(构建工作和其余的 skunkworks)时,您可以在单独的头中完成它们 - 然后您可以将构建工作直接推送到使用汞推的产品也没有移动臭鼬工厂。该模式如下所示:

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

此时您的 Skunkworks 克隆将有两个头,一个负责构建工作,另一个负责 Skunkworks。您可以在工作时来回切换,在构建和沉没工程之间交替,同时将它们保持在同一个克隆中。如果在 skunkworks 上工作时你也想要构建细节,你可以这样做:

hg update SKUNKWORKSHEAD
hg merge BUILDHEAD

将 buildwork 合并到 skunkworks 中,但是 buildwork 的东西仍然没有任何 skunkworks 作为其父级,所以在任何时候你都可以这样做:

cd ../product
hg pull -r BUILDHEAD ../skunkworks

并且你只会移动将内容构建到产品中,而无需任何其他 Skunkwork 更改。

这是执行此类操作的最佳方法(技术上称为匿名分支),因为当您准备准备将 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 合并回产品时,所有构建更改都已经存在,这将使合并的自动化程度降低。

This can be done pretty easily, but first lemme suggest that the next time you're doing to independent bits of work (the build work and the rest of skunkworks) you do them in separate heads -- then you can push the buildwork directly to product using hg push w/o moving skunkworks over there too. That pattern would look like:

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

at that point your skunkworks clone will have two heads, one with build work and one with skunkworks. You can switch back and forth while working, alternating between build and sunkworks while keeping them separate within the same clone. If while working on skunkworks you want the build niceties too you can do:

hg update SKUNKWORKSHEAD
hg merge BUILDHEAD

that merges the buildwork into skunkworks, but the buildwork stuff still doesn't have any skunkworks as its parent, so at anytime you could do:

cd ../product
hg pull -r BUILDHEAD ../skunkworks

and you'd move only the build stuff into product without any of the other skunkworks changes.

This is the optimal way to do such a thing (technically called anonymous branches) because when you are ready to move skunkworks into product it'll know exactly where the build changes came from and how to correctly integrate them into skunkworks.

Whew, all that said what you want to do now is probably:

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

The drawback there is that when you do merge skunkworks back into product all the build changes will already be there, which will make the merge less automatic that it might otherwise be.

找个人就嫁了吧 2024-10-14 06:28:32

我认为您想要的只是在 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.

I think all you want is to run in skunkworks hg diff buildstuff -r <rev> where <rev> is the last revision matching the product repo.

Below creates a number of files and directories representing the original repository:

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

We'll clone and change a file in each of the subdirectories:

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

Now just display the diff for dir2 compared to the previous checkin:

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文