Show More
@@ -2195,54 +2195,8 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2195 | 2195 | handle(revert, False) |
|
2196 | 2196 | else: |
|
2197 | 2197 | handle(remove, False) |
|
2198 | ||
|
2199 | 2198 | if not opts.get('dry_run'): |
|
2200 | def checkout(f): | |
|
2201 | fc = ctx[f] | |
|
2202 | repo.wwrite(f, fc.data(), fc.flags()) | |
|
2203 | ||
|
2204 | audit_path = pathutil.pathauditor(repo.root) | |
|
2205 | for f in remove[0]: | |
|
2206 | if repo.dirstate[f] == 'a': | |
|
2207 | repo.dirstate.drop(f) | |
|
2208 | continue | |
|
2209 | audit_path(f) | |
|
2210 | try: | |
|
2211 | util.unlinkpath(repo.wjoin(f)) | |
|
2212 | except OSError: | |
|
2213 | pass | |
|
2214 | repo.dirstate.remove(f) | |
|
2215 | ||
|
2216 | normal = None | |
|
2217 | if node == parent: | |
|
2218 | # We're reverting to our parent. If possible, we'd like status | |
|
2219 | # to report the file as clean. We have to use normallookup for | |
|
2220 | # merges to avoid losing information about merged/dirty files. | |
|
2221 | if p2 != nullid: | |
|
2222 | normal = repo.dirstate.normallookup | |
|
2223 | else: | |
|
2224 | normal = repo.dirstate.normal | |
|
2225 | for f in revert[0]: | |
|
2226 | checkout(f) | |
|
2227 | if normal: | |
|
2228 | normal(f) | |
|
2229 | ||
|
2230 | for f in add[0]: | |
|
2231 | checkout(f) | |
|
2232 | repo.dirstate.add(f) | |
|
2233 | ||
|
2234 | normal = repo.dirstate.normallookup | |
|
2235 | if node == parent and p2 == nullid: | |
|
2236 | normal = repo.dirstate.normal | |
|
2237 | for f in undelete[0]: | |
|
2238 | checkout(f) | |
|
2239 | normal(f) | |
|
2240 | ||
|
2241 | copied = copies.pathcopies(repo[parent], ctx) | |
|
2242 | ||
|
2243 | for f in add[0] + undelete[0] + revert[0]: | |
|
2244 | if f in copied: | |
|
2245 | repo.dirstate.copy(copied[f], f) | |
|
2199 | _performrevert(repo, parents, ctx, revert, add, remove, undelete) | |
|
2246 | 2200 | |
|
2247 | 2201 | if targetsubs: |
|
2248 | 2202 | # Revert the subrepos on the revert list |
@@ -2251,6 +2205,63 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2251 | 2205 | finally: |
|
2252 | 2206 | wlock.release() |
|
2253 | 2207 | |
|
2208 | def _performrevert(repo, parents, ctx, revert, add, remove, undelete): | |
|
2209 | """function that actually perform all the action computed for revert | |
|
2210 | ||
|
2211 | This is an independent function to let extension to plug in and react to | |
|
2212 | the imminent revert. | |
|
2213 | ||
|
2214 | Make sure you have the working directory locked when caling this function. | |
|
2215 | """ | |
|
2216 | parent, p2 = parents | |
|
2217 | node = ctx.node() | |
|
2218 | def checkout(f): | |
|
2219 | fc = ctx[f] | |
|
2220 | repo.wwrite(f, fc.data(), fc.flags()) | |
|
2221 | ||
|
2222 | audit_path = pathutil.pathauditor(repo.root) | |
|
2223 | for f in remove[0]: | |
|
2224 | if repo.dirstate[f] == 'a': | |
|
2225 | repo.dirstate.drop(f) | |
|
2226 | continue | |
|
2227 | audit_path(f) | |
|
2228 | try: | |
|
2229 | util.unlinkpath(repo.wjoin(f)) | |
|
2230 | except OSError: | |
|
2231 | pass | |
|
2232 | repo.dirstate.remove(f) | |
|
2233 | ||
|
2234 | normal = None | |
|
2235 | if node == parent: | |
|
2236 | # We're reverting to our parent. If possible, we'd like status | |
|
2237 | # to report the file as clean. We have to use normallookup for | |
|
2238 | # merges to avoid losing information about merged/dirty files. | |
|
2239 | if p2 != nullid: | |
|
2240 | normal = repo.dirstate.normallookup | |
|
2241 | else: | |
|
2242 | normal = repo.dirstate.normal | |
|
2243 | for f in revert[0]: | |
|
2244 | checkout(f) | |
|
2245 | if normal: | |
|
2246 | normal(f) | |
|
2247 | ||
|
2248 | for f in add[0]: | |
|
2249 | checkout(f) | |
|
2250 | repo.dirstate.add(f) | |
|
2251 | ||
|
2252 | normal = repo.dirstate.normallookup | |
|
2253 | if node == parent and p2 == nullid: | |
|
2254 | normal = repo.dirstate.normal | |
|
2255 | for f in undelete[0]: | |
|
2256 | checkout(f) | |
|
2257 | normal(f) | |
|
2258 | ||
|
2259 | copied = copies.pathcopies(repo[parent], ctx) | |
|
2260 | ||
|
2261 | for f in add[0] + undelete[0] + revert[0]: | |
|
2262 | if f in copied: | |
|
2263 | repo.dirstate.copy(copied[f], f) | |
|
2264 | ||
|
2254 | 2265 | def command(table): |
|
2255 | 2266 | '''returns a function object bound to table which can be used as |
|
2256 | 2267 | a decorator for populating table as a command table''' |
General Comments 0
You need to be logged in to leave comments.
Login now