changeset 416:cd6317fe70be

invert the svnmeta/editor relationship
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Thu, 11 Jun 2009 18:49:52 +0200
parents b17b2969861c
children 8630d1ebcdb9
files hgsubversion/cmdutil.py hgsubversion/hg_delta_editor.py hgsubversion/stupid.py hgsubversion/svnmeta.py hgsubversion/util.py hgsubversion/utility_commands.py hgsubversion/wrappers.py tests/test_rebuildmeta.py
diffstat 8 files changed, 114 insertions(+), 108 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/cmdutil.py
+++ b/hgsubversion/cmdutil.py
@@ -43,31 +43,31 @@ def filterdiff(diff, oldrev, newrev):
     return diff
 
 
-def parentrev(ui, repo, hge, svn_commit_hashes):
+def parentrev(ui, repo, meta, hashes):
     """Find the svn parent revision of the repo's dirstate.
     """
     workingctx = repo.parents()[0]
-    outrev = util.outgoing_revisions(ui, repo, hge, svn_commit_hashes,
-                                     workingctx.node())
+    outrev = util.outgoing_revisions(repo, hashes, workingctx.node())
     if outrev:
         workingctx = repo[outrev[-1]].parents()[0]
     return workingctx
 
 
-def replay_convert_rev(ui, hg_editor, svn, r, tbdelta):
+def replay_convert_rev(ui, meta, svn, r, tbdelta):
     # ui is only passed in for similarity with stupid.convert_rev()
+    hg_editor = meta.editor
     hg_editor.current.rev = r
-    hg_editor.meta.save_tbdelta(tbdelta) # needed by get_replay()
-    svn.get_replay(r.revnum, hg_editor)
+    meta.save_tbdelta(tbdelta) # needed by get_replay()
+    svn.get_replay(r.revnum, meta.editor)
     i = 1
     if hg_editor.current.missing:
-        hg_editor.ui.debug('Fetching %s files that could not use replay.\n' %
-                           len(hg_editor.current.missing))
+        meta.ui.debug('Fetching %s files that could not use replay.\n' %
+                      len(hg_editor.current.missing))
         files_to_grab = set()
         rootpath = svn.subdir and svn.subdir[1:] or ''
         for p in hg_editor.current.missing:
