slitaz-doc-wiki-data view pages/en/cookbook/advancedhg.txt @ rev 7

Add pages/en folder.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Feb 26 12:17:18 2011 +0000 (2011-02-26)
parents
children
line source
1 ====== Advanced usage of Mercurial ======
3 ==== Use an external tool to merge ====
5 If you want to use tools presented on this page, MQ particularly has a tool to manage merges (when several commits overwrite each other and you have to edit the result manually) which will probably be useful to you. SliTaz proposes Meld, a light software that can do that well. After installation, tell Mercurial to use it if necessary by putting it in your ~/.hgrc:
7 <code>
8 [ui]
9 merge = meld
10 </code>
12 ==== Useful extensions ====
14 To add an extension, you can use the ~/.hgrc file:
15 <code>
16 [extensions]
17 name = adress
18 </code>
19 Some extensions are packed within Mercurial, so it's not necessary to give them addressess. It's the case of the four following:
21 **color**
22 Add color in Mercurial. Useful when displaying differences between several versions of a file.
24 **hgext.fetch**
25 Add the command hg fetch, which regroups hg pull && hg merge && hg update.
27 **hgext.graphlog**
28 Add the command glog, which displays the revision tree along with the log. It's advised to limit the length of the log with option -l (i.e.: -l 10). Option -p displays the detail of differences introduced at each commit.
30 **mq**
31 This tool is explained in detail below. It allows you to manage a patch-list for a Mercurial repository: apply them, unapply, update, etc. This extension adds several commands which generally start with 'q'. Some webpages detail this tool, search: mercurial mq.
34 ==== Basic functionality of MQ ====
35 In a mercurial repository, create a patch repository with a controlled revision; it's a repository of patches into which the changes can be committed using Mercurial, like a repository within a repository:
36 <code>hg qinit -c</code>
38 Après avoir procédé à des modifications, les enregistrer en temps que patch plutôt que les commiter :
39 After modifications, save them as a patch instead of committing them:
40 <code>hg qnew nom_du_patch</code>
42 List applied/unapplied patches:
43 <code>hg qseries -v</code>
45 Add changes to the current patch (the last one applied):
46 <code>hg qrefresh</code>
48 Apply the next patch from the queue:
49 <code>hg qpush</code>
51 Apply all patches:
52 <code>hg qpush -a</code>
54 Unapply current patch:
55 <code>hg qpop</code>
57 Unapply all patches:
58 <code>hg qpop -a</code>
60 Go to a given patch in the queue:
61 <code>hg qgoto patch</code>
63 Add a message to the current patch (before committing it):
64 <code>hg qrefresh -m "Message"</code>
66 Transform a patch into a commit:
67 <code>hg qfinish patch</code>
69 Commit changes made in the patch repository:
70 <code>hg qcommit -m "Message de commit"</code>
72 Note: Patches are saved into .hg/patches. The file .hg/patches/series can be manually edited to change the application order of the patches; but take care if several patches have the same target file: it can create problems.
74 ==== MQ & Merge ====
76 **General idea**
78 Patches can be updated using the merge tool of Mercurial: it's easier than editing them manually. To do this, it's necessary to have two heads in the repository. One being the repository with patches applied ontop; the other the repository with the new commits/updates/etc:
80 <code>
81 o New repository revision
82 |
83 |
84 | o Patches
85 | |
86 | /
87 |
88 o Repository before patch application
89 </code>
91 The patches branch will next be merged into the new branch and MQ will use the merge function from Mercurial to update the patches. Please note that using an external merge tool (such as meld proposed previously) is highly recommended.
93 Create the head patches:
94 <code>
95 qpush -a
96 hg tags # Remember/Note the number of the revision qparent
97 qsave -e -c # Save the status of the patches, this save will be used during the merge. (Remember/Note the number at the end of patches.N; it's generally 1)
98 </code>
100 Create the new head:
101 <code>
102 hg update -C <N°qparent> # Go to the revision noted before.
104 # Next, do what you planned to:
105 # Update:
106 hg pull -u
107 # Commit new changes, make the modifications then:
108 hg commit -m "message"
109 # Edit a patch:
110 hg qgoto patch # Then do the modifications and:
111 hg qrefresh</code>
113 To launch the merge:
114 <code>hg qpush -a -m</code>
116 Clean the repository:
117 <code>
118 hg qpop -a
119 hg qpop -a -n patches.N
120 rm -r .hg/patches.N
121 </code>
123 Save the changes made into the patch repository:
124 <code>hg qcommit -m "Updated to match rev???"</code>
126 Re-apply the patch queue:
127 <code>hg qpush -a</code>