Show More
@@ -98,15 +98,13 b' def _commitfiltered(repo, ctx, match, al' | |||
|
98 | 98 | newid = repo.commitctx(new) |
|
99 | 99 | return newid |
|
100 | 100 | |
|
101 |
def _ |
|
|
102 |
""" |
|
|
103 | oldctx to a copy of oldctx not containing changed files matched by | |
|
104 | match. | |
|
101 | def _fixdirstate(repo, oldctx, newctx, status): | |
|
102 | """ fix the dirstate after switching the working directory from oldctx to | |
|
103 | newctx which can be result of either unamend or uncommit. | |
|
105 | 104 | """ |
|
106 | ctx = repo['.'] | |
|
107 | 105 | ds = repo.dirstate |
|
108 | 106 | copies = dict(ds.copies()) |
|
109 | s = repo.status(oldctx.p1(), oldctx, match=match) | |
|
107 | s = status | |
|
110 | 108 | for f in s.modified: |
|
111 | 109 | if ds[f] == 'r': |
|
112 | 110 | # modified + removed -> removed |
@@ -138,7 +136,7 b' def _uncommitdirstate(repo, oldctx, matc' | |||
|
138 | 136 | for dst, src in oldcopies.iteritems()) |
|
139 | 137 | # Adjust the dirstate copies |
|
140 | 138 | for dst, src in copies.iteritems(): |
|
141 | if (src not in ctx or dst in ctx or ds[dst] != 'a'): | |
|
139 | if (src not in newctx or dst in newctx or ds[dst] != 'a'): | |
|
142 | 140 | src = None |
|
143 | 141 | ds.copy(src, dst) |
|
144 | 142 | |
@@ -194,54 +192,14 b' def uncommit(ui, repo, *pats, **opts):' | |||
|
194 | 192 | |
|
195 | 193 | with repo.dirstate.parentchange(): |
|
196 | 194 | repo.dirstate.setparents(newid, node.nullid) |
|
197 |
|
|
|
195 | s = repo.status(old.p1(), old, match=match) | |
|
196 | _fixdirstate(repo, old, repo[newid], s) | |
|
198 | 197 | |
|
199 | 198 | def predecessormarkers(ctx): |
|
200 | 199 | """yields the obsolete markers marking the given changeset as a successor""" |
|
201 | 200 | for data in ctx.repo().obsstore.predecessors.get(ctx.node(), ()): |
|
202 | 201 | yield obsutil.marker(ctx.repo(), data) |
|
203 | 202 | |
|
204 | def _unamenddirstate(repo, predctx, curctx): | |
|
205 | """""" | |
|
206 | ||
|
207 | s = repo.status(predctx, curctx) | |
|
208 | ds = repo.dirstate | |
|
209 | copies = dict(ds.copies()) | |
|
210 | for f in s.modified: | |
|
211 | if ds[f] == 'r': | |
|
212 | # modified + removed -> removed | |
|
213 | continue | |
|
214 | ds.normallookup(f) | |
|
215 | ||
|
216 | for f in s.added: | |
|
217 | if ds[f] == 'r': | |
|
218 | # added + removed -> unknown | |
|
219 | ds.drop(f) | |
|
220 | elif ds[f] != 'a': | |
|
221 | ds.add(f) | |
|
222 | ||
|
223 | for f in s.removed: | |
|
224 | if ds[f] == 'a': | |
|
225 | # removed + added -> normal | |
|
226 | ds.normallookup(f) | |
|
227 | elif ds[f] != 'r': | |
|
228 | ds.remove(f) | |
|
229 | ||
|
230 | # Merge old parent and old working dir copies | |
|
231 | oldcopies = {} | |
|
232 | for f in (s.modified + s.added): | |
|
233 | src = curctx[f].renamed() | |
|
234 | if src: | |
|
235 | oldcopies[f] = src[0] | |
|
236 | oldcopies.update(copies) | |
|
237 | copies = dict((dst, oldcopies.get(src, src)) | |
|
238 | for dst, src in oldcopies.iteritems()) | |
|
239 | # Adjust the dirstate copies | |
|
240 | for dst, src in copies.iteritems(): | |
|
241 | if (src not in predctx or dst in predctx or ds[dst] != 'a'): | |
|
242 | src = None | |
|
243 | ds.copy(src, dst) | |
|
244 | ||
|
245 | 203 | @command('^unamend', []) |
|
246 | 204 | def unamend(ui, repo, **opts): |
|
247 | 205 | """ |
@@ -312,7 +270,8 b' def unamend(ui, repo, **opts):' | |||
|
312 | 270 | |
|
313 | 271 | with dirstate.parentchange(): |
|
314 | 272 | dirstate.setparents(newprednode, node.nullid) |
|
315 |
|
|
|
273 | s = repo.status(predctx, curctx) | |
|
274 | _fixdirstate(repo, curctx, newpredctx, s) | |
|
316 | 275 | |
|
317 | 276 | mapping = {curctx.node(): (newprednode,)} |
|
318 | 277 | scmutil.cleanupnodes(repo, mapping, 'unamend') |
General Comments 0
You need to be logged in to leave comments.
Login now