# HG changeset patch # User Sean Farley # Date 1395678044 18000 # Node ID 8f9619a675650aa86a074c335f883bd872ad639f # Parent eb4c7bc23f9e486e4de055326125d27acee13705 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. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- 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 diff --git a/hgsubversion/svncommands.py b/hgsubversion/svncommands.py --- 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 diff --git a/hgsubversion/util.py b/hgsubversion/util.py --- 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()