Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/patch.py @ 27900:27572a5cc409
diff: move status fixup earlier, out of _filepairs()
This prepares for future patches, and it also lets us remove the ugly
"ctx1" argument to _filepairs() (ugly because of its assymmetry --
there's no "ctx2" argument).
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 14 Jan 2016 10:02:34 -0800 |
parents | f7f3958d39c0 |
children | 29c8e35d3283 |
comparison
equal
deleted
inserted
replaced
27899:78b9fdb844c1 | 27900:27572a5cc409 |
---|---|
2254 # filter out copies where either side isn't inside the relative root | 2254 # filter out copies where either side isn't inside the relative root |
2255 copy = dict(((dst, src) for (dst, src) in copy.iteritems() | 2255 copy = dict(((dst, src) for (dst, src) in copy.iteritems() |
2256 if dst.startswith(relroot) | 2256 if dst.startswith(relroot) |
2257 and src.startswith(relroot))) | 2257 and src.startswith(relroot))) |
2258 | 2258 |
2259 modifiedset = set(modified) | |
2260 addedset = set(added) | |
2261 for f in modified: | |
2262 if f not in ctx1: | |
2263 # Fix up added, since merged-in additions appear as | |
2264 # modifications during merges | |
2265 modifiedset.remove(f) | |
2266 addedset.add(f) | |
2267 modified = sorted(modifiedset) | |
2268 added = sorted(addedset) | |
2269 | |
2259 def difffn(opts, losedata): | 2270 def difffn(opts, losedata): |
2260 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed, | 2271 return trydiff(repo, revs, ctx1, ctx2, modified, added, removed, |
2261 copy, getfilectx, opts, losedata, prefix, relroot) | 2272 copy, getfilectx, opts, losedata, prefix, relroot) |
2262 if opts.upgrade and not opts.git: | 2273 if opts.upgrade and not opts.git: |
2263 try: | 2274 try: |
2325 | 2336 |
2326 def diffui(*args, **kw): | 2337 def diffui(*args, **kw): |
2327 '''like diff(), but yields 2-tuples of (output, label) for ui.write()''' | 2338 '''like diff(), but yields 2-tuples of (output, label) for ui.write()''' |
2328 return difflabel(diff, *args, **kw) | 2339 return difflabel(diff, *args, **kw) |
2329 | 2340 |
2330 def _filepairs(ctx1, modified, added, removed, copy, opts): | 2341 def _filepairs(modified, added, removed, copy, opts): |
2331 '''generates tuples (f1, f2, copyop), where f1 is the name of the file | 2342 '''generates tuples (f1, f2, copyop), where f1 is the name of the file |
2332 before and f2 is the the name after. For added files, f1 will be None, | 2343 before and f2 is the the name after. For added files, f1 will be None, |
2333 and for removed files, f2 will be None. copyop may be set to None, 'copy' | 2344 and for removed files, f2 will be None. copyop may be set to None, 'copy' |
2334 or 'rename' (the latter two only if opts.git is set).''' | 2345 or 'rename' (the latter two only if opts.git is set).''' |
2335 gone = set() | 2346 gone = set() |
2336 | 2347 |
2337 copyto = dict([(v, k) for k, v in copy.items()]) | 2348 copyto = dict([(v, k) for k, v in copy.items()]) |
2338 | 2349 |
2339 addedset, removedset = set(added), set(removed) | 2350 addedset, removedset = set(added), set(removed) |
2340 # Fix up added, since merged-in additions appear as | |
2341 # modifications during merges | |
2342 for f in modified: | |
2343 if f not in ctx1: | |
2344 addedset.add(f) | |
2345 | 2351 |
2346 for f in sorted(modified + added + removed): | 2352 for f in sorted(modified + added + removed): |
2347 copyop = None | 2353 copyop = None |
2348 f1, f2 = f, f | 2354 f1, f2 = f, f |
2349 if f in addedset: | 2355 if f in addedset: |
2405 for f in modified + added + removed + copy.keys() + copy.values(): | 2411 for f in modified + added + removed + copy.keys() + copy.values(): |
2406 if f is not None and not f.startswith(relroot): | 2412 if f is not None and not f.startswith(relroot): |
2407 raise AssertionError( | 2413 raise AssertionError( |
2408 "file %s doesn't start with relroot %s" % (f, relroot)) | 2414 "file %s doesn't start with relroot %s" % (f, relroot)) |
2409 | 2415 |
2410 for f1, f2, copyop in _filepairs( | 2416 for f1, f2, copyop in _filepairs(modified, added, removed, copy, opts): |
2411 ctx1, modified, added, removed, copy, opts): | |
2412 content1 = None | 2417 content1 = None |
2413 content2 = None | 2418 content2 = None |
2414 flag1 = None | 2419 flag1 = None |
2415 flag2 = None | 2420 flag2 = None |
2416 if f1: | 2421 if f1: |