让我们说,我有2个错误需要修复:bug1和bug2。
我从bug1开始,在修复它的过程中,我转到bug2并修复了一半。
我返回bug1并再次部分修复它并再次转到bug2。
像这样,经过多次转换,我完成了两个错误的修复。
要审查这两个错误的人是不同的,并且不想与他们不关心的错误无关。所以,我需要为他们提供不同的补丁。
如果我使用普通hg diff
,我会做的:
hg diff -U 7 -p file1 -r OLD_REVISION_NUMBER > patch1
,
hg diff -U 7 -p file2 -r OLD_REVISION_NUMBER > patch2
如何使用Mercurial Queues执行相同的操作? 请建议一个基本的工作流程。
答案 0 :(得分:1)
这是一个非常简化的工作流程,假设有两个不重叠的补丁,即两个补丁不会修改相同的文件。
$ 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
请记住,Mercurial Queues旨在管理有序的修补程序列表,其中系列中的后续修补程序可能会修改早期修补程序所做的更改。如果您正在处理的项目涉及对同一组文件的并行开发,则MQ可能不是最佳使用工具。在这种情况下,请考虑使用带有或不带书签的Mercurial分支或Mercurial匿名头。