Mercurial > hg
diff hgext/convert/subversion.py @ 22298:4ba35d4298a0
convert: refactor subversion getchanges and caching
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 26 Aug 2014 22:03:32 +0200 |
parents | a74d05878a8d |
children | 35ab037de989 |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Tue Aug 26 22:03:32 2014 +0200 +++ b/hgext/convert/subversion.py Tue Aug 26 22:03:32 2014 +0200 @@ -347,7 +347,7 @@ % self.module) self.last_changed = self.revnum(self.head) - self._changescache = None + self._changescache = (None, None) if os.path.exists(os.path.join(url, '.svn/entries')): self.wc = url @@ -444,10 +444,7 @@ return self.heads - def getchanges(self, rev): - if self._changescache and self._changescache[0] == rev: - return self._changescache[1] - self._changescache = None + def _getchanges(self, rev): (paths, parents) = self.paths[rev] if parents: files, self.removed, copies = self.expandpaths(rev, paths, parents) @@ -463,15 +460,23 @@ files.sort() files = zip(files, [rev] * len(files)) + return (files, copies) - # caller caches the result, so free it here to release memory - del self.paths[rev] + def getchanges(self, rev): + # reuse cache from getchangedfiles + if self._changescache[0] == rev: + (files, copies) = self._changescache[1] + else: + (files, copies) = self._getchanges(rev) + # caller caches the result, so free it here to release memory + del self.paths[rev] return (files, copies) def getchangedfiles(self, rev, i): - changes = self.getchanges(rev) - self._changescache = (rev, changes) - return [f[0] for f in changes[0]] + # called from filemap - cache computed values for reuse in getchanges + (files, copies) = self._getchanges(rev) + self._changescache = (rev, (files, copies)) + return [f[0] for f in files] def getcommit(self, rev): if rev not in self.commits: