comparison mercurial/scmutil.py @ 25418:c0995cd8ff6f

scmutil: consistently return subrepos relative to ctx1 from itersubrepos() Previously, if a subrepo was added in ctx2 and then compared to another without it (ctx1), the subrepo for ctx2 was returned amongst all of the ctx1 based subrepos, since no subrepo exists in ctx1 to replace it in the 'subpaths' dict. The two callers of this, basectx.status() and cmdutil.diffordiffstat(), both compare the yielded subrepo against ctx2, and thus saw no changes when ctx2's subrepo was returned. The tests here previously didn't mention 's/a' for the 'p1()' case. This appears to have been a known issue, because some diffordiffstat() comments mention that the subpath disappeared, and "the best we can do is ignore it". I originally ran into the issue with some custom convert code to flatten a tree of subrepos causing hg.putcommit() to abort, but this new behavior seems like the correct status and diff behavior regardless. (The abort in convert isn't something users will see, because convert doesn't currently support subrepos in the official repo.)
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 03 Jun 2015 14:21:15 -0400
parents a5a95642144b
children 5984dd42e140
comparison
equal deleted inserted replaced
25417:95c271356a66 25418:c0995cd8ff6f
78 # Create a (subpath, ctx) mapping where we prefer subpaths from 78 # Create a (subpath, ctx) mapping where we prefer subpaths from
79 # ctx1. The subpaths from ctx2 are important when the .hgsub file 79 # ctx1. The subpaths from ctx2 are important when the .hgsub file
80 # has been modified (in ctx2) but not yet committed (in ctx1). 80 # has been modified (in ctx2) but not yet committed (in ctx1).
81 subpaths = dict.fromkeys(ctx2.substate, ctx2) 81 subpaths = dict.fromkeys(ctx2.substate, ctx2)
82 subpaths.update(dict.fromkeys(ctx1.substate, ctx1)) 82 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
83
84 missing = set()
85
86 for subpath in ctx2.substate:
87 if subpath not in ctx1.substate:
88 del subpaths[subpath]
89 missing.add(subpath)
90
83 for subpath, ctx in sorted(subpaths.iteritems()): 91 for subpath, ctx in sorted(subpaths.iteritems()):
84 yield subpath, ctx.sub(subpath) 92 yield subpath, ctx.sub(subpath)
93
94 # Yield an empty subrepo based on ctx1 for anything only in ctx2. That way,
95 # status and diff will have an accurate result when it does
96 # 'sub.{status|diff}(rev2)'. Otherwise, the ctx2 subrepo is compared
97 # against itself.
98 for subpath in missing:
99 yield subpath, ctx2.nullsub(subpath, ctx1)
85 100
86 def nochangesfound(ui, repo, excluded=None): 101 def nochangesfound(ui, repo, excluded=None):
87 '''Report no changes for push/pull, excluded is None or a list of 102 '''Report no changes for push/pull, excluded is None or a list of
88 nodes excluded from the push/pull. 103 nodes excluded from the push/pull.
89 ''' 104 '''