Show More
@@ -99,44 +99,6 b' def _commitfiltered(repo, ctx, match, ke' | |||
|
99 | 99 | extra=ctx.extra()) |
|
100 | 100 | return repo.commitctx(new) |
|
101 | 101 | |
|
102 | def _movedirstate(repo, newctx, match=None): | |
|
103 | """Move the dirstate to newctx and adjust it as necessary.""" | |
|
104 | oldctx = repo['.'] | |
|
105 | ds = repo.dirstate | |
|
106 | ds.setparents(newctx.node(), node.nullid) | |
|
107 | copies = dict(ds.copies()) | |
|
108 | s = newctx.status(oldctx, match=match) | |
|
109 | for f in s.modified: | |
|
110 | if ds[f] == 'r': | |
|
111 | # modified + removed -> removed | |
|
112 | continue | |
|
113 | ds.normallookup(f) | |
|
114 | ||
|
115 | for f in s.added: | |
|
116 | if ds[f] == 'r': | |
|
117 | # added + removed -> unknown | |
|
118 | ds.drop(f) | |
|
119 | elif ds[f] != 'a': | |
|
120 | ds.add(f) | |
|
121 | ||
|
122 | for f in s.removed: | |
|
123 | if ds[f] == 'a': | |
|
124 | # removed + added -> normal | |
|
125 | ds.normallookup(f) | |
|
126 | elif ds[f] != 'r': | |
|
127 | ds.remove(f) | |
|
128 | ||
|
129 | # Merge old parent and old working dir copies | |
|
130 | oldcopies = copiesmod.pathcopies(newctx, oldctx, match) | |
|
131 | oldcopies.update(copies) | |
|
132 | copies = dict((dst, oldcopies.get(src, src)) | |
|
133 | for dst, src in oldcopies.iteritems()) | |
|
134 | # Adjust the dirstate copies | |
|
135 | for dst, src in copies.iteritems(): | |
|
136 | if (src not in newctx or dst in newctx or ds[dst] != 'a'): | |
|
137 | src = None | |
|
138 | ds.copy(src, dst) | |
|
139 | ||
|
140 | 102 | @command('uncommit', |
|
141 | 103 | [('', 'keep', None, _('allow an empty commit after uncommiting')), |
|
142 | 104 | ('', 'allow-dirty-working-copy', False, |
@@ -193,7 +155,7 b' def uncommit(ui, repo, *pats, **opts):' | |||
|
193 | 155 | mapping[old.node()] = () |
|
194 | 156 | |
|
195 | 157 | with repo.dirstate.parentchange(): |
|
196 |
|
|
|
158 | scmutil.movedirstate(repo, repo[newid], match) | |
|
197 | 159 | |
|
198 | 160 | scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True) |
|
199 | 161 | |
@@ -255,7 +217,7 b' def unamend(ui, repo, **opts):' | |||
|
255 | 217 | dirstate = repo.dirstate |
|
256 | 218 | |
|
257 | 219 | with dirstate.parentchange(): |
|
258 |
|
|
|
220 | scmutil.movedirstate(repo, newpredctx) | |
|
259 | 221 | |
|
260 | 222 | mapping = {curctx.node(): (newprednode,)} |
|
261 | 223 | scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True) |
@@ -28,6 +28,7 b' from .node import (' | |||
|
28 | 28 | ) |
|
29 | 29 | |
|
30 | 30 | from . import ( |
|
31 | copies as copiesmod, | |
|
31 | 32 | encoding, |
|
32 | 33 | error, |
|
33 | 34 | match as matchmod, |
@@ -1253,6 +1254,44 b' def dirstatecopy(ui, repo, wctx, src, ds' | |||
|
1253 | 1254 | elif not dryrun: |
|
1254 | 1255 | wctx.copy(origsrc, dst) |
|
1255 | 1256 | |
|
1257 | def movedirstate(repo, newctx, match=None): | |
|
1258 | """Move the dirstate to newctx and adjust it as necessary.""" | |
|
1259 | oldctx = repo['.'] | |
|
1260 | ds = repo.dirstate | |
|
1261 | ds.setparents(newctx.node(), nullid) | |
|
1262 | copies = dict(ds.copies()) | |
|
1263 | s = newctx.status(oldctx, match=match) | |
|
1264 | for f in s.modified: | |
|
1265 | if ds[f] == 'r': | |
|
1266 | # modified + removed -> removed | |
|
1267 | continue | |
|
1268 | ds.normallookup(f) | |
|
1269 | ||
|
1270 | for f in s.added: | |
|
1271 | if ds[f] == 'r': | |
|
1272 | # added + removed -> unknown | |
|
1273 | ds.drop(f) | |
|
1274 | elif ds[f] != 'a': | |
|
1275 | ds.add(f) | |
|
1276 | ||
|
1277 | for f in s.removed: | |
|
1278 | if ds[f] == 'a': | |
|
1279 | # removed + added -> normal | |
|
1280 | ds.normallookup(f) | |
|
1281 | elif ds[f] != 'r': | |
|
1282 | ds.remove(f) | |
|
1283 | ||
|
1284 | # Merge old parent and old working dir copies | |
|
1285 | oldcopies = copiesmod.pathcopies(newctx, oldctx, match) | |
|
1286 | oldcopies.update(copies) | |
|
1287 | copies = dict((dst, oldcopies.get(src, src)) | |
|
1288 | for dst, src in oldcopies.iteritems()) | |
|
1289 | # Adjust the dirstate copies | |
|
1290 | for dst, src in copies.iteritems(): | |
|
1291 | if (src not in newctx or dst in newctx or ds[dst] != 'a'): | |
|
1292 | src = None | |
|
1293 | ds.copy(src, dst) | |
|
1294 | ||
|
1256 | 1295 | def writerequires(opener, requirements): |
|
1257 | 1296 | with opener('requires', 'w', atomictemp=True) as fp: |
|
1258 | 1297 | for r in sorted(requirements): |
General Comments 0
You need to be logged in to leave comments.
Login now