changeset 16602:80aef0bc5ba7

context: add copies method with caching
author Matt Mackall <mpm@selenic.com>
date Sun, 06 May 2012 14:37:51 -0500
parents 0c98820be15c
children ddd4996740c7
files mercurial/context.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sun May 06 14:20:53 2012 -0500
+++ b/mercurial/context.py	Sun May 06 14:37:51 2012 -0500
@@ -8,6 +8,7 @@
 from node import nullid, nullrev, short, hex, bin
 from i18n import _
 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
+import copies
 import match as matchmod
 import os, errno, stat
 
@@ -695,6 +696,14 @@
             c = visit.pop(max(visit))
             yield c
 
+    def copies(self, c2):
+        if not util.hasattr(self, "_copycache"):
+            self._copycache = {}
+        sc2 = str(c2)
+        if sc2 not in self._copycache:
+            self._copycache[sc2] = copies.pathcopies(c2)
+        return self._copycache[sc2]
+
 class workingctx(changectx):
     """A workingctx object makes access to data related to
     the current working directory convenient.