294
|
1 |
-*- mode: outline; coding: utf-8 -*-
|
|
2 |
|
|
3 |
* Manage patches with MQ.
|
|
4 |
|
|
5 |
First enable MQ, add following to your ~/.hgrc:
|
|
6 |
|
|
7 |
[extensions]
|
|
8 |
hgext.mq =
|
|
9 |
|
|
10 |
Second get unpatched sources and put it to hg repository:
|
|
11 |
|
|
12 |
$ tar zxf proj-x.y.z.tar.gz
|
|
13 |
$ mv proj-x.y.z proj
|
|
14 |
$ cd proj
|
|
15 |
$ hg init
|
|
16 |
$ hg ci -m "Added x.y.z version of proj."
|
|
17 |
|
|
18 |
Init MQ and take name for first patch:
|
|
19 |
|
|
20 |
$ hg qinit
|
|
21 |
$ hg qnew first.patch
|
|
22 |
|
|
23 |
Next make changes by editing source and save it to patch:
|
|
24 |
|
|
25 |
$ $EDITOR file.c
|
|
26 |
...
|
|
27 |
$ hg diff
|
|
28 |
...
|
|
29 |
$ hg qrefresh
|
|
30 |
$ hg diff # <-- have zero diff
|
|
31 |
|
|
32 |
You can make second patch by applying existing one:
|
|
33 |
|
|
34 |
$ hg qnew second.patch
|
|
35 |
$ patch -p1 <bugfix.patch
|
|
36 |
$ hg qrefresh
|
|
37 |
|
|
38 |
You can take list of patches (from old to new) and revert or apply patches by
|
|
39 |
qpop/qpush command:
|
|
40 |
|
|
41 |
$ hg qseries # <-- what patches have
|
|
42 |
first.patch
|
|
43 |
second.patch
|
|
44 |
$ hg qapplied # <-- what patches applied
|
|
45 |
first.patch
|
|
46 |
second.patch
|
|
47 |
$ hg qpop
|
|
48 |
$ hg qseries
|
|
49 |
first.patch
|
|
50 |
second.patch
|
|
51 |
$ hg qapplied
|
|
52 |
first.patch
|
|
53 |
|
|
54 |
You can revert or apply all patches by single command:
|
|
55 |
|
|
56 |
$ hg qpop -a
|
|
57 |
$ hg qpush -a
|
|
58 |
|
|
59 |
You can delete patch from patch list (before that you need de-apply patch):
|
|
60 |
|
|
61 |
$ hg qpop -a
|
|
62 |
$ hg qdelete first.patch
|
|
63 |
|
|
64 |
To add new version of source and fix patches for it first de apply patches,
|
|
65 |
then pull new changes and try apply patches on top of new sources:
|
|
66 |
|
|
67 |
$ hg qpop -a
|
|
68 |
$ rm * # .hg dir not deleted because its name start with dot
|
|
69 |
$ cd ..
|
|
70 |
$ tar zxf proj-a.b.c.tar.gz
|
|
71 |
$ cp -R proj-a.b.c/* proj
|
|
72 |
$ cd proj
|
|
73 |
$ hg addremove -s 70
|
|
74 |
$ hg ci -m "Added a.b.c version of proj."
|
|
75 |
$ hg qpush -a
|
|
76 |
|