9

我有一个名为“模拟器”的平台中立的 Mercurial 代码仓库

并希望在构建之前应用针对特定平台优化的补丁。

根据指南,我们可以通过使用带有防护的补丁来实现这一点。

  • Windows Experimental.patch +windows
  • Unix Experimental.patch +unix
  • Mac Experimental.patch +mac

但是它开始变得很麻烦,因为我们的补丁队列包含 100 多个补丁,命名为 windows-memory-optimization.patch +windows、unix-memory-optimization.patch +unix、windows-io-experimental-bug-fix.patch +windows、等等等等。我们在系列文件中将其组织为组,但文件变得越来越大,使用 qseries / qapplied 变得难以管理

相反,我们希望为 windows、unix 和 mac 设置一个队列。

因此,补丁可以组织为:

  • Windows 补丁堆栈:memory-opt.patch、io-opt.patch 等
  • Unix 补丁栈:disk.patch、graphics.patch 等
  • Mac 补丁堆栈:io-fix.patch、io-opt.patch、experimental.patch 等

然后交换每个平台的补丁堆栈进出模拟器存储库。这样我就可以处理 windows 补丁堆栈并弹出/推送各种子系统优化补丁,并独立于 unix 或 mac 补丁堆栈来处理它们。

看起来我做不到,除了针对每个平台制作 3 个不同的 repos 并以这种方式维护补丁堆栈。

除了手动将 .hg/patches 目录复制进出仓库之外,还有其他方法可以完成“交换”补丁堆栈吗?

4

3 回答 3

17

Mercurial 队列的有趣使用:)

我在这里假设您已经在某处对您的 mercurial 队列进行版本控制。如果您不/不知道如何执行此操作,请查看hgbook 中的相关部分:这是在不应用补丁的情况下逐步协作/保存您的工作的好方法。

三个命名分支

应该可以在 MQ 存储库中维护三个不同的命名分支,每个平台一个。

要切换平台,只需切换活动分支。

(与alias mq='hg -R $(hg root)/.hg/patches'

首先创建一个windows分支:

$ mq branch windows
marked working directory as branch windows

已创建,但尚未提交。

做一些事情,添加补丁:

$ hg qnew windowspatch
... do some stuff

刷新、弹出和提交:

$ hg qref
$ hg qpop -a
$ mq ci -m 'new windows branch'

您现在拥有默认分支和新的 windows 分支:

$ mq branches
windows                       65:5fd4ef0b96c9
default                       64:06c1a56a3c08 (inactive)

现在创建一个 Unix 分支。

首先切换回基本默认分支:

$ mq up default
1 files updated, 0 files merged, 1 files removed, 0 files unresolved

创建一个新的 unix 分支并添加一个特定于 unix 的补丁:

$ mq branch unix
marked working directory as branch unix
$ hg qnew unixpatch
... blahblah
$ hg qref
$ hg qpop -a
$ mq ci -m 'adding unix branch'
$ mq branches
unix                          66:c51bb2c7b413
windows                       65:5fd4ef0b96c9
default                       64:06c1a56a3c08 (inactive)

用法

qpop -a在操作 mq repos 之前不要忘记...

推送所有windows补丁

$ mq up windows
xx files updated, yy files merged, zz files removed, ww files unresolved
$ hg qpush -a

三个物理回购

维护三个独立的(mercurial queue)分支看起来有点吓人。如果是这样,您可以只使用三个不同的 MQ 存储库:每个平台一个,每个版本在不同的位置。

例如 :

$ cd mqs
$ hg qclone mq-windows windows
$ hg qclone mq-unix unix
$ hg qclone mq-mac mac

要在不同平台上工作,只需切换文件夹 (repos)。该概念类似于第一种方法。但不是在一个 MQ 存储库中拥有三个内部分支,而是使用三个单独的 MQ 存储库。

于 2009-06-09T15:48:02.493 回答
5

要为“mq”创建等效的 Windows 别名,请在与“hg.exe”相同的目录中创建一个批处理文件(例如,“C:\Program Files\TortoiseHg”),将其命名为“mq.cmd”,然后粘贴代码:

@echo off
FOR /F "tokens=1 delims=" %%A in ('hg root') do SET hgRoot=%%A
hg -R %hgRoot%/.hg/patches %1 %2 %3 %4 %5 %6 %7 %8 %9
于 2009-09-05T00:23:17.573 回答
5

I know this question is old, but may be someone could be interested to know there's another solution. I think this wasn't possible at the time the question got asked, but here it is more info regarding this situation: Multiple Patch Queues on MQ

于 2010-11-21T20:30:42.870 回答