Mercurial > hgsubversion
changeset 1416:020917cde9f5
util: get rid of RevMap.readmapfile
This is a part of the bigger plan to get rid of reading or writing rev_map
directly without going through the RevMap class.
Since we have enough pieces to not use RevMap.readmapfile directly, use
them in revset_fromsvn and revset_svnrev.
author | Jun Wu <quark@fb.com> |
---|---|
date | Sat, 14 May 2016 19:55:03 +0100 |
parents | d6cec13b4bb0 |
children | c161586a6b77 |
files | hgsubversion/util.py |
diffstat | 1 files changed, 10 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgsubversion/util.py +++ b/hgsubversion/util.py @@ -320,16 +320,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(meta.revmap_file, - missingok=False)) - return filter(svnrevs.__contains__, subset) - except IOError, err: - if err.errno != errno.ENOENT: - raise + if not meta.revmapexists: raise hgutil.Abort("svn metadata is missing - " "run 'hg svn rebuildmeta' to reconstruct it") + svnrevs = set(rev(h) for h in meta.revmap.hashes().keys()) + return filter(svnrevs.__contains__, subset) def revset_svnrev(repo, subset, x): '''``svnrev(number)`` @@ -344,22 +339,16 @@ def revset_svnrev(repo, subset, x): except ValueError: raise error.ParseError("the argument to svnrev() must be a number") - rev = rev + ' ' - revs = [] meta = repo.svnmeta(skiperrorcheck=True) - try: - 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() - if r in subset: - revs.append(r) - return revs - except IOError, err: - if err.errno != errno.ENOENT: - raise + if not meta.revmapexists: raise hgutil.Abort("svn metadata is missing - " "run 'hg svn rebuildmeta' to reconstruct it") + revs = [] + for n in meta.revmap.revhashes(revnum): + r = repo[n].rev() + if r in subset: + revs.append(r) + return revs revsets = { 'fromsvn': revset_fromsvn,