comparison mercurial/context.py @ 42707:3cffc7bbec26

copies: extract an explicit `computechangesetcopie` method from context Right now, the logic around changeset centric copies data are buried into the "changectx" code. We extract this code in a dedicated method (in the copies module) for clarity. This clarity will help to explicitly compute and caches these data in the future.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 06 Aug 2019 03:17:40 +0200
parents 97b03f0e7c7b
children 87c4cd89b539
comparison
equal deleted inserted replaced
42706:60789444acd6 42707:3cffc7bbec26
22 short, 22 short,
23 wdirfilenodeids, 23 wdirfilenodeids,
24 wdirhex, 24 wdirhex,
25 ) 25 )
26 from . import ( 26 from . import (
27 copies,
27 dagop, 28 dagop,
28 encoding, 29 encoding,
29 error, 30 error,
30 fileset, 31 fileset,
31 match as matchmod, 32 match as matchmod,
272 except error.LookupError: 273 except error.LookupError:
273 return '' 274 return ''
274 275
275 @propertycache 276 @propertycache
276 def _copies(self): 277 def _copies(self):
277 p1copies = {} 278 return copies.computechangesetcopies(self)
278 p2copies = {}
279 p1 = self.p1()
280 p2 = self.p2()
281 narrowmatch = self._repo.narrowmatch()
282 for dst in self.files():
283 if not narrowmatch(dst) or dst not in self:
284 continue
285 copied = self[dst].renamed()
286 if not copied:
287 continue
288 src, srcnode = copied
289 if src in p1 and p1[src].filenode() == srcnode:
290 p1copies[dst] = src
291 elif src in p2 and p2[src].filenode() == srcnode:
292 p2copies[dst] = src
293 return p1copies, p2copies
294 def p1copies(self): 279 def p1copies(self):
295 return self._copies[0] 280 return self._copies[0]
296 def p2copies(self): 281 def p2copies(self):
297 return self._copies[1] 282 return self._copies[1]
298 283