comparison mercurial/context.py @ 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 f1745323a567
comparison
equal deleted inserted replaced
16601:0c98820be15c 16602:80aef0bc5ba7
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import nullid, nullrev, short, hex, bin 8 from node import nullid, nullrev, short, hex, bin
9 from i18n import _ 9 from i18n import _
10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases 10 import ancestor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
11 import copies
11 import match as matchmod 12 import match as matchmod
12 import os, errno, stat 13 import os, errno, stat
13 14
14 propertycache = util.propertycache 15 propertycache = util.propertycache
15 16
693 if not visit: 694 if not visit:
694 break 695 break
695 c = visit.pop(max(visit)) 696 c = visit.pop(max(visit))
696 yield c 697 yield c
697 698
699 def copies(self, c2):
700 if not util.hasattr(self, "_copycache"):
701 self._copycache = {}
702 sc2 = str(c2)
703 if sc2 not in self._copycache:
704 self._copycache[sc2] = copies.pathcopies(c2)
705 return self._copycache[sc2]
706
698 class workingctx(changectx): 707 class workingctx(changectx):
699 """A workingctx object makes access to data related to 708 """A workingctx object makes access to data related to
700 the current working directory convenient. 709 the current working directory convenient.
701 date - any valid date string or (unixtime, offset), or None. 710 date - any valid date string or (unixtime, offset), or None.
702 user - username string, or None. 711 user - username string, or None.