Mercurial > hgsubversion
comparison hg_delta_editor.py @ 225:2117cb0118fe
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 | 2165461d2dd8 |
children | bb2b78f9f4ce |
comparison
equal
deleted
inserted
replaced
224:2165461d2dd8 | 225:2117cb0118fe |
---|---|
56 f = open(self.revmap_file, 'a') | 56 f = open(self.revmap_file, 'a') |
57 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n') | 57 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n') |
58 f.flush() | 58 f.flush() |
59 f.close() | 59 f.close() |
60 self.revmap[revnum, branch] = node_hash | 60 self.revmap[revnum, branch] = node_hash |
61 | |
62 def last_known_revision(self): | |
63 ''' Obtain the highest numbered -- i.e. latest -- revision known. | |
64 | |
65 Currently, this function just iterates over the entire revision map | |
66 using the max() builtin. This may be slow for extremely large | |
67 repositories, but for now, it's fast enough. | |
68 ''' | |
69 try: | |
70 return max(k[0] for k in self.revmap.iterkeys()) | |
71 except ValueError: | |
72 return 0 | |
61 | 73 |
62 def __init__(self, path=None, repo=None, ui_=None, | 74 def __init__(self, path=None, repo=None, ui_=None, |
63 subdir='', author_host='', | 75 subdir='', author_host='', |
64 tag_locations=['tags'], | 76 tag_locations=['tags'], |
65 authors=None, | 77 authors=None, |
129 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): | 141 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): |
130 self.repo = hg.repository(self.ui, repo_path) | 142 self.repo = hg.repository(self.ui, repo_path) |
131 assert os.path.isfile(self.revmap_file) | 143 assert os.path.isfile(self.revmap_file) |
132 assert os.path.isfile(self.svn_url_file) | 144 assert os.path.isfile(self.svn_url_file) |
133 assert os.path.isfile(self.uuid_file) | 145 assert os.path.isfile(self.uuid_file) |
134 assert os.path.isfile(self.last_revision_handled_file) | |
135 else: | 146 else: |
136 self.repo = hg.repository(self.ui, repo_path, create=True) | 147 self.repo = hg.repository(self.ui, repo_path, create=True) |
137 os.makedirs(os.path.dirname(self.uuid_file)) | 148 os.makedirs(os.path.dirname(self.uuid_file)) |
138 f = open(self.revmap_file, 'w') | 149 f = open(self.revmap_file, 'w') |
139 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) | 150 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) |
761 | 772 |
762 def uuid_file(self): | 773 def uuid_file(self): |
763 return self.meta_file_named('uuid') | 774 return self.meta_file_named('uuid') |
764 uuid_file = property(uuid_file) | 775 uuid_file = property(uuid_file) |
765 | 776 |
766 def last_revision_handled_file(self): | |
767 return self.meta_file_named('last_rev') | |
768 last_revision_handled_file = property(last_revision_handled_file) | |
769 | |
770 def branch_info_file(self): | 777 def branch_info_file(self): |
771 return self.meta_file_named('branch_info') | 778 return self.meta_file_named('branch_info') |
772 branch_info_file = property(branch_info_file) | 779 branch_info_file = property(branch_info_file) |
773 | 780 |
774 def tag_info_file(self): | 781 def tag_info_file(self): |