# HG changeset patch # User Dirkjan Ochtman # Date 1245136312 -7200 # Node ID 404162e4bb53df56fae33b43453f62520e80bc51 # Parent 7c576ae19d80fe39e64a830cf3897df04c9bccb5 editor: move find missing files routine into RevisionData class diff --git a/hgsubversion/editor.py b/hgsubversion/editor.py --- a/hgsubversion/editor.py +++ b/hgsubversion/editor.py @@ -77,6 +77,41 @@ class RevisionData(object): self.symlinks[path] = False self.ui.note('D %s\n' % path) + def findmissing(self, svn): + + if not self.missing: + return + + msg = 'fetching %s files that could not use replay.\n' + self.ui.debug(msg % len(self.missing)) + root = svn.subdir and svn.subdir[1:] or '' + r = self.rev.revnum + + files = set() + for p in self.missing: + self.ui.note('.') + self.ui.flush() + if p[-1] == '/': + dir = p[len(root):] + new = [dir + f for f, k in svn.list_files(dir, r) if k == 'f'] + files.update(new) + else: + files.add(p[len(root):]) + + i = 1 + self.ui.note('\nfetching files...\n') + for p in files: + self.ui.note('.') + self.ui.flush() + if i % 50 == 0: + svn.init_ra_and_client() + i += 1 + data, mode = svn.get_file(p, r) + self.set(p, data, 'x' in mode, 'l' in mode) + + self.missing = set() + self.ui.note('\n') + class HgEditor(delta.Editor): diff --git a/hgsubversion/replay.py b/hgsubversion/replay.py --- a/hgsubversion/replay.py +++ b/hgsubversion/replay.py @@ -26,33 +26,7 @@ def convert_rev(ui, meta, svn, r, tbdelt hg_editor.current.rev = r meta.save_tbdelta(tbdelta) # needed by get_replay() svn.get_replay(r.revnum, meta.editor) - i = 1 - if 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: - meta.ui.note('.') - meta.ui.flush() - if p[-1] == '/': - dirpath = p[len(rootpath):] - files_to_grab.update([dirpath + f for f,k in - svn.list_files(dirpath, r.revnum) - if k == 'f']) - else: - files_to_grab.add(p[len(rootpath):]) - meta.ui.note('\nFetching files...\n') - for p in files_to_grab: - 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.current.set(p, data, 'x' in mode, 'l' in mode) - hg_editor.current.missing = set() - meta.ui.note('\n') + hg_editor.current.findmissing(svn) _updateexternals(meta, hg_editor.current) return commit_current_delta(meta, tbdelta, hg_editor.current)