如何使用Mercurial队列同时处理多个修补程序?

如何使用Mercurial队列同时处理多个修补程序?,mercurial,patch,mercurial-queue,Mercurial,Patch,Mercurial Queue,比如说,我有两个bug需要修复:bug1和bug2 我从bug1开始,在修复它的过程中,我转到bug2,然后半修复它 我返回到bug1,再次部分修复它,然后再次转到bug2 就像这样,在多次切换之后,我完成了两个bug的修复 审查这两个bug的人是不同的,他们不想与他们不关心的bug有任何关系。所以,我需要为他们提供不同的补丁 如果我使用的是普通的hg diff,我会: hg diff-U 7-p file1-r OLD_REVISION_NUMBER>patch1用于bug1,以及 hg di

比如说,我有两个bug需要修复:bug1和bug2

我从bug1开始,在修复它的过程中,我转到bug2,然后半修复它

我返回到bug1,再次部分修复它,然后再次转到bug2

就像这样,在多次切换之后,我完成了两个bug的修复

审查这两个bug的人是不同的,他们不想与他们不关心的bug有任何关系。所以,我需要为他们提供不同的补丁

如果我使用的是普通的
hg diff
,我会:

hg diff-U 7-p file1-r OLD_REVISION_NUMBER>patch1
用于bug1,以及

hg diff-U 7-p文件2-r旧版本号>patch2
用于bug2

如何对Mercurial队列执行相同的操作?
请推荐一个基本的工作流程。

这里是一个非常简化的工作流程,假设有两个不重叠的补丁,也就是说,这两个补丁不修改相同的文件

$ hg init myrepo
$ cd myrepo
$ echo "This is file1" >file1
$ echo "This is file2" >file2
$ hg add
adding file1
adding file2
$ hg commit -m 'initial files'

#  Initialize and work on patch1

$ hg qnew -m 'Fix for bug1' patch1
$ echo "a second line" >>file1
$ hg diff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line
$ hg qdiff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#  Update the current patch (patch1)

$ hg qrefresh
$ hg diff
$ hg qdiff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#   Initialize and work on patch2

$ hg qnew -m 'Fix for bug2' patch2
$ hg qseries
patch1
patch2
$ hg qtop
patch2
$ hg diff
$ echo 'another line for file2' >>file2
$ hg diff
diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2
$ hg qrefresh
$ hg diff
$ hg qdiff
diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2

#  Export patch2

$ hg export qtip
# HG changeset patch
# User My Name <myemail>
# Date 1362771912 28800
# Node ID 2baa2bf81b000d4d720f9c4151242458b90bcd80
# Parent  ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
Fix for bug2

diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2

#  Pop back to and export patch1

$ hg qpop
popping patch2
now at: patch1
$ hg export qtip
# HG changeset patch
# User My Name <myemail>
# Date 1362771745 28800
# Node ID ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
# Parent  a227e9c42f2d17fb28082ad2451a03d4926505ba
Fix for bug1

diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#  Resume working on patch2

$ hg qpush
applying patch2
now at: patch2
...

#  Apply patch1 to repo

$ hg qpop
popping patch2
now at: patch1
$ hg qfinish -a
$ hg qseries
patch2
$ hg summary
parent: 1:ccd75363c8f4 tip
 Fix for bug1
branch: default
commit: (clean)
update: (current)
mq:     1 unapplied
$ hg qpush
applying patch2
now at: patch2
$hg init myrepo
$cd myrepo
$echo“这是文件1”>文件1
$echo“这是文件2”>file2
$hg加
添加文件1
添加文件2
$hg提交-m“初始文件”
#初始化并使用补丁1
$hg qnew-m“bug1修复”补丁1
$echo“第二行”>>文件1
$hg差异
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
$hg qdiff
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#更新当前修补程序(修补程序1)
$hg qrefresh
$hg差异
$hg qdiff
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#初始化并使用补丁2
$hg qnew-m“bug2修复”补丁2
$hg q系列
补丁1
补丁2
$hg qtop
补丁2
$hg差异
$echo'文件2的另一行'>>文件2
$hg差异
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
$hg qrefresh
$hg差异
$hg qdiff
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
#出口补丁2
$hg出口qtip
#HG变更集补丁
#使用我的名字
#日期136277191228800
#节点ID 2baa2bf81b000d4d720f9c4151242458b90bcd80
#母ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
修正bug2
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
#返回并导出补丁1
$hg qpop
弹出补丁2
现在:patch1
$hg出口qtip
#HG变更集补丁
#使用我的名字
#日期13627717452800
#节点ID ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
#父级A227E9C42F2D17FB28082AD2451A03D49265BA
修正bug1
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#继续使用补丁2
$hg/push
应用补丁2
现在:补丁2
...
#将补丁1应用于回购
$hg qpop
弹出补丁2
现在:patch1
$hg qfinish-a
$hg q系列
补丁2
$hg汇总表
家长:1:ccd75363c8f4提示
修正bug1
分支:默认
承诺:(清洁)
更新:(当前)
mq:1未应用
$hg/push
应用补丁2
现在:补丁2

