##// END OF EJS Templates
context: reuse changectx._copies() in all but workingctx...
Martin von Zweigbergk -
r42477:a13b3055 default
parent child Browse files
Show More
@@ -272,6 +272,30 b' class basectx(object):'
272 except error.LookupError:
272 except error.LookupError:
273 return ''
273 return ''
274
274
275 @propertycache
276 def _copies(self):
277 p1copies = {}
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):
295 return self._copies[0]
296 def p2copies(self):
297 return self._copies[1]
298
275 def sub(self, path, allowcreate=True):
299 def sub(self, path, allowcreate=True):
276 '''return a subrepo for the stored revision of path, never wdir()'''
300 '''return a subrepo for the stored revision of path, never wdir()'''
277 return subrepo.subrepo(self, path, allowcreate=allowcreate)
301 return subrepo.subrepo(self, path, allowcreate=allowcreate)
@@ -456,27 +480,7 b' class changectx(basectx):'
456 # Otherwise (config said to read only from filelog, or we are in
480 # Otherwise (config said to read only from filelog, or we are in
457 # compatiblity mode and there is not data in the changeset), we get
481 # compatiblity mode and there is not data in the changeset), we get
458 # the copy metadata from the filelogs.
482 # the copy metadata from the filelogs.
459 p1copies = {}
483 return super(changectx, self)._copies
460 p2copies = {}
461 p1 = self.p1()
462 p2 = self.p2()
463 narrowmatch = self._repo.narrowmatch()
464 for dst in self.files():
465 if not narrowmatch(dst) or dst not in self:
466 continue
467 copied = self[dst].renamed()
468 if not copied:
469 continue
470 src, srcnode = copied
471 if src in p1 and p1[src].filenode() == srcnode:
472 p1copies[dst] = src
473 elif src in p2 and p2[src].filenode() == srcnode:
474 p2copies[dst] = src
475 return p1copies, p2copies
476 def p1copies(self):
477 return self._copies[0]
478 def p2copies(self):
479 return self._copies[1]
480 def description(self):
484 def description(self):
481 return self._changeset.description
485 return self._changeset.description
482 def branch(self):
486 def branch(self):
@@ -1206,26 +1210,6 b' class committablectx(basectx):'
1206 return self._status.removed
1210 return self._status.removed
1207 def deleted(self):
1211 def deleted(self):
1208 return self._status.deleted
1212 return self._status.deleted
1209 @propertycache
1210 def _copies(self):
1211 p1copies = {}
1212 p2copies = {}
1213 parents = self._repo.dirstate.parents()
1214 p1manifest = self._repo[parents[0]].manifest()
1215 p2manifest = self._repo[parents[1]].manifest()
1216 narrowmatch = self._repo.narrowmatch()
1217 for dst, src in self._repo.dirstate.copies().items():
1218 if not narrowmatch(dst):
1219 continue
1220 if src in p1manifest:
1221 p1copies[dst] = src
1222 elif src in p2manifest:
1223 p2copies[dst] = src
1224 return p1copies, p2copies
1225 def p1copies(self):
1226 return self._copies[0]
1227 def p2copies(self):
1228 return self._copies[1]
1229 def branch(self):
1213 def branch(self):
1230 return encoding.tolocal(self._extra['branch'])
1214 return encoding.tolocal(self._extra['branch'])
1231 def closesbranch(self):
1215 def closesbranch(self):
@@ -1579,6 +1563,27 b' class workingctx(committablectx):'
1579 return s
1563 return s
1580
1564
1581 @propertycache
1565 @propertycache
1566 def _copies(self):
1567 p1copies = {}
1568 p2copies = {}
1569 parents = self._repo.dirstate.parents()
1570 p1manifest = self._repo[parents[0]].manifest()
1571 p2manifest = self._repo[parents[1]].manifest()
1572 narrowmatch = self._repo.narrowmatch()
1573 for dst, src in self._repo.dirstate.copies().items():
1574 if not narrowmatch(dst):
1575 continue
1576 if src in p1manifest:
1577 p1copies[dst] = src
1578 elif src in p2manifest:
1579 p2copies[dst] = src
1580 return p1copies, p2copies
1581 def p1copies(self):
1582 return self._copies[0]
1583 def p2copies(self):
1584 return self._copies[1]
1585
1586 @propertycache
1582 def _manifest(self):
1587 def _manifest(self):
1583 """generate a manifest corresponding to the values in self._status
1588 """generate a manifest corresponding to the values in self._status
1584
1589
@@ -151,8 +151,8 b' Test rebasing a commit with copy informa'
151 rebasing 2:55d0b405c1b2 "rename a to b" (tip)
151 rebasing 2:55d0b405c1b2 "rename a to b" (tip)
152 merging a and b to b
152 merging a and b to b
153 saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/55d0b405c1b2-78df867e-rebase.hg
153 saved backup bundle to $TESTTMP/rebase-rename/.hg/strip-backup/55d0b405c1b2-78df867e-rebase.hg
154 BROKEN: should show the rename
155 $ hg st --change . --copies
154 $ hg st --change . --copies
156 A b
155 A b
156 a
157 R a
157 R a
158 $ cd ..
158 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now