|
1 $ cat >> $HGRCPATH <<EOF |
|
2 > [defaults] |
|
3 > amend=-d "0 0" |
|
4 > [web] |
|
5 > push_ssl = false |
|
6 > allow_push = * |
|
7 > [phases] |
|
8 > publish = False |
|
9 > [alias] |
|
10 > qlog = log --template='{rev} - {node|short} {desc} ({phase})\n' |
|
11 > [diff] |
|
12 > git = 1 |
|
13 > unified = 0 |
|
14 > [extensions] |
|
15 > hgext.rebase= |
|
16 > hgext.graphlog= |
|
17 > EOF |
|
18 $ echo "obsolete=$(echo $(dirname $TESTDIR))/hgext/obsolete.py" >> $HGRCPATH |
|
19 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH |
|
20 $ mkcommit() { |
|
21 > echo "$1" > "$1" |
|
22 > hg add "$1" |
|
23 > hg ci -m "add $1" |
|
24 > } |
|
25 |
|
26 various init |
|
27 |
|
28 $ hg init local |
|
29 $ cd local |
|
30 $ mkcommit a |
|
31 $ mkcommit b |
|
32 $ cat >> .hg/hgrc << EOF |
|
33 > [phases] |
|
34 > publish = True |
|
35 > EOF |
|
36 $ hg pull -q . # make 1 public |
|
37 $ rm .hg/hgrc |
|
38 $ mkcommit c |
|
39 $ mkcommit d |
|
40 $ hg up 1 |
|
41 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
42 $ mkcommit e -q |
|
43 created new head |
|
44 $ mkcommit f |
|
45 $ hg qlog |
|
46 5 - e44648563c73 add f (draft) |
|
47 4 - fbb94e3a0ecf add e (draft) |
|
48 3 - 47d2a3944de8 add d (draft) |
|
49 2 - 4538525df7e2 add c (draft) |
|
50 1 - 7c3bad9141dc add b (public) |
|
51 0 - 1f0dee641bb7 add a (public) |
|
52 |
|
53 test simple kill |
|
54 |
|
55 $ hg kill 5 |
|
56 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
57 working directory now at fbb94e3a0ecf |
|
58 $ hg qlog |
|
59 4 - fbb94e3a0ecf add e (draft) |
|
60 3 - 47d2a3944de8 add d (draft) |
|
61 2 - 4538525df7e2 add c (draft) |
|
62 1 - 7c3bad9141dc add b (public) |
|
63 0 - 1f0dee641bb7 add a (public) |
|
64 |
|
65 test multiple kill |
|
66 |
|
67 $ hg kill 4 3 |
|
68 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
69 working directory now at 7c3bad9141dc |
|
70 $ hg qlog |
|
71 2 - 4538525df7e2 add c (draft) |
|
72 1 - 7c3bad9141dc add b (public) |
|
73 0 - 1f0dee641bb7 add a (public) |
|
74 $ cd .. |
|
75 |
|
76 ########################## |
|
77 importing Parren test |
|
78 ########################## |
|
79 |
|
80 $ cat << EOF >> $HGRCPATH |
|
81 > [ui] |
|
82 > logtemplate = "{rev}\t{bookmarks}: {desc|firstline} - {author|user}\n" |
|
83 > EOF |
|
84 |
|
85 Creating And Updating Changeset |
|
86 =============================== |
|
87 |
|
88 Setup the Base Repo |
|
89 ------------------- |
|
90 |
|
91 We start with a plain base repo:: |
|
92 |
|
93 $ hg init main; cd main |
|
94 $ cat >main-file-1 <<-EOF |
|
95 > One |
|
96 > |
|
97 > Two |
|
98 > |
|
99 > Three |
|
100 > EOF |
|
101 $ echo Two >main-file-2 |
|
102 $ hg add |
|
103 adding main-file-1 |
|
104 adding main-file-2 |
|
105 $ hg commit --message base |
|
106 $ cd .. |
|
107 |
|
108 and clone this into a new repo where we do our work:: |
|
109 |
|
110 $ hg clone main work |
|
111 updating to branch default |
|
112 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
113 $ cd work |
|
114 |
|
115 |
|
116 Create First Patch |
|
117 ------------------ |
|
118 |
|
119 To begin with, we just do the changes that will be the initial version of the changeset:: |
|
120 |
|
121 $ echo One >file-from-A |
|
122 $ sed -i'' -e s/One/Eins/ main-file-1 |
|
123 $ hg add file-from-A |
|
124 |
|
125 So this is what we would like our changeset to be:: |
|
126 |
|
127 $ hg diff |
|
128 diff --git a/file-from-A b/file-from-A |
|
129 new file mode 100644 |
|
130 --- /dev/null |
|
131 +++ b/file-from-A |
|
132 @@ -0,0 +1,1 @@ |
|
133 +One |
|
134 diff --git a/main-file-1 b/main-file-1 |
|
135 --- a/main-file-1 |
|
136 +++ b/main-file-1 |
|
137 @@ -1,1 +1,1 @@ |
|
138 -One |
|
139 +Eins |
|
140 |
|
141 To commit it we just - commit it:: |
|
142 |
|
143 $ hg commit --message "a nifty feature" |
|
144 |
|
145 and place a bookmark so we can easily refer to it again (which we could have done before the commit):: |
|
146 |
|
147 $ hg book feature-A |
|
148 |
|
149 |
|
150 Create Second Patch |
|
151 ------------------- |
|
152 |
|
153 Let's do this again for the second changeset:: |
|
154 |
|
155 $ echo Two >file-from-B |
|
156 $ sed -i'' -e s/Two/Zwie/ main-file-1 |
|
157 $ hg add file-from-B |
|
158 |
|
159 Before committing, however, we need to switch to a new bookmark for the second |
|
160 changeset. Otherwise we would inadvertently move the bookmark for our first changeset. |
|
161 It is therefore advisable to always set the bookmark before committing:: |
|
162 |
|
163 $ hg book feature-B |
|
164 $ hg commit --message "another feature" |
|
165 |
|
166 So here we are:: |
|
167 |
|
168 $ hg book |
|
169 feature-A 1:568a468b60fc |
|
170 * feature-B 2:7b36850622b2 |
|
171 |
|
172 |
|
173 Fix The Second Patch |
|
174 -------------------- |
|
175 |
|
176 There's a typo in feature-B. We spelled *Zwie* instead of *Zwei*:: |
|
177 |
|
178 $ hg diff --change tip | grep -F Zwie |
|
179 +Zwie |
|
180 |
|
181 Fixing this is very easy. Just change:: |
|
182 |
|
183 $ sed -i'' -e s/Zwie/Zwei/ main-file-1 |
|
184 |
|
185 and **amend**:: |
|
186 |
|
187 $ hg amend --note "fix spelling of Zwei" |
|
188 |
|
189 The `--note` is our commit message for the *update* only. So its only purpose |
|
190 is to document the evolution of the changeset. If we use `--message` with |
|
191 `amend`, it replaces the commit message of the changeset itself. |
|
192 |
|
193 This results in a new single changeset for our amended changeset, and the old |
|
194 changeset plus the updating changeset are hidden from view by default:: |
|
195 |
|
196 $ hg log |
|
197 4 feature-B: another feature - test |
|
198 1 feature-A: a nifty feature - test |
|
199 0 : base - test |
|
200 |
|
201 $ hg up feature-A -q |
|
202 $ sed -i'' -e s/Eins/Un/ main-file-1 |
|
203 |
|
204 $ hg amend --note 'french looks better' |
|
205 $ hg log |
|
206 6 feature-A: a nifty feature - test |
|
207 4 feature-B: another feature - test |
|
208 1 : a nifty feature - test |
|
209 0 : base - test |
|
210 $ hg stabilize |
|
211 hg rebase -Dr f8111a076f09 -d 23409eba69a0 |
|
212 $ hg up null -q #prevent feature-A bookmark to move # XXX grml |
|
213 $ hg bookmark |
|
214 feature-A 6:23409eba69a0 |
|
215 feature-B 4:f8111a076f09 |
|
216 $ hg up 6 |
|
217 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
218 $ hg bookmark |
|
219 feature-A 6:23409eba69a0 |
|
220 feature-B 4:f8111a076f09 |
|
221 $ hg bookmark -if feature-A |
|
222 $ hg graft -O 4 |
|
223 grafting revision 4 |
|
224 merging main-file-1 |
|
225 $ hg bookmark -ifr 7 feature-B # XXX not bookmark support in rebase --keep :-/ |
|
226 $ hg log |
|
227 7 feature-B: another feature - test |
|
228 6 feature-A: a nifty feature - test |
|
229 0 : base - test |
|
230 |
|
231 Test commit -o options |
|
232 |
|
233 $ hg up 6 |
|
234 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
235 $ hg revert -r 7 --all |
|
236 adding file-from-B |
|
237 reverting main-file-1 |
|
238 $ sed -i'' -e s/Zwei/deux/ main-file-1 |
|
239 $ hg commit -m 'another feature that rox' -o 7 |
|
240 created new head |
|
241 $ hg log |
|
242 8 feature-B: another feature that rox - test |
|
243 6 feature-A: a nifty feature - test |
|
244 0 : base - test |