Mercurial > hgsubversion
changeset 1182:8f9619a67565
maps: change readmapfile to take a path instead of repo
This is a small refactor for an upcoming change that will change map objects to
store a svnmeta instead of the repo.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:20:44 -0500 |
parents | eb4c7bc23f9e |
children | 09b20039192c |
files | hgsubversion/maps.py hgsubversion/svncommands.py hgsubversion/util.py |
diffstat | 3 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -231,9 +231,9 @@ class RevMap(dict): return os.path.join(repo.path, 'svn', 'rev_map') @classmethod - def readmapfile(cls, repo, missingok=True): + def readmapfile(cls, path, missingok=True): try: - f = open(cls.mappath(repo)) + f = open(path) except IOError, err: if not missingok or err.errno != errno.ENOENT: raise @@ -244,7 +244,7 @@ class RevMap(dict): return f def _load(self): - for l in self.readmapfile(self.repo): + for l in self.readmapfile(self.path): revnum, ha, branch = l.split(' ', 2) if branch == '\n': branch = None
--- a/hgsubversion/svncommands.py +++ b/hgsubversion/svncommands.py @@ -72,7 +72,7 @@ def _buildmeta(ui, repo, args, partial=F foundpartialinfo = False if os.path.exists(youngestpath): youngest = util.load(youngestpath) - sofar = list(maps.RevMap.readmapfile(repo)) + sofar = list(maps.RevMap.readmapfile(meta.revmap_file)) if sofar and len(sofar[-1].split(' ', 2)) > 1: lasthash = sofar[-1].split(' ', 2)[1] startrev = repo[lasthash].rev() + 1
--- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -343,9 +343,11 @@ def revset_fromsvn(repo, subset, x): rev = repo.changelog.rev bin = node.bin + meta = repo.svnmeta(skiperrorcheck=True) try: svnrevs = set(rev(bin(l.split(' ', 2)[1])) - for l in maps.RevMap.readmapfile(repo, missingok=False)) + for l in maps.RevMap.readmapfile(meta.revmap_file, + missingok=False)) return filter(svnrevs.__contains__, subset) except IOError, err: if err.errno != errno.ENOENT: @@ -368,8 +370,9 @@ def revset_svnrev(repo, subset, x): rev = rev + ' ' revs = [] + meta = repo.svnmeta(skiperrorcheck=True) try: - for l in maps.RevMap.readmapfile(repo, missingok=False): + for l in maps.RevMap.readmapfile(meta.revmap_file, missingok=False): if l.startswith(rev): n = l.split(' ', 2)[1] r = repo[node.bin(n)].rev()