Mercurial > evolve
comparison tests/test-grab.t @ 3453:32ed5b6fadd3
grab: add a command to grab a commit and update to it
This patch adds anew command `hg grab` which will pick a commit and put it on
the top of the working directory parent and updates to it.
Earlier grab was an alias for `hg rebase -r <rev> -d .` which is now deleted to
make sure `hg grab` resolves to the grab command and that alias.
Continuing interrupted grab functionality is also there using the evolvestate
class.
Tests are also added for the new introduced command.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Thu, 11 Jan 2018 20:03:20 +0530 |
parents | |
children | b2f591aa4507 |
comparison
equal
deleted
inserted
replaced
3449:4a1dc4854648 | 3453:32ed5b6fadd3 |
---|---|
1 Test for the grab command | |
2 | |
3 $ cat >> $HGRCPATH <<EOF | |
4 > [alias] | |
5 > glog = log -G -T "{rev}:{node|short} {desc}\n" | |
6 > [extensions] | |
7 > EOF | |
8 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH | |
9 | |
10 $ mkcommit() { | |
11 > echo "$1" > "$1" | |
12 > hg add "$1" | |
13 > hg ci -m "add $1" | |
14 > } | |
15 | |
16 $ hg init repo | |
17 $ cd repo | |
18 $ hg help grab | |
19 hg grab [-r] rev | |
20 | |
21 grabs a commit, move it on the top of working directory parent and | |
22 updates to it. | |
23 | |
24 options: | |
25 | |
26 -r --rev VALUE revision to grab | |
27 --continue continue interrupted grab | |
28 --abort abort interrupted grab | |
29 | |
30 (some details hidden, use --verbose to show complete help) | |
31 | |
32 $ mkcommit a | |
33 $ mkcommit b | |
34 $ mkcommit c | |
35 | |
36 $ hg glog | |
37 @ 2:4538525df7e2 add c | |
38 | | |
39 o 1:7c3bad9141dc add b | |
40 | | |
41 o 0:1f0dee641bb7 add a | |
42 | |
43 | |
44 Grabbing an ancestor | |
45 | |
46 $ hg grab -r 7c3bad9141dc | |
47 abort: cannot grab an ancestor revision | |
48 [255] | |
49 | |
50 Specifying multiple revisions to grab | |
51 | |
52 $ hg grab 1f0dee641bb7 -r 7c3bad9141dc | |
53 abort: specify just one revision | |
54 [255] | |
55 | |
56 Specifying no revisions to grab | |
57 | |
58 $ hg grab | |
59 abort: empty revision set | |
60 [255] | |
61 | |
62 Continuing without interrupted grab | |
63 | |
64 $ hg grab --continue | |
65 abort: no interrupted grab state exists | |
66 [255] | |
67 | |
68 Aborting without interrupted grab | |
69 | |
70 $ hg grab --abort | |
71 abort: no interrupted grab state exists | |
72 [255] | |
73 | |
74 Specifying both continue and revs | |
75 | |
76 $ hg up 1f0dee641bb7 | |
77 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
78 $ hg grab -r 4538525df7e2 --continue | |
79 abort: cannot specify both --continue and revision | |
80 [255] | |
81 | |
82 Making new branch heads | |
83 | |
84 $ mkcommit x | |
85 created new head | |
86 $ mkcommit y | |
87 | |
88 $ hg glog | |
89 @ 4:d46dc301d92f add y | |
90 | | |
91 o 3:8e224524cd09 add x | |
92 | | |
93 | o 2:4538525df7e2 add c | |
94 | | | |
95 | o 1:7c3bad9141dc add b | |
96 |/ | |
97 o 0:1f0dee641bb7 add a | |
98 | |
99 Grabbing a revision | |
100 | |
101 $ hg grab 7c3bad9141dc | |
102 grabbing 1:7c3bad9141dc "add b" | |
103 1 new orphan changesets | |
104 $ hg glog | |
105 @ 5:7c15c05db6fa add b | |
106 | | |
107 o 4:d46dc301d92f add y | |
108 | | |
109 o 3:8e224524cd09 add x | |
110 | | |
111 | * 2:4538525df7e2 add c | |
112 | | | |
113 | x 1:7c3bad9141dc add b | |
114 |/ | |
115 o 0:1f0dee641bb7 add a | |
116 | |
117 | |
118 When grab does not create any changes | |
119 | |
120 $ hg graft -r 4538525df7e2 | |
121 grafting 2:4538525df7e2 "add c" | |
122 | |
123 $ hg glog | |
124 @ 6:c4636a81ebeb add c | |
125 | | |
126 o 5:7c15c05db6fa add b | |
127 | | |
128 o 4:d46dc301d92f add y | |
129 | | |
130 o 3:8e224524cd09 add x | |
131 | | |
132 | * 2:4538525df7e2 add c | |
133 | | | |
134 | x 1:7c3bad9141dc add b | |
135 |/ | |
136 o 0:1f0dee641bb7 add a | |
137 | |
138 $ hg grab -r 4538525df7e2 | |
139 grabbing 2:4538525df7e2 "add c" | |
140 note: grab of 2:4538525df7e2 created no changes to commit | |
141 | |
142 $ hg glog | |
143 @ 6:c4636a81ebeb add c | |
144 | | |
145 o 5:7c15c05db6fa add b | |
146 | | |
147 o 4:d46dc301d92f add y | |
148 | | |
149 o 3:8e224524cd09 add x | |
150 | | |
151 o 0:1f0dee641bb7 add a | |
152 | |
153 interrupted grab | |
154 | |
155 $ hg up d46dc301d92f | |
156 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
157 $ echo foo > c | |
158 $ hg ci -Aqm "foo to c" | |
159 $ hg grab -r c4636a81ebeb | |
160 grabbing 6:c4636a81ebeb "add c" | |
161 merging c | |
162 warning: conflicts while merging c! (edit, then use 'hg resolve --mark') | |
163 unresolved merge conflicts (see hg help resolve) | |
164 [1] | |
165 | |
166 $ echo foobar > c | |
167 $ hg resolve --all --mark | |
168 (no more unresolved files) | |
169 $ hg grab --continue | |
170 $ hg glog | |
171 @ 8:44e155eb95c7 add c | |
172 | | |
173 o 7:2ccc03d1d096 foo to c | |
174 | | |
175 | o 5:7c15c05db6fa add b | |
176 |/ | |
177 o 4:d46dc301d92f add y | |
178 | | |
179 o 3:8e224524cd09 add x | |
180 | | |
181 o 0:1f0dee641bb7 add a | |
182 | |
183 Testing the abort functionality of hg grab | |
184 | |
185 $ echo foo > b | |
186 $ hg ci -Aqm "foo to b" | |
187 $ hg glog -r .^:: | |
188 @ 9:902d4f4602bb foo to b | |
189 | | |
190 o 8:44e155eb95c7 add c | |
191 | | |
192 ~ | |
193 | |
194 $ hg grab -r 7c15c05db6fa | |
195 grabbing 5:7c15c05db6fa "add b" | |
196 merging b | |
197 warning: conflicts while merging b! (edit, then use 'hg resolve --mark') | |
198 unresolved merge conflicts (see hg help resolve) | |
199 [1] | |
200 | |
201 $ hg grab --abort | |
202 aborting grab, updating to 902d4f4602bb | |
203 | |
204 $ hg glog | |
205 @ 9:902d4f4602bb foo to b | |
206 | | |
207 o 8:44e155eb95c7 add c | |
208 | | |
209 o 7:2ccc03d1d096 foo to c | |
210 | | |
211 | o 5:7c15c05db6fa add b | |
212 |/ | |
213 o 4:d46dc301d92f add y | |
214 | | |
215 o 3:8e224524cd09 add x | |
216 | | |
217 o 0:1f0dee641bb7 add a | |
218 | |
219 | |
220 Trying to grab a public changeset | |
221 | |
222 $ hg phase -r 7c15c05db6fa -p | |
223 | |
224 $ hg grab -r 7c15c05db6fa | |
225 abort: cannot grab public changesets: 7c15c05db6fa | |
226 (see 'hg help phases' for details) | |
227 [255] | |
228 | |
229 $ hg glog | |
230 @ 9:902d4f4602bb foo to b | |
231 | | |
232 o 8:44e155eb95c7 add c | |
233 | | |
234 o 7:2ccc03d1d096 foo to c | |
235 | | |
236 | o 5:7c15c05db6fa add b | |
237 |/ | |
238 o 4:d46dc301d92f add y | |
239 | | |
240 o 3:8e224524cd09 add x | |
241 | | |
242 o 0:1f0dee641bb7 add a | |
243 |