comparison mercurial/patch.py @ 29422:40d53d4b5925

patch: allow copy information to be passed in When displaying patches from graphical tools where you can browse through individual files, with diff being called separately on each, recomputing the limits of file copy history can become rather expensive on large repositories. Instead, we can compute it once and pass it in for subsequent calls.
author Henrik Stuart <henriks@unity3d.com>
date Mon, 27 Jun 2016 12:11:18 +0200
parents 0d83ad967bf8
children 160c829dd5d0
comparison
equal deleted inserted replaced
29421:ecbbf4d56ee8 29422:40d53d4b5925
2182 buildopts['noprefix'] = get('noprefix', forceplain=False) 2182 buildopts['noprefix'] = get('noprefix', forceplain=False)
2183 2183
2184 return mdiff.diffopts(**buildopts) 2184 return mdiff.diffopts(**buildopts)
2185 2185
2186 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None, 2186 def diff(repo, node1=None, node2=None, match=None, changes=None, opts=None,
2187 losedatafn=None, prefix='', relroot=''): 2187 losedatafn=None, prefix='', relroot='', copy=None):
2188 '''yields diff of changes to files between two nodes, or node and 2188 '''yields diff of changes to files between two nodes, or node and
2189 working directory. 2189 working directory.
2190 2190
2191 if node1 is None, use first dirstate parent instead. 2191 if node1 is None, use first dirstate parent instead.
2192 if node2 is None, compare node1 with working directory. 2192 if node2 is None, compare node1 with working directory.
2201 2201
2202 prefix is a filename prefix that is prepended to all filenames on 2202 prefix is a filename prefix that is prepended to all filenames on
2203 display (used for subrepos). 2203 display (used for subrepos).
2204 2204
2205 relroot, if not empty, must be normalized with a trailing /. Any match 2205 relroot, if not empty, must be normalized with a trailing /. Any match
2206 patterns that fall outside it will be ignored.''' 2206 patterns that fall outside it will be ignored.
2207
2208 copy, if not empty, should contain mappings {dst@y: src@x} of copy
2209 information.'''
2207 2210
2208 if opts is None: 2211 if opts is None:
2209 opts = mdiff.defaultopts 2212 opts = mdiff.defaultopts
2210 2213
2211 if not node1 and not node2: 2214 if not node1 and not node2:
2248 hexfunc = hex 2251 hexfunc = hex
2249 else: 2252 else:
2250 hexfunc = short 2253 hexfunc = short
2251 revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node] 2254 revs = [hexfunc(node) for node in [ctx1.node(), ctx2.node()] if node]
2252 2255
2253 copy = {} 2256 if copy is None:
2254 if opts.git or opts.upgrade: 2257 copy = {}
2255 copy = copies.pathcopies(ctx1, ctx2, match=match) 2258 if opts.git or opts.upgrade:
2259 copy = copies.pathcopies(ctx1, ctx2, match=match)
2256 2260
2257 if relroot is not None: 2261 if relroot is not None:
2258 if not relfiltered: 2262 if not relfiltered:
2259 # XXX this would ideally be done in the matcher, but that is 2263 # XXX this would ideally be done in the matcher, but that is
2260 # generally meant to 'or' patterns, not 'and' them. In this case we 2264 # generally meant to 'or' patterns, not 'and' them. In this case we