请记住,Mercurial队列旨在管理一个有序的修补程序列表,其中系列中的后续修补程序可能会修改早期修补程序所做的更改。如果您正在处理的项目涉及对同一组文件的并行开发,那么MQ可能不是最好的工具。在这种情况下,考虑使用有或没有书签的水星分支或水银匿名头。

< P>这是一个非常简化的工作流,假设两个非重叠的补丁,即,两个补丁不修改相同的文件。
$ hg init myrepo
$ cd myrepo
$ echo "This is file1" >file1
$ echo "This is file2" >file2
$ hg add
adding file1
adding file2
$ hg commit -m 'initial files'

#  Initialize and work on patch1

$ hg qnew -m 'Fix for bug1' patch1
$ echo "a second line" >>file1
$ hg diff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line
$ hg qdiff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#  Update the current patch (patch1)

$ hg qrefresh
$ hg diff
$ hg qdiff
diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#   Initialize and work on patch2

$ hg qnew -m 'Fix for bug2' patch2
$ hg qseries
patch1
patch2
$ hg qtop
patch2
$ hg diff
$ echo 'another line for file2' >>file2
$ hg diff
diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2
$ hg qrefresh
$ hg diff
$ hg qdiff
diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2

#  Export patch2

$ hg export qtip
# HG changeset patch
# User My Name <myemail>
# Date 1362771912 28800
# Node ID 2baa2bf81b000d4d720f9c4151242458b90bcd80
# Parent  ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
Fix for bug2

diff --git a/file2 b/file2
--- a/file2
+++ b/file2
@@ -1,1 +1,2 @@
 This is file2
+another line for file2

#  Pop back to and export patch1

$ hg qpop
popping patch2
now at: patch1
$ hg export qtip
# HG changeset patch
# User My Name <myemail>
# Date 1362771745 28800
# Node ID ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
# Parent  a227e9c42f2d17fb28082ad2451a03d4926505ba
Fix for bug1

diff --git a/file1 b/file1
--- a/file1
+++ b/file1
@@ -1,1 +1,1 @@
-This is file1
+a second line

#  Resume working on patch2

$ hg qpush
applying patch2
now at: patch2
...

#  Apply patch1 to repo

$ hg qpop
popping patch2
now at: patch1
$ hg qfinish -a
$ hg qseries
patch2
$ hg summary
parent: 1:ccd75363c8f4 tip
 Fix for bug1
branch: default
commit: (clean)
update: (current)
mq:     1 unapplied
$ hg qpush
applying patch2
now at: patch2
$hg init myrepo
$cd myrepo
$echo“这是文件1”>文件1
$echo“这是文件2”>file2
$hg加
添加文件1
添加文件2
$hg提交-m“初始文件”
#初始化并使用补丁1
$hg qnew-m“bug1修复”补丁1
$echo“第二行”>>文件1
$hg差异
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
$hg qdiff
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#更新当前修补程序(修补程序1)
$hg qrefresh
$hg差异
$hg qdiff
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#初始化并使用补丁2
$hg qnew-m“bug2修复”补丁2
$hg q系列
补丁1
补丁2
$hg qtop
补丁2
$hg差异
$echo'文件2的另一行'>>文件2
$hg差异
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
$hg qrefresh
$hg差异
$hg qdiff
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
#出口补丁2
$hg出口qtip
#HG变更集补丁
#使用我的名字
#日期136277191228800
#节点ID 2baa2bf81b000d4d720f9c4151242458b90bcd80
#母ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
修正bug2
diff—git a/file2 b/file2
---a/文件2
+++b/文件2
@@ -1,1 +1,2 @@
这是文件2
+文件2的另一行
#返回并导出补丁1
$hg qpop
弹出补丁2
现在:patch1
$hg出口qtip
#HG变更集补丁
#使用我的名字
#日期13627717452800
#节点ID ccd75363c8f459bec4a8d6b94dfb4150fb9e3014
#父级A227E9C42F2D17FB28082AD2451A03D49265BA
修正bug1
diff—git a/file1 b/file1
---a/file1
+++b/文件1
@@ -1,1 +1,1 @@
-这是文件1
+第二行
#继续使用补丁2
$hg/push
应用补丁2
现在:补丁2
...
#将补丁1应用于回购
$hg qpop
弹出补丁2
现在:patch1
$hg qfinish-a
$hg q系列
补丁2
$hg汇总表
家长:1:ccd75363c8f4提示
修正bug1
分支:默认
承诺:(清洁)
更新:(当前)
mq:1未应用
$hg/push
应用补丁2
现在:补丁2
请记住,Mercurial队列旨在管理一个有序的修补程序列表,其中系列中的后续修补程序可能会修改早期修补程序所做的更改。如果您正在处理的项目涉及在同一组文件上进行并行开发,那么MQ可能不是最佳选择