Show More
@@ -142,7 +142,6 b' try:' | |||
|
142 | 142 | import cPickle as pickle |
|
143 | 143 | except ImportError: |
|
144 | 144 | import pickle |
|
145 | import tempfile | |
|
146 | 145 | import os |
|
147 | 146 | |
|
148 | 147 | from mercurial import bookmarks |
@@ -154,10 +153,10 b' from mercurial import context' | |||
|
154 | 153 | from mercurial import hg |
|
155 | 154 | from mercurial import lock as lockmod |
|
156 | 155 | from mercurial import node |
|
157 | from mercurial import patch | |
|
158 | 156 | from mercurial import repair |
|
159 | 157 | from mercurial import scmutil |
|
160 | 158 | from mercurial import util |
|
159 | from mercurial import merge as mergemod | |
|
161 | 160 | from mercurial.i18n import _ |
|
162 | 161 | |
|
163 | 162 | cmdtable = {} |
@@ -177,25 +176,27 b' editcomment = _("""# Edit history betwee' | |||
|
177 | 176 | # |
|
178 | 177 | """) |
|
179 | 178 | |
|
180 |
def |
|
|
181 | """Produce a new changeset that represents the diff from node1 to node2.""" | |
|
182 | try: | |
|
183 | fd, patchfile = tempfile.mkstemp(prefix='hg-histedit-') | |
|
184 | fp = os.fdopen(fd, 'w') | |
|
185 | diffopts = patch.diffopts(ui, opts) | |
|
186 | diffopts.git = True | |
|
187 | diffopts.ignorews = False | |
|
188 | diffopts.ignorewsamount = False | |
|
189 | diffopts.ignoreblanklines = False | |
|
190 | gen = patch.diff(repo, node1, node2, opts=diffopts) | |
|
191 | for chunk in gen: | |
|
192 | fp.write(chunk) | |
|
193 | fp.close() | |
|
194 | files = set() | |
|
195 | patch.patch(ui, repo, patchfile, files=files, eolmode=None) | |
|
196 | finally: | |
|
197 | os.unlink(patchfile) | |
|
198 | return files | |
|
179 | def applychanges(ui, repo, ctx, opts): | |
|
180 | """Merge changeset from ctx (only) in the current working directory""" | |
|
181 | wcpar = repo.dirstate.parents()[0] | |
|
182 | if ctx.p1().node() == wcpar: | |
|
183 | # edition ar "in place" we do not need to make any merge, | |
|
184 | # just applies changes on parent for edition | |
|
185 | cmdutil.revert(ui, repo, ctx, (wcpar, node.nullid), all=True) | |
|
186 | stats = None | |
|
187 | else: | |
|
188 | try: | |
|
189 | # ui.forcemerge is an internal variable, do not document | |
|
190 | repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', '')) | |
|
191 | stats = mergemod.update(repo, ctx.node(), True, True, False, | |
|
192 | ctx.p1().node()) | |
|
193 | finally: | |
|
194 | repo.ui.setconfig('ui', 'forcemerge', '') | |
|
195 | repo.setparents(wcpar, node.nullid) | |
|
196 | repo.dirstate.write() | |
|
197 | # fix up dirstate for copies and renames | |
|
198 | cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev()) | |
|
199 | return stats | |
|
199 | 200 | |
|
200 | 201 | def collapse(repo, first, last, commitopts): |
|
201 | 202 | """collapse the set of revisions from first to last as new one. |
@@ -273,27 +274,24 b' def pick(ui, repo, ctx, ha, opts):' | |||
|
273 | 274 | ui.debug('node %s unchanged\n' % ha) |
|
274 | 275 | return oldctx, [], [], [] |
|
275 | 276 | hg.update(repo, ctx.node()) |
|
276 | try: | |
|
277 | files = foldchanges(ui, repo, oldctx.p1().node() , ha, opts) | |
|
278 | if not files: | |
|
279 | ui.warn(_('%s: empty changeset') | |
|
280 | % node.hex(ha)) | |
|
281 | return ctx, [], [], [] | |
|
282 | except Exception: | |
|
277 | stats = applychanges(ui, repo, oldctx, opts) | |
|
278 | if stats and stats[3] > 0: | |
|
283 | 279 | raise util.Abort(_('Fix up the change and run ' |
|
284 | 280 | 'hg histedit --continue')) |
|
281 | # drop the second merge parent | |
|
285 | 282 | n = repo.commit(text=oldctx.description(), user=oldctx.user(), |
|
286 | 283 | date=oldctx.date(), extra=oldctx.extra()) |
|
284 | if n is None: | |
|
285 | ui.warn(_('%s: empty changeset\n') | |
|
286 | % node.hex(ha)) | |
|
287 | return ctx, [], [], [] | |
|
287 | 288 | return repo[n], [n], [oldctx.node()], [] |
|
288 | 289 | |
|
289 | 290 | |
|
290 | 291 | def edit(ui, repo, ctx, ha, opts): |
|
291 | 292 | oldctx = repo[ha] |
|
292 | 293 | hg.update(repo, ctx.node()) |
|
293 | try: | |
|
294 | foldchanges(ui, repo, oldctx.p1().node() , ha, opts) | |
|
295 | except Exception: | |
|
296 | pass | |
|
294 | applychanges(ui, repo, oldctx, opts) | |
|
297 | 295 | raise util.Abort(_('Make changes as needed, you may commit or record as ' |
|
298 | 296 | 'needed now.\nWhen you are finished, run hg' |
|
299 | 297 | ' histedit --continue to resume.')) |
@@ -301,17 +299,16 b' def edit(ui, repo, ctx, ha, opts):' | |||
|
301 | 299 | def fold(ui, repo, ctx, ha, opts): |
|
302 | 300 | oldctx = repo[ha] |
|
303 | 301 | hg.update(repo, ctx.node()) |
|
304 | try: | |
|
305 | files = foldchanges(ui, repo, oldctx.p1().node() , ha, opts) | |
|
306 | if not files: | |
|
307 | ui.warn(_('%s: empty changeset') | |
|
308 | % node.hex(ha)) | |
|
309 | return ctx, [], [], [] | |
|
310 | except Exception: | |
|
302 | stats = applychanges(ui, repo, oldctx, opts) | |
|
303 | if stats and stats[3] > 0: | |
|
311 | 304 | raise util.Abort(_('Fix up the change and run ' |
|
312 | 305 | 'hg histedit --continue')) |
|
313 | 306 | n = repo.commit(text='fold-temp-revision %s' % ha, user=oldctx.user(), |
|
314 | 307 | date=oldctx.date(), extra=oldctx.extra()) |
|
308 | if n is None: | |
|
309 | ui.warn(_('%s: empty changeset') | |
|
310 | % node.hex(ha)) | |
|
311 | return ctx, [], [], [] | |
|
315 | 312 | return finishfold(ui, repo, ctx, oldctx, n, opts, []) |
|
316 | 313 | |
|
317 | 314 | def finishfold(ui, repo, ctx, oldctx, newnode, opts, internalchanges): |
@@ -346,9 +343,8 b' def drop(ui, repo, ctx, ha, opts):' | |||
|
346 | 343 | def message(ui, repo, ctx, ha, opts): |
|
347 | 344 | oldctx = repo[ha] |
|
348 | 345 | hg.update(repo, ctx.node()) |
|
349 | try: | |
|
350 | foldchanges(ui, repo, oldctx.p1().node() , ha, opts) | |
|
351 | except Exception: | |
|
346 | stats = applychanges(ui, repo, oldctx, opts) | |
|
347 | if stats and stats[3] > 0: | |
|
352 | 348 | raise util.Abort(_('Fix up the change and run ' |
|
353 | 349 | 'hg histedit --continue')) |
|
354 | 350 | message = oldctx.description() + '\n' |
@@ -88,13 +88,14 b' log before edit' | |||
|
88 | 88 | edit the history |
|
89 | 89 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle |
|
90 | 90 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | patching file e | |
|
92 | Hunk #1 FAILED at 0 | |
|
93 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
91 | merging e | |
|
92 | warning: conflicts during merge. | |
|
93 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
94 | 94 | abort: Fix up the change and run hg histedit --continue |
|
95 | 95 | |
|
96 | 96 | fix up |
|
97 | $ echo a > e | |
|
97 | $ echo 'I can haz no commute' > e | |
|
98 | $ hg resolve --mark e | |
|
98 | 99 | $ cat > cat.py <<EOF |
|
99 | 100 | > import sys |
|
100 | 101 | > print open(sys.argv[1]).read() |
@@ -121,25 +122,27 b' fix up' | |||
|
121 | 122 | |
|
122 | 123 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
123 | 124 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
124 | patching file e | |
|
125 | Hunk #1 FAILED at 0 | |
|
126 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
125 | merging e | |
|
126 | warning: conflicts during merge. | |
|
127 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
127 | 128 | abort: Fix up the change and run hg histedit --continue |
|
128 | 129 | |
|
129 | 130 | just continue this time |
|
131 | $ hg revert -r 'p1()' e | |
|
132 | $ hg resolve --mark e | |
|
130 | 133 | $ hg histedit --continue 2>&1 | fixbundle |
|
131 | 134 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
132 | 135 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
133 | 136 | |
|
134 | 137 | log after edit |
|
135 | 138 | $ hg log --graph |
|
136 |
@ changeset: 5: |
|
|
139 | @ changeset: 5:2696a654c663 | |
|
137 | 140 | | tag: tip |
|
138 | 141 | | user: test |
|
139 | 142 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
140 | 143 | | summary: f |
|
141 | 144 | | |
|
142 |
o changeset: 4: |
|
|
145 | o changeset: 4:ec2c1cf833a8 | |
|
143 | 146 | | user: test |
|
144 | 147 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
145 | 148 | | summary: d |
@@ -167,7 +170,7 b' log after edit' | |||
|
167 | 170 | |
|
168 | 171 | contents of e |
|
169 | 172 | $ hg cat e |
|
170 | a | |
|
173 | I can haz no commute | |
|
171 | 174 | |
|
172 | 175 | manifest |
|
173 | 176 | $ hg manifest |
@@ -157,16 +157,21 b' folding and creating no new change doesn' | |||
|
157 | 157 | |
|
158 | 158 | $ HGEDITOR='python editor.py' hg histedit 1 |
|
159 | 159 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
160 | patching file file | |
|
161 | Hunk #1 FAILED at 2 | |
|
162 | 1 out of 1 hunks FAILED -- saving rejects to file file.rej | |
|
160 | merging file | |
|
161 | warning: conflicts during merge. | |
|
162 | merging file incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
163 | 163 | abort: Fix up the change and run hg histedit --continue |
|
164 | 164 | [255] |
|
165 |
There were conflicts, |
|
|
165 | There were conflicts, we keep P1 content. This | |
|
166 | 166 | should effectively drop the changes from +6. |
|
167 | 167 | $ hg status |
|
168 | M file | |
|
168 | 169 | ? editor.py |
|
169 |
? file. |
|
|
170 | ? file.orig | |
|
171 | $ hg resolve -l | |
|
172 | U file | |
|
173 | $ hg revert -r 'p1()' file | |
|
174 | $ hg resolve --mark file | |
|
170 | 175 | $ hg histedit --continue |
|
171 | 176 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
172 | 177 | saved backup bundle to $TESTTMP/*-backup.hg (glob) |
@@ -217,12 +222,19 b' dropped revision.' | |||
|
217 | 222 | > EOF |
|
218 | 223 | $ HGEDITOR="cat $EDITED >" hg histedit 1 |
|
219 | 224 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
220 | patching file file | |
|
221 | Hunk #1 FAILED at 2 | |
|
222 | 1 out of 1 hunks FAILED -- saving rejects to file file.rej | |
|
225 | merging file | |
|
226 | warning: conflicts during merge. | |
|
227 | merging file incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
223 | 228 | abort: Fix up the change and run hg histedit --continue |
|
224 | 229 | [255] |
|
225 |
$ |
|
|
230 | $ cat > file << EOF | |
|
231 | > 1 | |
|
232 | > 2 | |
|
233 | > 3 | |
|
234 | > 4 | |
|
235 | > 5 | |
|
236 | > EOF | |
|
237 | $ hg resolve --mark file | |
|
226 | 238 |
$ hg commit -m |
|
227 | 239 | created new head |
|
228 | 240 | $ echo 6 >> file |
@@ -73,23 +73,21 b' log before edit' | |||
|
73 | 73 | edit the history |
|
74 | 74 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit 177f92b77385 2>&1 | fixbundle |
|
75 | 75 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
76 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
76 | remote changed e which local deleted | |
|
77 | use (c)hanged version or leave (d)eleted? c | |
|
78 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
79 | merging e | |
|
80 | warning: conflicts during merge. | |
|
81 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
77 | 82 | abort: Fix up the change and run hg histedit --continue |
|
78 | 83 | |
|
79 | fix up (pre abort) | |
|
80 | $ echo a > e | |
|
81 | $ hg add e | |
|
82 | $ hg histedit --continue 2>&1 | fixbundle | |
|
83 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
84 | file e already exists | |
|
85 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
86 | abort: Fix up the change and run hg histedit --continue | |
|
87 | 84 | |
|
88 | 85 | abort the edit |
|
89 | 86 | $ hg histedit --abort 2>&1 | fixbundle |
|
90 | 87 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
91 | 88 | |
|
92 | 89 | log after abort |
|
90 | $ hg resolve -l | |
|
93 | 91 | $ hg log --graph |
|
94 | 92 | @ changeset: 6:bfa474341cc9 |
|
95 | 93 | | tag: tip |
@@ -89,9 +89,9 b' log before edit' | |||
|
89 | 89 | edit the history |
|
90 | 90 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle |
|
91 | 91 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
92 | patching file e | |
|
93 | Hunk #1 FAILED at 0 | |
|
94 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
92 | merging e | |
|
93 | warning: conflicts during merge. | |
|
94 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
95 | 95 | abort: Fix up the change and run hg histedit --continue |
|
96 | 96 | |
|
97 | 97 | abort the edit |
@@ -147,21 +147,24 b' second edit set' | |||
|
147 | 147 | edit the history |
|
148 | 148 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle |
|
149 | 149 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
150 | patching file e | |
|
151 | Hunk #1 FAILED at 0 | |
|
152 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
150 | merging e | |
|
151 | warning: conflicts during merge. | |
|
152 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
153 | 153 | abort: Fix up the change and run hg histedit --continue |
|
154 | 154 | |
|
155 | 155 | fix up |
|
156 | 156 | $ echo 'I can haz no commute' > e |
|
157 | $ hg resolve --mark e | |
|
157 | 158 | $ hg histedit --continue 2>&1 | fixbundle |
|
158 | 159 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
159 | patching file e | |
|
160 | Hunk #1 FAILED at 0 | |
|
161 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
160 | merging e | |
|
161 | warning: conflicts during merge. | |
|
162 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
162 | 163 | abort: Fix up the change and run hg histedit --continue |
|
163 | 164 | |
|
164 | 165 | just continue this time |
|
166 | $ hg revert -r 'p1()' e | |
|
167 | $ hg resolve --mark e | |
|
165 | 168 | $ hg histedit --continue 2>&1 | fixbundle |
|
166 | 169 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
167 | 170 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
@@ -227,19 +230,22 b' start over' | |||
|
227 | 230 | edit the history, this time with a fold action |
|
228 | 231 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit 3 2>&1 | fixbundle |
|
229 | 232 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
230 | patching file e | |
|
231 | Hunk #1 FAILED at 0 | |
|
232 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
233 | merging e | |
|
234 | warning: conflicts during merge. | |
|
235 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
233 | 236 | abort: Fix up the change and run hg histedit --continue |
|
234 | 237 | |
|
235 | 238 | $ echo 'I can haz no commute' > e |
|
239 | $ hg resolve --mark e | |
|
236 | 240 | $ HGEDITOR="cat \"$EDITED\" > " hg histedit --continue 2>&1 | fixbundle |
|
237 | 241 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
238 | patching file e | |
|
239 | Hunk #1 FAILED at 0 | |
|
240 | 1 out of 1 hunks FAILED -- saving rejects to file e.rej | |
|
242 | merging e | |
|
243 | warning: conflicts during merge. | |
|
244 | merging e incomplete! (edit conflicts, then use 'hg resolve --mark') | |
|
241 | 245 | abort: Fix up the change and run hg histedit --continue |
|
242 | 246 | second edit also fails, but just continue |
|
247 | $ hg revert -r 'p1()' e | |
|
248 | $ hg resolve --mark e | |
|
243 | 249 | $ hg histedit --continue 2>&1 | fixbundle |
|
244 | 250 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
245 | 251 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
General Comments 0
You need to be logged in to leave comments.
Login now