comparison tests/test-split.t @ 1478:9603aa1ecdfd

evolve: add a command to split commits Before this patch, to split commit one had to use prune. This patch adds a new command called split that prompts the user interactively to split a given changeset with record/crecord.
author Laurent Charignon <lcharignon@fb.com>
date Thu, 18 Jun 2015 16:48:53 -0700
parents
children c7726b19c7a0
comparison
equal deleted inserted replaced
1477:6ab5c0f40699 1478:9603aa1ecdfd
1 test of the split command
2 -----------------------
3
4 $ cat >> $HGRCPATH <<EOF
5 > [defaults]
6 > amend=-d "0 0"
7 > fold=-d "0 0"
8 > split=-d "0 0"
9 > amend=-d "0 0"
10 > [web]
11 > push_ssl = false
12 > allow_push = *
13 > [phases]
14 > publish = False
15 > [diff]
16 > git = 1
17 > unified = 0
18 > [ui]
19 > interactive = true
20 > [extensions]
21 > hgext.graphlog=
22 > EOF
23 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
24 $ mkcommit() {
25 > echo "$1" > "$1"
26 > hg add "$1"
27 > hg ci -m "add $1"
28 > }
29
30
31 Basic case, split a head
32 $ hg init testsplit
33 $ cd testsplit
34 $ mkcommit _a
35 $ mkcommit _b
36 $ mkcommit _c
37 $ mkcommit _d
38 $ echo "change to a" >> _a
39 $ hg amend
40 $ hg debugobsolete
41 9e84a109b8eb081ad754681ee4b1380d17a3741f aa8f656bb307022172d2648be6fb65322f801225 0 (*) {'user': 'test'} (glob)
42 f002b57772d7f09b180c407213ae16d92996a988 0 {9e84a109b8eb081ad754681ee4b1380d17a3741f} (*) {'user': 'test'} (glob)
43
44 To create commits with the number of split
45 $ export NUM=0
46 $ export HGEDITOR="NUM=$((NUM+1)); echo split$NUM > $1"
47 $ hg split << EOF
48 > y
49 > y
50 > y
51 > n
52 > N
53 > y
54 > y
55 > EOF
56 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
57 reverting _a
58 adding _d
59 diff --git a/_a b/_a
60 1 hunks, 1 lines changed
61 examine changes to '_a'? [Ynesfdaq?] y
62
63 @@ -1,0 +2,1 @@
64 +change to a
65 record change 1/2 to '_a'? [Ynesfdaq?] y
66
67 diff --git a/_d b/_d
68 new file mode 100644
69 examine changes to '_d'? [Ynesfdaq?] y
70
71 @@ -0,0 +1,1 @@
72 +_d
73 record change 2/2 to '_d'? [Ynesfdaq?] n
74
75 created new head
76 Done splitting? [yN] N
77 diff --git a/_d b/_d
78 new file mode 100644
79 examine changes to '_d'? [Ynesfdaq?] y
80
81 @@ -0,0 +1,1 @@
82 +_d
83 record this change to '_d'? [Ynesfdaq?] y
84
85 no more change to split
86
87 $ hg debugobsolete
88 9e84a109b8eb081ad754681ee4b1380d17a3741f aa8f656bb307022172d2648be6fb65322f801225 0 (*) {'user': 'test'} (glob)
89 f002b57772d7f09b180c407213ae16d92996a988 0 {9e84a109b8eb081ad754681ee4b1380d17a3741f} (*) {'user': 'test'} (glob)
90 aa8f656bb307022172d2648be6fb65322f801225 8a76f55839e6badd47ed8338803d8bc16f578d68 1e105584671a463974ee2122f95979ce5e507f1a 0 (*) {'user': 'test'} (glob)
91
92 Cannot split a commit with uncommited changes
93 $ hg up "desc(_c)"
94 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
95 $ echo "_cd" > _c
96 $ hg split
97 abort: uncommitted changes
98 [255]
99
100 Split a revision specified with -r
101 $ hg up "desc(_c)" -C
102 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
103 $ echo "change to b" >> _b
104 $ hg amend -m "_cprim"
105 2 new unstable changesets
106 $ hg evolve --all
107 move:[6] split0
108 atop:[9] _cprim
109 move:[7] split0
110 atop:[10] split0
111 working directory is now at * (glob)
112 $ hg log -r "desc(_cprim)" -v -p
113 changeset: 9:719157b217ac
114 parent: 1:37445b16603b
115 user: test
116 date: Thu Jan 01 00:00:00 1970 +0000
117 files: _b _c
118 description:
119 _cprim
120
121
122 diff --git a/_b b/_b
123 --- a/_b
124 +++ b/_b
125 @@ -1,0 +2,1 @@
126 +change to b
127 diff --git a/_c b/_c
128 new file mode 100644
129 --- /dev/null
130 +++ b/_c
131 @@ -0,0 +1,1 @@
132 +_c
133
134 $ hg split -r "desc(_cprim)" <<EOF
135 > y
136 > y
137 > y
138 > n
139 > y
140 > EOF
141 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
142 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
143 reverting _b
144 adding _c
145 diff --git a/_b b/_b
146 1 hunks, 1 lines changed
147 examine changes to '_b'? [Ynesfdaq?] y
148
149 @@ -1,0 +2,1 @@
150 +change to b
151 record change 1/2 to '_b'? [Ynesfdaq?] y
152
153 diff --git a/_c b/_c
154 new file mode 100644
155 examine changes to '_c'? [Ynesfdaq?] y
156
157 @@ -0,0 +1,1 @@
158 +_c
159 record change 2/2 to '_c'? [Ynesfdaq?] n
160
161 created new head
162 Done splitting? [yN] y
163
164 Stop before splitting the commit completely creates a commit with all the
165 remaining changes
166
167 $ hg debugobsolete
168 9e84a109b8eb081ad754681ee4b1380d17a3741f aa8f656bb307022172d2648be6fb65322f801225 0 (*) {'user': 'test'} (glob)
169 f002b57772d7f09b180c407213ae16d92996a988 0 {9e84a109b8eb081ad754681ee4b1380d17a3741f} (*) {'user': 'test'} (glob)
170 aa8f656bb307022172d2648be6fb65322f801225 8a76f55839e6badd47ed8338803d8bc16f578d68 1e105584671a463974ee2122f95979ce5e507f1a 0 (*) {'user': 'test'} (glob)
171 10200229058723ce8d67f6612c1f6b4f73b1fe73 719157b217acc43d397369a448824ed4c7a302f2 0 (*) {'user': 'test'} (glob)
172 5d0c8b0f2d3e5e1ff95f93d7da2ba06650605ab5 0 {10200229058723ce8d67f6612c1f6b4f73b1fe73} (*) {'user': 'test'} (glob)
173 8a76f55839e6badd47ed8338803d8bc16f578d68 0ea1d0d23e674ea8a6affe760741c82bb8e380f7 0 (*) {'user': 'test'} (glob)
174 1e105584671a463974ee2122f95979ce5e507f1a b6099ccb49cae181af7c59ed5603a1dfca632445 0 (*) {'user': 'test'} (glob)
175 719157b217acc43d397369a448824ed4c7a302f2 8eb71353cb2c70fc1154be3af79c0ce98898ae88 ead904640c8543606f72490c6ae10955fb11fff0 0 (*) {'user': 'test'} (glob)
176
177 Cannot specify multiple revisions with -r
178 $ hg split -r "desc(_a)::"
179 abort: you can only specify one revision to split
180 [255]
181
182 Cannot split a commit that is not a head if instability is not allowed
183 $ cat >> $HGRCPATH <<EOF
184 > [experimental]
185 > evolution=createmarkers
186 > evolutioncommands=split
187 > EOF
188 $ hg split -r "desc(_c)"
189 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 abort: cannot split commit: 719157b217ac not a head
191 [255]
192
193