Mercurial > hgsubversion
comparison 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 |
comparison
equal
deleted
inserted
replaced
295:aacc8cf83e13 | 296:9be04de434ed |
---|---|
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, |
132 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): | 144 if os.path.isdir(repo_path) and len(os.listdir(repo_path)): |
133 self.repo = hg.repository(self.ui, repo_path) | 145 self.repo = hg.repository(self.ui, repo_path) |
134 assert os.path.isfile(self.revmap_file) | 146 assert os.path.isfile(self.revmap_file) |
135 assert os.path.isfile(self.svn_url_file) | 147 assert os.path.isfile(self.svn_url_file) |
136 assert os.path.isfile(self.uuid_file) | 148 assert os.path.isfile(self.uuid_file) |
137 assert os.path.isfile(self.last_revision_handled_file) | |
138 else: | 149 else: |
139 self.repo = hg.repository(self.ui, repo_path, create=True) | 150 self.repo = hg.repository(self.ui, repo_path, create=True) |
140 os.makedirs(os.path.dirname(self.uuid_file)) | 151 os.makedirs(os.path.dirname(self.uuid_file)) |
141 f = open(self.revmap_file, 'w') | 152 f = open(self.revmap_file, 'w') |
142 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) | 153 f.write('%s\n' % our_util.REVMAP_FILE_VERSION) |
764 | 775 |
765 def uuid_file(self): | 776 def uuid_file(self): |
766 return self.meta_file_named('uuid') | 777 return self.meta_file_named('uuid') |
767 uuid_file = property(uuid_file) | 778 uuid_file = property(uuid_file) |
768 | 779 |
769 def last_revision_handled_file(self): | |
770 return self.meta_file_named('last_rev') | |
771 last_revision_handled_file = property(last_revision_handled_file) | |
772 | |
773 def branch_info_file(self): | 780 def branch_info_file(self): |
774 return self.meta_file_named('branch_info') | 781 return self.meta_file_named('branch_info') |
775 branch_info_file = property(branch_info_file) | 782 branch_info_file = property(branch_info_file) |
776 | 783 |
777 def tag_info_file(self): | 784 def tag_info_file(self): |