-            hg_editor.ui.note('.')
-            hg_editor.ui.flush()
+            meta.ui.note('.')
+            meta.ui.flush()
             if p[-1] == '/':
                 dirpath = p[len(rootpath):]
                 files_to_grab.update([dirpath + f for f,k in
@@ -75,17 +75,17 @@ def replay_convert_rev(ui, hg_editor, sv
                                       if k == 'f'])
             else:
                 files_to_grab.add(p[len(rootpath):])
-        hg_editor.ui.note('\nFetching files...\n')
+        meta.ui.note('\nFetching files...\n')
         for p in files_to_grab:
-            hg_editor.ui.note('.')
-            hg_editor.ui.flush()
+            meta.ui.note('.')
+            meta.ui.flush()
             if i % 50 == 0:
                 svn.init_ra_and_client()
             i += 1
             data, mode = svn.get_file(p, r.revnum)
             hg_editor.set_file(p, data, 'x' in mode, 'l' in mode)
         hg_editor.current.missing = set()
-        hg_editor.ui.note('\n')
+        meta.ui.note('\n')
     hg_editor.commit_current_delta(tbdelta)
 
 
@@ -168,7 +168,7 @@ def _externals(ctx):
     return ext
 
 
-def commit_from_rev(ui, repo, rev_ctx, hg_editor, svn_url, base_revision,
+def commit_from_rev(ui, repo, rev_ctx, meta, svn_url, base_revision,
                     username, password):
     """Build and send a commit from Mercurial to Subversion.
     """
--- a/hgsubversion/hg_delta_editor.py
+++ b/hgsubversion/hg_delta_editor.py
@@ -9,7 +9,6 @@ from mercurial import node
 from svn import delta
 from svn import core
 
-import svnmeta
 import svnexternals
 import util
 
@@ -71,10 +70,10 @@ class RevisionData(object):
 
 class HgChangeReceiver(delta.Editor):
 
-    def __init__(self, repo, uuid=None, subdir=''):
-        self.ui = repo.ui
-        self.repo = repo
-        self.meta = svnmeta.SVNMeta(repo, uuid, subdir)
+    def __init__(self, meta):
+        self.meta = meta
+        self.ui = meta.ui
+        self.repo = meta.repo
         self.current = RevisionData()
 
     def set_file(self, path, data, isexec=False, islink=False):
--- a/hgsubversion/stupid.py
+++ b/hgsubversion/stupid.py
@@ -76,13 +76,13 @@ def mempatchproxy(parentctx, files):
     return mempatch
 
 
-def filteriterhunks(hg_editor):
+def filteriterhunks(meta):
     iterhunks = patch.iterhunks
     def filterhunks(ui, fp, sourcefile=None):
         applycurrent = False
         for data in iterhunks(ui, fp, sourcefile):
             if data[0] == 'file':
-                if data[1][1] in hg_editor.meta.filemap:
+                if data[1][1] in meta.filemap:
                     applycurrent = True
                 else:
                     applycurrent = False
@@ -92,7 +92,7 @@ def filteriterhunks(hg_editor):
     return filterhunks
 
 
-def diff_branchrev(ui, svn, hg_editor, branch, r, parentctx):
+def diff_branchrev(ui, svn, meta, branch, r, parentctx):
     """Extract all 'branch' content at a given revision.
 
     Return a tuple (files, filectxfn) where 'files' is the list of all files
@@ -106,7 +106,7 @@ def diff_branchrev(ui, svn, hg_editor, b
         elif branch.startswith('../'):
             return branch[3:]
         return 'branches/%s' % branch
-    parent_rev, br_p = hg_editor.meta.get_parent_svn_branch_and_rev(r.revnum, branch)
+    parent_rev, br_p = meta.get_parent_svn_branch_and_rev(r.revnum, branch)
     diff_path = make_diff_path(branch)
     try:
         if br_p == branch:
@@ -149,7 +149,7 @@ def diff_branchrev(ui, svn, hg_editor, b
             oldpatchfile = patch.patchfile
             olditerhunks = patch.iterhunks
             patch.patchfile = mempatchproxy(parentctx, files_data)
-            patch.iterhunks = filteriterhunks(hg_editor)
+            patch.iterhunks = filteriterhunks(meta)
             try:
                 # We can safely ignore the changed list since we are
                 # handling non-git patches. Touched files are known
@@ -211,7 +211,7 @@ def diff_branchrev(ui, svn, hg_editor, b
     for f in files_data:
         touched_files[f] = 1
 
-    copies = getcopies(svn, hg_editor, branch, diff_path, r, touched_files,
+    copies = getcopies(svn, meta, branch, diff_path, r, touched_files,
                        parentctx)
 
     def filectxfn(repo, memctx, path):
@@ -282,7 +282,7 @@ def makecopyfinder(r, branchpath, rootdi
 
     return finder
 
-def getcopies(svn, hg_editor, branch, branchpath, r, files, parentctx):
+def getcopies(svn, meta, branch, branchpath, r, files, parentctx):
     """Return a mapping {dest: source} for every file copied into r.
     """
     if parentctx.node() == revlog.nullid:
@@ -307,10 +307,10 @@ def getcopies(svn, hg_editor, branch, br
     def getctx(svnrev):
         if svnrev in ctxs:
             return ctxs[svnrev]
-        changeid = hg_editor.meta.get_parent_revision(svnrev + 1, branch)
+        changeid = meta.get_parent_revision(svnrev + 1, branch)
         ctx = None
         if changeid != revlog.nullid:
-            ctx = hg_editor.repo.changectx(changeid)
+            ctx = meta.repo.changectx(changeid)
         ctxs[svnrev] = ctx
         return ctx
 
@@ -378,7 +378,7 @@ def fetch_externals(svn, branchpath, r, 
     return externals
 
 
-def fetch_branchrev(svn, hg_editor, branch, branchpath, r, parentctx):
+def fetch_branchrev(svn, meta, branch, branchpath, r, parentctx):
     """Extract all 'branch' content at a given revision.
 
     Return a tuple (files, filectxfn) where 'files' is the list of all files
@@ -396,7 +396,7 @@ def fetch_branchrev(svn, hg_editor, bran
         for path, e in r.paths.iteritems():
             if not path.startswith(branchprefix):
                 continue
-            if not hg_editor.meta._is_path_valid(path):
+            if not meta._is_path_valid(path):
                 continue
             kind = svn.checkpath(path, r.revnum)
             path = path[len(branchprefix):]
@@ -418,7 +418,7 @@ def fetch_branchrev(svn, hg_editor, bran
                 deleted = [f for f in parentctx if f.startswith(path)]
                 files += deleted
 
-    copies = getcopies(svn, hg_editor, branch, branchpath, r, files, parentctx)
+    copies = getcopies(svn, meta, branch, branchpath, r, files, parentctx)
 
     def filectxfn(repo, memctx, path):
         data, mode = svn.get_file(branchpath + '/' + path, r.revnum)
@@ -430,32 +430,32 @@ def fetch_branchrev(svn, hg_editor, bran
 
     return files, filectxfn
 
-def checkbranch(hg_editor, r, branch):
-    branchedits = hg_editor.meta.revmap.branchedits(branch, r)
+def checkbranch(meta, r, branch):
+    branchedits = meta.revmap.branchedits(branch, r)
     if not branchedits:
         return None
     branchtip = branchedits[0][1]
-    for child in hg_editor.repo[branchtip].children():
+    for child in meta.repo[branchtip].children():
         b = child.branch() != 'default' and child.branch() or None
         if b == branch and child.extra().get('close'):
             return None
     return branchtip
 
-def branches_in_paths(hge, tbdelta, paths, revnum, checkpath, listdir):
+def branches_in_paths(meta, tbdelta, paths, revnum, checkpath, listdir):
     '''Given a list of paths, return mapping of all branches touched
     to their branch path.
     '''
     branches = {}
     paths_need_discovery = []
     for p in paths:
-        relpath, branch, branchpath = hge.meta._split_branch_path(p)
+        relpath, branch, branchpath = meta._split_branch_path(p)
         if relpath is not None:
             branches[branch] = branchpath
-        elif paths[p].action == 'D' and not hge.meta._is_path_tag(p):
-            ln = hge.meta._localname(p)
+        elif paths[p].action == 'D' and not meta._is_path_tag(p):
+            ln = meta._localname(p)
             # must check in branches_to_delete as well, because this runs after we
             # already updated the branch map
-            if ln in hge.meta.branches or ln in tbdelta['branches'][1]:
+            if ln in meta.branches or ln in tbdelta['branches'][1]:
                 branches[ln] = p
         else:
             paths_need_discovery.append(p)
@@ -497,12 +497,12 @@ def branches_in_paths(hge, tbdelta, path
             path = filepaths.pop(0)
             parentdir = '/'.join(path[:-1])
             filepaths = [p for p in filepaths if not '/'.join(p).startswith(parentdir)]
-            branchpath = hge.meta._normalize_path(parentdir)
+            branchpath = meta._normalize_path(parentdir)
             if branchpath.startswith('tags/'):
                 continue
-            branchname = hge.meta._localname(branchpath)
+            branchname = meta._localname(branchpath)
             if branchpath.startswith('trunk/'):
-                branches[hge.meta._localname('trunk')] = 'trunk'
+                branches[meta._localname('trunk')] = 'trunk'
                 continue
             if branchname and branchname.startswith('../'):
                 continue
@@ -510,11 +510,11 @@ def branches_in_paths(hge, tbdelta, path
 
     return branches
 
-def convert_rev(ui, hg_editor, svn, r, tbdelta):
+def convert_rev(ui, meta, svn, r, tbdelta):
     # this server fails at replay
 
-    hg_editor.meta.save_tbdelta(tbdelta)
-    branches = branches_in_paths(hg_editor, tbdelta, r.paths, r.revnum,
+    meta.save_tbdelta(tbdelta)
+    branches = branches_in_paths(meta, tbdelta, r.paths, r.revnum,
                                  svn.checkpath, svn.list_files)
     brpaths = branches.values()
     bad_branch_paths = {}
@@ -529,27 +529,27 @@ def convert_rev(ui, hg_editor, svn, r, t
 
         # We've go a branch that contains other branches. We have to be careful to
         # get results similar to real replay in this case.
-        for existingbr in hg_editor.meta.branches:
-            bad = hg_editor.meta._remotename(existingbr)
+        for existingbr in meta.branches:
+            bad = meta._remotename(existingbr)
             if bad.startswith(bp) and len(bad) > len(bp):
                 bad_branch_paths[br].append(bad[len(bp)+1:])
 
     deleted_branches = {}
     for p in r.paths:
-        if hg_editor.meta._is_path_tag(p):
+        if meta._is_path_tag(p):
             continue
-        branch = hg_editor.meta._localname(p)
-        if not (r.paths[p].action == 'R' and branch in hg_editor.meta.branches):
+        branch = meta._localname(p)
+        if not (r.paths[p].action == 'R' and branch in meta.branches):
             continue
-        closed = checkbranch(hg_editor, r, branch)
+        closed = checkbranch(meta, r, branch)
         if closed is not None:
             deleted_branches[branch] = closed
 
-    date = hg_editor.meta.fixdate(r.date)
+    date = meta.fixdate(r.date)
     check_deleted_branches = set()
     for b in branches:
 
-        parentctx = hg_editor.repo[hg_editor.meta.get_parent_revision(r.revnum, b)]
+        parentctx = meta.repo[meta.get_parent_revision(r.revnum, b)]
         if parentctx.branch() != (b or 'default'):
             check_deleted_branches.add(b)
 
@@ -562,12 +562,12 @@ def convert_rev(ui, hg_editor, svn, r, t
 
         try:
             files_touched, filectxfn2 = diff_branchrev(
-                                           ui, svn, hg_editor, b, r, parentctx)
+                                           ui, svn, meta, b, r, parentctx)
         except BadPatchApply, e:
             # Either this revision or the previous one does not exist.
             ui.status("Fetching entire revision: %s.\n" % e.args[0])
             files_touched, filectxfn2 = fetch_branchrev(
-                svn, hg_editor, b, branches[b], r, parentctx)
+                svn, meta, b, branches[b], r, parentctx)
 
         externals = fetch_externals(svn, branches[b], r, parentctx)
         if externals is not None:
@@ -586,7 +586,7 @@ def convert_rev(ui, hg_editor, svn, r, t
 
         if '' in files_touched:
             files_touched.remove('')
-        excluded = [f for f in files_touched if f not in hg_editor.meta.filemap]
+        excluded = [f for f in files_touched if f not in meta.filemap]
         for f in excluded:
             files_touched.remove(f)
 
@@ -600,39 +600,39 @@ def convert_rev(ui, hg_editor, svn, r, t
                 assert f[0] != '/'
 
         extra = util.build_extra(r.revnum, b, svn.uuid, svn.subdir)
-        if not hg_editor.meta.usebranchnames:
+        if not meta.usebranchnames:
             extra.pop('branch', None)
 
-        current_ctx = context.memctx(hg_editor.repo,
+        current_ctx = context.memctx(meta.repo,
                                      [parentctx.node(), revlog.nullid],
                                      r.message or util.default_commit_msg,
                                      files_touched,
                                      filectxfn,
-                                     hg_editor.meta.authors[r.author],
+                                     meta.authors[r.author],
                                      date,
                                      extra)
-        ha = hg_editor.repo.commitctx(current_ctx)
+        ha = meta.repo.commitctx(current_ctx)
 
         branch = extra.get('branch', None)
-        if not branch in hg_editor.meta.branches:
-            hg_editor.meta.branches[branch] = None, 0, r.revnum
-        hg_editor.meta.revmap[r.revnum, b] = ha
+        if not branch in meta.branches:
+            meta.branches[branch] = None, 0, r.revnum
+        meta.revmap[r.revnum, b] = ha
         util.describe_commit(ui, ha, b)
 
     # These are branches with an 'R' status in svn log. This means they were
     # replaced by some other branch, so we need to verify they get marked as closed.
     for branch in check_deleted_branches:
-        closed = checkbranch(hg_editor, r, branch)
+        closed = checkbranch(meta, r, branch)
         if closed is not None:
             deleted_branches[branch] = closed
 
     if tbdelta['tags'][0] or tbdelta['tags'][1]:
-        hg_editor.meta.committags(tbdelta['tags'], r, deleted_branches)
+        meta.committags(tbdelta['tags'], r, deleted_branches)
 
     for b, parent in deleted_branches.iteritems():
         if parent == node.nullid:
             continue
-        hg_editor.meta.delbranch(b, parent, r)
+        meta.delbranch(b, parent, r)
 
     # save the changed metadata
-    hg_editor.meta._save_metadata()
+    meta._save_metadata()
--- a/hgsubversion/svnmeta.py
+++ b/hgsubversion/svnmeta.py
@@ -9,6 +9,7 @@ from mercurial import node
 
 import util
 import maps
+import hg_delta_editor
 
 
 def pickle_atomic(data, file_path, dir=None):
@@ -81,6 +82,12 @@ class SVNMeta(object):
         self.lastdate = '1970-01-01 00:00:00 -0000'
         self.filemap = maps.FileMap(repo)
 
+    @property
+    def editor(self):
+        if not hasattr(self, '_editor'):
+            self._editor = hg_delta_editor.HgChangeReceiver(self)
+        return self._editor
+
     def _get_uuid(self):
         return open(os.path.join(self.meta_data_dir, 'uuid')).read()
 
--- a/hgsubversion/util.py
+++ b/hgsubversion/util.py
@@ -42,7 +42,7 @@ class PrefixMatch(object):
     def __call__(self, fn):
         return fn.startswith(self.p)
 
-def outgoing_revisions(ui, repo, hg_editor, reverse_map, sourcerev):
+def outgoing_revisions(repo, reverse_map, sourcerev):
     """Given a repo and an hg_editor, determines outgoing revisions for the
     current working copy state.
     """
--- a/hgsubversion/utility_commands.py
+++ b/hgsubversion/utility_commands.py
@@ -2,10 +2,10 @@ import os
 
 from mercurial import util as hgutil
 
+import svnmeta
 import svnwrap
 import cmdutil
 import util
-import hg_delta_editor
 
 def genignore(ui, repo, hg_repo_path, force=False, **opts):
     """generate .hgignore from svn:ignore properties.
@@ -18,9 +18,9 @@ def genignore(ui, repo, hg_repo_path, fo
     url = util.normalize_url(repo.ui.config('paths', 'default'))
     user, passwd = util.getuserpass(opts)
     svn = svnwrap.SubversionRepo(url, user, passwd)
-    hge = hg_delta_editor.HgChangeReceiver(repo, svn.uuid)
-    hashes = hge.meta.revmap.hashes()
-    parent = cmdutil.parentrev(ui, repo, hge, hashes)
+    meta = svnmeta.SVNMeta(repo, svn.uuid)
+    hashes = meta.revmap.hashes()
+    parent = cmdutil.parentrev(ui, repo, meta, hashes)
     r, br = hashes[parent.node()]
     if br == None:
         branchpath = 'trunk'
@@ -46,9 +46,9 @@ def info(ui, repo, hg_repo_path, **opts)
     url = util.normalize_url(repo.ui.config('paths', 'default'))
     user, passwd = util.getuserpass(opts)
     svn = svnwrap.SubversionRepo(url, user, passwd)
-    hge = hg_delta_editor.HgChangeReceiver(repo, svn.uuid)
-    hashes = hge.meta.revmap.hashes()
-    parent = cmdutil.parentrev(ui, repo, hge, hashes)
+    meta = svnmeta.SVNMeta(repo, svn.uuid)
+    hashes = meta.revmap.hashes()
+    parent = cmdutil.parentrev(ui, repo, meta, hashes)
     pn = parent.node()
     if pn not in hashes:
         ui.status('Not a child of an svn revision.\n')
@@ -66,7 +66,7 @@ def info(ui, repo, hg_repo_path, **opts)
     if url[-1] == '/':
         url = url[:-1]
     url = '%s%s' % (url, branchpath)
-    author = hge.meta.authors.reverselookup(parent.user())
+    author = meta.authors.reverselookup(parent.user())
     # cleverly figure out repo root w/o actually contacting the server
     reporoot = url[:len(url)-len(subdir)]
     ui.status('''URL: %(url)s
@@ -78,7 +78,7 @@ Last Changed Author: %(author)s
 Last Changed Rev: %(revision)s
 Last Changed Date: %(date)s\n''' %
               {'reporoot': reporoot,
-               'uuid': hge.meta.uuid,
+               'uuid': meta.uuid,
                'url': url,
                'author': author,
                'revision': r,
--- a/hgsubversion/wrappers.py
+++ b/hgsubversion/wrappers.py
@@ -14,7 +14,7 @@ from svn import core
 from svn import delta
 
 import cmdutil
-import hg_delta_editor
+import svnmeta
 import stupid as stupidmod
 import svnwrap
 import util
@@ -36,9 +36,9 @@ def parents(orig, ui, repo, *args, **opt
     """
     if not opts.get('svn', False):
         return orig(ui, repo, *args, **opts)
-    hge = hg_delta_editor.HgChangeReceiver(repo)
-    hashes = hge.meta.revmap.hashes()
-    ha = cmdutil.parentrev(ui, repo, hge, hashes)
+    meta = svnmeta.SVNMeta(repo)
+    hashes = meta.revmap.hashes()
+    ha = cmdutil.parentrev(ui, repo, meta, hashes)
     if ha.node() == node.nullid:
         raise hgutil.Abort('No parent svn revision!')
     displayer = hgcmdutil.show_changeset(ui, repo, opts, buffered=False)
@@ -57,10 +57,10 @@ def incoming(orig, ui, repo, source='def
 
     user, passwd = util.getuserpass(opts)
     svn = svnwrap.SubversionRepo(other.svnurl, user, passwd)
-    hg_editor = hg_delta_editor.HgChangeReceiver(repo)
+    meta = svnmeta.SVNMeta(repo)
 
     ui.status('incoming changes from %s\n' % other.svnurl)
-    for r in svn.revisions(start=hg_editor.meta.revmap.seen):
+    for r in svn.revisions(start=meta.revmap.seen):
         ui.status('\n')
         for label, attr in revmeta:
             l1 = label + ':'
@@ -77,10 +77,10 @@ def outgoing(repo, dest=None, heads=None
 
     # split off #rev; TODO implement --revision/#rev support
     svnurl, revs, checkout = hg.parseurl(dest.svnurl, heads)
-    hge = hg_delta_editor.HgChangeReceiver(repo)
+    meta = svnmeta.SVNMeta(repo)
     parent = repo.parents()[0].node()
-    hashes = hge.meta.revmap.hashes()
-    return util.outgoing_revisions(repo.ui, repo, hge, hashes, parent)
+    hashes = meta.revmap.hashes()
+    return util.outgoing_revisions(repo, hashes, parent)
 
 
 def diff(orig, ui, repo, *args, **opts):
@@ -88,11 +88,11 @@ def diff(orig, ui, repo, *args, **opts):
     """
     if not opts.get('svn', False) or opts.get('change', None):
         return orig(ui, repo, *args, **opts)
-    hge = hg_delta_editor.HgChangeReceiver(repo)
-    hashes = hge.meta.revmap.hashes()
+    meta = svnmeta.SVNMeta(repo)
+    hashes = meta.revmap.hashes()
     if not opts.get('rev', None):
         parent = repo.parents()[0]
-        o_r = util.outgoing_revisions(ui, repo, hge, hashes, parent.node())
+        o_r = util.outgoing_revisions(repo, hashes, parent.node())
         if o_r:
             parent = repo[o_r[-1]].parents()[0]
         opts['rev'] = ['%s:.' % node.hex(parent.node()), ]
@@ -123,7 +123,7 @@ def push(repo, dest, force, revs):
     user = repo.ui.config('hgsubversion', 'username')
     passwd = repo.ui.config('hgsubversion', 'password')
     svn = svnwrap.SubversionRepo(svnurl, user, passwd)
-    hge = hg_delta_editor.HgChangeReceiver(repo, svn.uuid)
+    meta = svnmeta.SVNMeta(repo, svn.uuid)
 
     # Strategy:
     # 1. Find all outgoing commits from this head
@@ -132,8 +132,8 @@ def push(repo, dest, force, revs):
         return 1
     workingrev = repo.parents()[0]
     ui.status('searching for changes\n')
-    hashes = hge.meta.revmap.hashes()
-    outgoing = util.outgoing_revisions(ui, repo, hge, hashes, workingrev.node())
+    hashes = meta.revmap.hashes()
+    outgoing = util.outgoing_revisions(repo, hashes, workingrev.node())
     if not (outgoing and len(outgoing)):
         ui.status('no changes found\n')
         return 0
@@ -157,7 +157,7 @@ def push(repo, dest, force, revs):
         # 2. Commit oldest revision that needs to be pushed
         base_revision = hashes[base_n][0]
         try:
-            cmdutil.commit_from_rev(ui, repo, old_ctx, hge, svnurl,
+            cmdutil.commit_from_rev(ui, repo, old_ctx, meta, svnurl,
                                     base_revision, user, passwd)
         except cmdutil.NoFilesException:
             ui.warn("Could not push revision %s because it had no changes in svn.\n" %
@@ -183,7 +183,7 @@ def push(repo, dest, force, revs):
             # TODO: can we avoid calling our own rebase wrapper here?
             rebase(hgrebase.rebase, ui, repo, svn=True, svnextrafn=extrafn,
                    svnsourcerev=needs_transplant)
-            repo = hg.repository(ui, hge.meta.path)
+            repo = hg.repository(ui, meta.path)
             for child in repo[replacement.node()].children():
                 rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
                 if rebasesrc in outgoing:
@@ -195,9 +195,9 @@ def push(repo, dest, force, revs):
                         if children:
                             child = children[0]
                         rebasesrc = node.bin(child.extra().get('rebase_source', node.hex(node.nullid)))
-        # TODO: stop constantly creating the HgChangeReceiver instances.
-        hge = hg_delta_editor.HgChangeReceiver(hge.repo, svn.uuid)
-        hashes = hge.meta.revmap.hashes()
+        # TODO: stop constantly creating the SVNMeta instances.
+        meta = svnmeta.SVNMeta(meta.repo, svn.uuid)
+        hashes = meta.revmap.hashes()
     util.swap_out_encoding(old_encoding)
     return 0
 
@@ -235,10 +235,10 @@ def pull(repo, source, heads=[], force=F
     user = repo.ui.config('hgsubversion', 'username')
     passwd = repo.ui.config('hgsubversion', 'password')
     svn = svnwrap.SubversionRepo(svn_url, user, passwd)
-    hg_editor = hg_delta_editor.HgChangeReceiver(repo, svn.uuid, svn.subdir)
+    meta = svnmeta.SVNMeta(repo, svn.uuid, svn.subdir)
 
-    start = max(hg_editor.meta.revmap.seen, skipto_rev)
-    initializing_repo = hg_editor.meta.revmap.seen <= 0
+    start = max(meta.revmap.seen, skipto_rev)
+    initializing_repo = meta.revmap.seen <= 0
     ui = repo.ui
 
     if initializing_repo and start > 0:
@@ -253,14 +253,14 @@ def pull(repo, source, heads=[], force=F
                 if (r.author is None and
                     r.message == 'This is an empty revision for padding.'):
                     continue
-                tbdelta = hg_editor.meta.update_branch_tag_map_for_rev(r)
+                tbdelta = meta.update_branch_tag_map_for_rev(r)
                 # got a 502? Try more than once!
                 tries = 0
                 converted = False
                 while not converted:
                     try:
                         util.describe_revision(ui, r)
-                        pullfuns[have_replay](ui, hg_editor, svn, r, tbdelta)
+                        pullfuns[have_replay](ui, meta, svn, r, tbdelta)
                         converted = True
                     except svnwrap.SubversionRepoCanNotReplay, e: #pragma: no cover
                         ui.status('%s\n' % e.message)
@@ -304,9 +304,9 @@ def rebase(orig, ui, repo, **opts):
         extra['branch'] = ctx.branch()
     extrafn = opts.get('svnextrafn', extrafn2)
     sourcerev = opts.get('svnsourcerev', repo.parents()[0].node())
-    hge = hg_delta_editor.HgChangeReceiver(repo)
-    hashes = hge.meta.revmap.hashes()
-    o_r = util.outgoing_revisions(ui, repo, hge, hashes, sourcerev=sourcerev)
+    meta = svnmeta.SVNMeta(repo)
+    hashes = meta.revmap.hashes()
+    o_r = util.outgoing_revisions(repo, hashes, sourcerev=sourcerev)
     if not o_r:
         ui.status('Nothing to rebase!\n')
         return 0
--- a/tests/test_rebuildmeta.py
+++ b/tests/test_rebuildmeta.py
@@ -8,7 +8,7 @@ from mercurial import hg
 from mercurial import ui
 
 from hgsubversion import svncommands
-from hgsubversion import hg_delta_editor
+from hgsubversion import svnmeta
 
 def _do_case(self, name, stupid):
     subdir = test_util.subdir.get(name, '')
@@ -38,7 +38,7 @@ def _do_case(self, name, stupid):
     srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info')))
     destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info')))
     self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys()))
-    revkeys = hg_delta_editor.HgChangeReceiver(dest).meta.revmap.keys()
+    revkeys = svnmeta.SVNMeta(dest).revmap.keys()
     for branch in destbi:
         srcinfo = srcbi[branch]
         destinfo = destbi[branch]