Mercurial > hgsubversion
diff hg_delta_editor.py @ 296:9be04de434ed
Get rid of .hg/svn/last_rev:
We now calculate the last known revision by iterating over all known
revisions and finding the highest number. Theoretically, we might be
able to simply read the latest entry, but in practice, that's a bug
waiting to happen. For instance, we might want to achieve
compatibility with '.hg/shamap' as generated by the
ConvertExtension, and it not only cannot offer a guarantee of
linearity, but it also allows more than one conversion to source exists.
I'd say we have other problems to care about until this turns up as a
hotspot in profiling. Such as why we leak circa 100MB of memory per
1000 revisions converted ;)
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 27 Mar 2009 01:09:36 +0100 |
parents | aacc8cf83e13 |
children | 3e27514d575c |
line wrap: on
line diff
--- a/hg_delta_editor.py +++ b/hg_delta_editor.py @@ -59,6 +59,18 @@ class HgChangeReceiver(delta.Editor): f.close() self.revmap[revnum, branch] = node_hash + def last_known_revision(self): + ''' Obtain the highest numbered -- i.e. latest -- revision known. + + Currently, this function just iterates over the entire revision map + using the max() builtin. This may be slow for extremely large + repositories, but for now, it's fast enough. + ''' + try: + return max(k[0] for k in self.revmap.iterkeys()) + except ValueError: + return 0 + def __init__(self, path=None, repo=None, ui_=None, subdir='', author_host='', tag_locations=['tags'], @@ -134,7 +146,6 @@ class HgChangeReceiver(delta.Editor): assert os.path.isfile(self.revmap_file) assert os.path.isfile(self.svn_url_file) assert os.path.isfile(self.uuid_file) - assert os.path.isfile(self.last_revision_handled_file) else: self.repo = hg.repository(self.ui, repo_path, create=True) os.makedirs(os.path.dirname(self.uuid_file)) @@ -766,10 +777,6 @@ class HgChangeReceiver(delta.Editor): return self.meta_file_named('uuid') uuid_file = property(uuid_file) - def last_revision_handled_file(self): - return self.meta_file_named('last_rev') - last_revision_handled_file = property(last_revision_handled_file) - def branch_info_file(self): return self.meta_file_named('branch_info') branch_info_file = property(branch_info_file)