##// END OF EJS Templates
tests: histedit-helpers fixbundle should not complain about no input
timeless -
r27350:89027334 default
parent child Browse files
Show More
@@ -1,6 +1,7
1 1 fixbundle() {
2 2 grep -v 'saving bundle' | grep -v 'saved backup' | \
3 3 grep -v added | grep -v adding | \
4 4 grep -v "unable to find 'e' for patching" | \
5 grep -v "e: No such file or directory"
5 grep -v "e: No such file or directory" | \
6 cat
6 7 }
@@ -1,212 +1,211
1 1 test for old histedit issue #6:
2 2 editing a changeset without any actual change would corrupt the repository
3 3
4 4 $ . "$TESTDIR/histedit-helpers.sh"
5 5
6 6 $ cat >> $HGRCPATH <<EOF
7 7 > [extensions]
8 8 > histedit=
9 9 > EOF
10 10
11 11 $ initrepo ()
12 12 > {
13 13 > dir="$1"
14 14 > comment="$2"
15 15 > if [ -n "${comment}" ]; then
16 16 > echo % ${comment}
17 17 > echo % ${comment} | sed 's:.:-:g'
18 18 > fi
19 19 > hg init ${dir}
20 20 > cd ${dir}
21 21 > for x in a b c d e f ; do
22 22 > echo $x > $x
23 23 > hg add $x
24 24 > hg ci -m $x
25 25 > done
26 26 > cd ..
27 27 > }
28 28
29 29 $ geneditor ()
30 30 > {
31 31 > # generate an editor script for selecting changesets to be edited
32 32 > choice=$1 # changesets that should be edited (using sed line ranges)
33 33 > cat <<EOF | sed 's:^....::'
34 34 > # editing the rules, replacing 'pick' with 'edit' for the chosen lines
35 35 > sed '${choice}s:^pick:edit:' "\$1" > "\${1}.tmp"
36 36 > mv "\${1}.tmp" "\$1"
37 37 > # displaying the resulting rules, minus comments and empty lines
38 38 > sed '/^#/d;/^$/d;s:^:| :' "\$1" >&2
39 39 > EOF
40 40 > }
41 41
42 42 $ startediting ()
43 43 > {
44 44 > # begin an editing session
45 45 > choice="$1" # changesets that should be edited
46 46 > number="$2" # number of changesets considered (from tip)
47 47 > comment="$3"
48 48 > geneditor "${choice}" > edit.sh
49 49 > echo % start editing the history ${comment}
50 50 > HGEDITOR="sh ./edit.sh" hg histedit -- -${number} 2>&1 | fixbundle
51 51 > }
52 52
53 53 $ continueediting ()
54 54 > {
55 55 > # continue an edit already in progress
56 56 > editor="$1" # message editor when finalizing editing
57 57 > comment="$2"
58 58 > echo % finalize changeset editing ${comment}
59 59 > HGEDITOR=${editor} hg histedit --continue 2>&1 | fixbundle
60 60 > }
61 61
62 62 $ graphlog ()
63 63 > {
64 64 > comment="${1:-log}"
65 65 > echo % "${comment}"
66 66 > hg log -G --template '{rev} {node} \"{desc|firstline}\"\n'
67 67 > }
68 68
69 69
70 70 $ initrepo r1 "test editing with no change"
71 71 % test editing with no change
72 72 -----------------------------
73 73 $ cd r1
74 74 $ graphlog "log before editing"
75 75 % log before editing
76 76 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
77 77 |
78 78 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
79 79 |
80 80 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
81 81 |
82 82 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
83 83 |
84 84 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
85 85 |
86 86 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
87 87
88 88 $ startediting 2 3 "(not changing anything)" # edit the 2nd of 3 changesets
89 89 % start editing the history (not changing anything)
90 90 | pick 055a42cdd887 3 d
91 91 | edit e860deea161a 4 e
92 92 | pick 652413bf663e 5 f
93 93 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
94 94 Make changes as needed, you may commit or record as needed now.
95 95 When you are finished, run hg histedit --continue to resume.
96 96 $ continueediting true "(leaving commit message unaltered)"
97 97 % finalize changeset editing (leaving commit message unaltered)
98 98 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 100
101 101
102 102 check state of working copy
103 103 $ hg id
104 104 794fe033d0a0 tip
105 105
106 106 $ graphlog "log after history editing"
107 107 % log after history editing
108 108 @ 5 794fe033d0a030f8df77c5de945fca35c9181c30 "f"
109 109 |
110 110 o 4 04d2fab980779f332dec458cc944f28de8b43435 "e"
111 111 |
112 112 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
113 113 |
114 114 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
115 115 |
116 116 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
117 117 |
118 118 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
119 119
120 120
121 121 $ cd ..
122 122
123 123 $ initrepo r2 "test editing with no change, then abort"
124 124 % test editing with no change, then abort
125 125 -----------------------------------------
126 126 $ cd r2
127 127 $ graphlog "log before editing"
128 128 % log before editing
129 129 @ 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
130 130 |
131 131 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
132 132 |
133 133 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
134 134 |
135 135 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
136 136 |
137 137 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
138 138 |
139 139 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
140 140
141 141 $ startediting 1,2 3 "(not changing anything)" # edit the 1st two of 3 changesets
142 142 % start editing the history (not changing anything)
143 143 | edit 055a42cdd887 3 d
144 144 | edit e860deea161a 4 e
145 145 | pick 652413bf663e 5 f
146 146 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
147 147 Make changes as needed, you may commit or record as needed now.
148 148 When you are finished, run hg histedit --continue to resume.
149 149 $ continueediting true "(leaving commit message unaltered)"
150 150 % finalize changeset editing (leaving commit message unaltered)
151 151 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
152 152 Make changes as needed, you may commit or record as needed now.
153 153 When you are finished, run hg histedit --continue to resume.
154 154 $ graphlog "log after first edit"
155 155 % log after first edit
156 156 @ 6 e5ae3ca2f1ffdbd89ec41ebc273a231f7c3022f2 "d"
157 157 |
158 158 | o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
159 159 | |
160 160 | o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
161 161 | |
162 162 | o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
163 163 |/
164 164 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
165 165 |
166 166 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
167 167 |
168 168 o 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
169 169
170 170
171 171 abort editing session, after first forcibly updating away
172 172 $ hg up 0
173 173 abort: histedit in progress
174 174 (use 'hg histedit --continue' or 'hg histedit --abort')
175 175 [255]
176 176 $ mv .hg/histedit-state .hg/histedit-state-ignore
177 177 $ hg up 0
178 178 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
179 179 $ mv .hg/histedit-state-ignore .hg/histedit-state
180 180 $ hg sum
181 181 parent: 0:cb9a9f314b8b
182 182 a
183 183 branch: default
184 184 commit: 1 added, 1 unknown (new branch head)
185 185 update: 6 new changesets (update)
186 186 phases: 7 draft
187 187 hist: 2 remaining (histedit --continue)
188 188
189 189 $ hg histedit --abort 2>&1 | fixbundle
190 [1]
191 190
192 191 modified files should survive the abort when we've moved away already
193 192 $ hg st
194 193 A e
195 194 ? edit.sh
196 195
197 196 $ graphlog "log after abort"
198 197 % log after abort
199 198 o 5 652413bf663ef2a641cab26574e46d5f5a64a55a "f"
200 199 |
201 200 o 4 e860deea161a2f77de56603b340ebbb4536308ae "e"
202 201 |
203 202 o 3 055a42cdd88768532f9cf79daa407fc8d138de9b "d"
204 203 |
205 204 o 2 177f92b773850b59254aa5e923436f921b55483b "c"
206 205 |
207 206 o 1 d2ae7f538514cd87c17547b0de4cea71fe1af9fb "b"
208 207 |
209 208 @ 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b "a"
210 209
211 210
212 211 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now