##// END OF EJS Templates
patch.diff: restrict matcher to relative root in certain cases...
Siddharth Agarwal -
r24433:f5f4dc11 default
parent child Browse files
Show More
@@ -2105,6 +2105,13 b' def diff(repo, node1=None, node2=None, m'
2105 ctx1 = repo[node1]
2105 ctx1 = repo[node1]
2106 ctx2 = repo[node2]
2106 ctx2 = repo[node2]
2107
2107
2108 relfiltered = False
2109 if relroot != '' and match.always():
2110 # as a special case, create a new matcher with just the relroot
2111 pats = [relroot]
2112 match = scmutil.match(ctx2, pats, default='path')
2113 relfiltered = True
2114
2108 if not changes:
2115 if not changes:
2109 changes = repo.status(ctx1, ctx2, match=match)
2116 changes = repo.status(ctx1, ctx2, match=match)
2110 modified, added, removed = changes[:3]
2117 modified, added, removed = changes[:3]
@@ -2123,14 +2130,16 b' def diff(repo, node1=None, node2=None, m'
2123 copy = copies.pathcopies(ctx1, ctx2)
2130 copy = copies.pathcopies(ctx1, ctx2)
2124
2131
2125 if relroot is not None:
2132 if relroot is not None:
2126 # XXX this would ideally be done in the matcher, but that is generally
2133 if not relfiltered:
2127 # meant to 'or' patterns, not 'and' them. In this case we need to 'and'
2134 # XXX this would ideally be done in the matcher, but that is
2128 # all the patterns from the matcher with relroot.
2135 # generally meant to 'or' patterns, not 'and' them. In this case we
2136 # need to 'and' all the patterns from the matcher with relroot.
2129 def filterrel(l):
2137 def filterrel(l):
2130 return [f for f in l if f.startswith(relroot)]
2138 return [f for f in l if f.startswith(relroot)]
2131 modified = filterrel(modified)
2139 modified = filterrel(modified)
2132 added = filterrel(added)
2140 added = filterrel(added)
2133 removed = filterrel(removed)
2141 removed = filterrel(removed)
2142 relfiltered = True
2134 # filter out copies where either side isn't inside the relative root
2143 # filter out copies where either side isn't inside the relative root
2135 copy = dict(((dst, src) for (dst, src) in copy.iteritems()
2144 copy = dict(((dst, src) for (dst, src) in copy.iteritems()
2136 if dst.startswith(relroot)
2145 if dst.startswith(relroot)
General Comments 0
You need to be logged in to leave comments. Login now