Pergunta

Lets say, I have 2 bugs to fix : bug1 and bug2.

I start with bug1 and in the midst of fixing it, I go to bug2 and half fix it.

I return to bug1 and again partially fix it and again go to bug2.

Like this, after much switching, I finish fixing both the bugs.

The people who are to review both these bugs are different and want nothing to do with the bug they aren't concerned with. So, I need to provide them with different patches.

If I were using plain hg diff, I would have done :

hg diff -U 7 -p file1 -r OLD_REVISION_NUMBER > patch1 for bug1, and

hg diff -U 7 -p file2 -r OLD_REVISION_NUMBER > patch2 for bug2

How do I do the same with Mercurial Queues? Please suggest a basic workflow.

Foi útil?

Solução

Here is a very simplified workflow assuming two non-overlapping patches, that is, the two patches do not modify the same files.

$ 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

Keep in mind that the Mercurial Queues is designed to manage an ordered list of patches where a later patch in a series may modify changes made by an earlier patch. If the projects you are working on involve parallel development on the same sets of files, MQ may not be the best tool to use. In that case, consider using Mercurial branches or Mercurial anonymous heads with or without bookmarks.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top