##// END OF EJS Templates
histedit: don't crash if the result of fixing up a fold is empty
Augie Fackler -
r17130:0a48f3d5 default
parent child Browse files
Show More
@@ -307,7 +307,11 b' def histedit(ui, repo, *parent, **opts):'
307 new = repo.commit(text=message, user=oldctx.user(),
307 new = repo.commit(text=message, user=oldctx.user(),
308 date=oldctx.date(), extra=oldctx.extra())
308 date=oldctx.date(), extra=oldctx.extra())
309
309
310 if action in ('f', 'fold'):
310 # If we're resuming a fold and we have new changes, mark the
311 # replacements and finish the fold. If not, it's more like a
312 # drop of the changesets that disappeared, and we can skip
313 # this step.
314 if action in ('f', 'fold') and (new or newchildren):
311 if new:
315 if new:
312 tmpnodes.append(new)
316 tmpnodes.append(new)
313 else:
317 else:
@@ -108,3 +108,78 b' post-fold manifest'
108 f
108 f
109
109
110 $ cd ..
110 $ cd ..
111
112 folding and creating no new change doesn't break:
113 $ mkdir fold-to-empty-test
114 $ cd fold-to-empty-test
115 $ hg init
116 $ printf "1\n2\n3\n" > file
117 $ hg add file
118 $ hg commit -m '1+2+3'
119 $ echo 4 >> file
120 $ hg commit -m '+4'
121 $ echo 5 >> file
122 $ hg commit -m '+5'
123 $ echo 6 >> file
124 $ hg commit -m '+6'
125 $ hg log --graph
126 @ changeset: 3:251d831eeec5
127 | tag: tip
128 | user: test
129 | date: Thu Jan 01 00:00:00 1970 +0000
130 | summary: +6
131 |
132 o changeset: 2:888f9082bf99
133 | user: test
134 | date: Thu Jan 01 00:00:00 1970 +0000
135 | summary: +5
136 |
137 o changeset: 1:617f94f13c0f
138 | user: test
139 | date: Thu Jan 01 00:00:00 1970 +0000
140 | summary: +4
141 |
142 o changeset: 0:0189ba417d34
143 user: test
144 date: Thu Jan 01 00:00:00 1970 +0000
145 summary: 1+2+3
146
147
148 $ cat > editor.py <<EOF
149 > import re, sys
150 > rules = sys.argv[1]
151 > data = open(rules).read()
152 > data = re.sub(r'pick ([0-9a-f]{12} 2 \+5)', r'drop \1', data)
153 > data = re.sub(r'pick ([0-9a-f]{12} 2 \+6)', r'fold \1', data)
154 > open(rules, 'w').write(data)
155 > EOF
156
157 $ HGEDITOR='python editor.py' hg histedit 1
158 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
159 patching file file
160 Hunk #1 FAILED at 2
161 1 out of 1 hunks FAILED -- saving rejects to file file.rej
162 abort: Fix up the change and run hg histedit --continue
163 [255]
164 There were conflicts, but we'll continue without resolving. This
165 should effectively drop the changes from +6.
166 $ hg status
167 ? editor.py
168 ? file.rej
169 $ hg histedit --continue
170 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
171 saved backup bundle to $TESTTMP/*-backup.hg (glob)
172 $ hg log --graph
173 @ changeset: 1:617f94f13c0f
174 | tag: tip
175 | user: test
176 | date: Thu Jan 01 00:00:00 1970 +0000
177 | summary: +4
178 |
179 o changeset: 0:0189ba417d34
180 user: test
181 date: Thu Jan 01 00:00:00 1970 +0000
182 summary: 1+2+3
183
184
185 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now