|
1 .. Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
|
2 .. Logilab SA <contact@logilab.fr> |
|
3 |
|
4 ------------- |
|
5 Evolve How To |
|
6 ------------- |
|
7 |
|
8 |
|
9 |
|
10 Add a changeset: ``commit`` |
|
11 --------------------------- |
|
12 |
|
13 Just use commit as usual. New changesets will be in the `draft` phase. |
|
14 |
|
15 Rewrite a changeset: ``commit --amend`` |
|
16 --------------------------------------- |
|
17 |
|
18 It writes a new changeset combining working-directory parent changes and parent. |
|
19 It will work on any `draft` or `secret` changeset. It will not work on `public` |
|
20 changesets. |
|
21 |
|
22 To understand what the result of amend will be I use the two following |
|
23 aliases [#]_:: |
|
24 |
|
25 # diff what amend will look like |
|
26 pdiff=diff --rev .^ |
|
27 |
|
28 # status what amend will look like |
|
29 pstatus=status --rev .^ |
|
30 |
|
31 This command can even be invoked on changesets with children, provided |
|
32 none are public. |
|
33 |
|
34 .. [#] (defined by the evolve extension for you) |
|
35 |
|
36 |
|
37 |
|
38 Move a changeset: ``grab`` |
|
39 -------------------------- |
|
40 |
|
41 You can use ``hg grab <rev>`` to move a rev at your current location, making the |
|
42 old version obsolete. |
|
43 |
|
44 .. note:: grab is an alias for ``hg rebase --dest . --rev $@; hg up <result>`` |
|
45 |
|
46 |
|
47 Delete a changeset: ``prune`` |
|
48 ----------------------------- |
|
49 |
|
50 A new ``prune`` command allows removing a changeset. |
|
51 |
|
52 Just use ``hg prune <some-rev>``. |
|
53 |
|
54 |
|
55 Moving within the history: ``gdown`` and ``gup`` |
|
56 ------------------------------------------------ |
|
57 |
|
58 While working on mutable part of the history you often need to move between |
|
59 mutable commits. |
|
60 |
|
61 You just need to use standard update to work with evolve. For convenience, you |
|
62 can use ``hg gup`` to move to the child commit or ``hg gdown`` to move to the parent commit. |
|
63 |
|
64 Those command have ``previous`` and ``next`` alias. |
|
65 |
|
66 .. note:: Those commands only exist for the convenience of getting qpush and qpop |
|
67 feeling back. |
|
68 |
|
69 Collapse changesets: ``fold`` |
|
70 ----------------------------- |
|
71 |
|
72 You can use ``hg fold`` to collapse multiple changesets in a single one. |
|
73 |
|
74 It takes two forms: |
|
75 |
|
76 ``hg fold <rev>`` folds everything from you current changeset to `<rev>` |
|
77 |
|
78 ``hg fold -r <revset>`` fold everything changeset matching the revset together. |
|
79 |
|
80 Getting changes out of a commit |
|
81 ------------------------------- |
|
82 |
|
83 The ``hg uncommit`` command lets you rewrite the parent commit without |
|
84 selected changed files. Target files content is not altered and |
|
85 appears again as "modified":: |
|
86 |
|
87 $ hg st |
|
88 M babar |
|
89 M celestine |
|
90 $ hg commit babar celestine |
|
91 $ hg st |
|
92 $ hg uncommit celestine |
|
93 $ hg status |
|
94 M celestine |
|
95 |
|
96 Split a changeset |
|
97 ----------------- |
|
98 |
|
99 To split on file boundaries, just use ``uncommit`` command. |
|
100 |
|
101 If you need a fine-grained split, there is no official command for that yet. |
|
102 However, it is easily achieved by manual operation:: |
|
103 |
|
104 ### you want to split changeset A: 42 |
|
105 # update to A parent |
|
106 $ hg up 42^ |
|
107 # restore content from A |
|
108 $ hg revert -r 42 --all |
|
109 # partially commit the first part |
|
110 $ hg record |
|
111 # commit the second part |
|
112 $ hg commit |
|
113 # informs mercurial of what happened |
|
114 # current changeset (.) and previous one (.^) replace A (42) |
|
115 $ hg prune --new . --new .^ 42 |
|
116 |
|
117 For more complexe scenario we recommend the use of the histedit_ extension. |
|
118 |
|
119 .. _histedit: https://www.mercurial-scm.org/wiki/HisteditExtension |
|
120 |
|
121 |
|
122 Update my current work in progress after a pull |
|
123 ----------------------------------------------- |
|
124 |
|
125 Whenever you are working on some changesets, it is more likely that a pull |
|
126 will, eventually, import new changesets in your tree. |
|
127 |
|
128 And it is likely that you will want your work in progress changesets to be |
|
129 rebased on the top of this newly imported subtree. |
|
130 |
|
131 Doing so is only a matter of rebasing. |
|
132 |
|
133 |
|
134 |
|
135 Move multiple changesets: ``rebase`` |
|
136 ------------------------------------ |
|
137 |
|
138 You can still use rebase to move a whole segment of the changeset graph together. |
|
139 |
|
140 .. warning:: Beware that rebasing changesets already obsolete will likely result in |
|
141 divergent versions of the changesets. |
|
142 |
|
143 Resolve history troubles: ``evolve`` |
|
144 ------------------------------------ |
|
145 |
|
146 When you rewrite (amend) a changeset with children without rewriting |
|
147 those children you create *unstable* changesets and *suspended |
|
148 obsolete* changesets. |
|
149 |
|
150 When you are finished amending a given changeset, you will want to |
|
151 declare it stable, in other words rebase its former descendants on its |
|
152 newest version. |
|
153 |
|
154 You can also use evolve to solve `bumped` and `divergent` changeset/ |
|
155 |
|
156 |
|
157 Fix my history afterward: ``prune -n`` |
|
158 -------------------------------------- |
|
159 |
|
160 Sometimes you need to create an obsolete marker by hand. This may happen when |
|
161 upstream has applied some of your patches for example. |
|
162 |
|
163 you can use ``hg prune <old-changeset> --succ <new-changeset>`` to add obsolete |
|
164 marker. |
|
165 |
|
166 View diff from the last amend |
|
167 ----------------------------- |
|
168 |
|
169 An ``odiff`` alias have been added by ``enable.sh`` |
|
170 |
|
171 :: |
|
172 [alias] |
|
173 odiff = diff --rev 'limit(precursors(.),1)' --rev . |
|
174 |
|
175 View obsolete markers |
|
176 --------------------- |
|
177 |
|
178 hgview_ is the only viewer that currently supports this feature. You |
|
179 need version 1.6.2 |
|
180 |
|
181 .. _hgview: http://www.logilab.org/project/hgview/ |
|
182 |
|
183 .. image:: figures/hgview-example.png |
|
184 :scale: 50% |
|
185 |
|
186 |
|
187 You can also use a debug command |
|
188 |
|
189 $ hg debugobsolete |
|
190 5eb72dbe0cb4 e8db4aa611f6 |
|
191 c4cbebac3751 4f1c269eab68 |
|
192 |
|
193 |
|
194 |
|
195 Important Note |
|
196 ============== |
|
197 |
|
198 View change to your file |
|
199 ------------------------ |
|
200 |
|
201 Extinct changesets are hidden using the *hidden* feature of mercurial. |
|
202 |
|
203 Only ``hg log`` and ``hgview`` support it, other |
|
204 graphical viewer do not. |
|
205 |
|
206 You can use ``hg log --graph --hidden`` from the command line |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |