Mercurial > hgsubversion
comparison hg_delta_editor.py @ 300:4aba7542f6a9
Various cleanups, cosmetics and removal of superfluous assertions.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 27 Mar 2009 03:16:21 +0100 |
parents | 3e27514d575c |
children | ce676eff002b |
comparison
equal
deleted
inserted
replaced
299:3e27514d575c | 300:4aba7542f6a9 |
---|---|
242 return branches | 242 return branches |
243 | 243 |
244 def _path_and_branch_for_path(self, path, existing=True): | 244 def _path_and_branch_for_path(self, path, existing=True): |
245 return self._split_branch_path(path, existing=existing)[:2] | 245 return self._split_branch_path(path, existing=existing)[:2] |
246 | 246 |
247 def _branch_for_path(self, path, existing=True): | |
248 return self._path_and_branch_for_path(path, existing=existing)[1] | |
249 | |
247 def _localname(self, path): | 250 def _localname(self, path): |
248 """Compute the local name for a branch located at path. | 251 """Compute the local name for a branch located at path. |
249 """ | 252 """ |
250 assert not path.startswith('tags/') | |
251 if path == 'trunk': | 253 if path == 'trunk': |
252 return None | 254 return None |
253 elif path.startswith('branches/'): | 255 elif path.startswith('branches/'): |
254 return path[len('branches/'):] | 256 return path[len('branches/'):] |
255 return '../%s' % path | 257 return '../%s' % path |
270 If existing=True, will return None, None, None if the file isn't on some known | 272 If existing=True, will return None, None, None if the file isn't on some known |
271 branch. If existing=False, then it will guess what the branch would be if it were | 273 branch. If existing=False, then it will guess what the branch would be if it were |
272 known. | 274 known. |
273 """ | 275 """ |
274 path = self._normalize_path(path) | 276 path = self._normalize_path(path) |
275 if path.startswith('tags/'): | |
276 return None, None, None | |
277 test = '' | 277 test = '' |
278 path_comps = path.split('/') | 278 path_comps = path.split('/') |
279 while self._localname(test) not in self.branches and len(path_comps): | 279 while self._localname(test) not in self.branches and len(path_comps): |
280 if not test: | 280 if not test: |
281 test = path_comps.pop(0) | 281 test = path_comps.pop(0) |
370 Note that it's only a tag if it was copied from the path '' in a branch (or tag) | 370 Note that it's only a tag if it was copied from the path '' in a branch (or tag) |
371 we have, for our purposes. | 371 we have, for our purposes. |
372 | 372 |
373 Otherwise, returns False. | 373 Otherwise, returns False. |
374 """ | 374 """ |
375 return self._split_tag_path(path)[-1] or False | |
376 | |
377 def _split_tag_path(self, path): | |
378 r = (None, None, None) | |
375 path = self._normalize_path(path) | 379 path = self._normalize_path(path) |
376 for tags_path in self.tag_locations: | 380 for tags_path in self.tag_locations: |
377 if path and (path.startswith(tags_path) and | 381 if path and (path.startswith(tags_path) and |
378 len(path) > len('%s/' % tags_path)): | 382 len(path) > len('%s/' % tags_path)): |
379 return path[len(tags_path)+1:] | 383 return path[len(tags_path)+1:] |
883 if f in files: | 887 if f in files: |
884 return False | 888 return False |
885 # parentctx is not an ancestor of childctx, files are unrelated | 889 # parentctx is not an ancestor of childctx, files are unrelated |
886 return False | 890 return False |
887 | 891 |
888 def add_file(self, path, parent_baton, copyfrom_path, | 892 def add_file(self, path, parent_baton=None, copyfrom_path=None, |
889 copyfrom_revision, file_pool=None): | 893 copyfrom_revision=None, file_pool=None): |
890 self.current_file = 'foobaz' | 894 self.current_file = 'foobaz' |
891 self.base_revision = None | 895 self.base_revision = None |
892 if path in self.deleted_files: | 896 if path in self.deleted_files: |
893 del self.deleted_files[path] | 897 del self.deleted_files[path] |
894 fpath, branch = self._path_and_branch_for_path(path, existing=False) | 898 fpath, branch = self._path_and_branch_for_path(path, existing=False) |