comparison hg_delta_editor.py @ 306:e6853c7fa3af

hg_delta_editor: fix _split_tag_path to actually work as intended. I don't remember why I wrote this function, but it might be useful. This changeset passes all tests, although I couldn't remember how to run the comprehensive test suite.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 01 May 2009 13:25:57 +0200
parents ce676eff002b
children 1d48d9a34c19
comparison
equal deleted inserted replaced
305:97360cb777a8 306:e6853c7fa3af
397 Note that it's only a tag if it was copied from the path '' in a branch (or tag) 397 Note that it's only a tag if it was copied from the path '' in a branch (or tag)
398 we have, for our purposes. 398 we have, for our purposes.
399 399
400 Otherwise, returns False. 400 Otherwise, returns False.
401 """ 401 """
402 return self._split_tag_path(path)[-1] or False 402 return self._split_tag_path(path)[1] or False
403 403
404 def _split_tag_path(self, path): 404 def _split_tag_path(self, path):
405 r = (None, None, None) 405 """Figure out which tag inside our repo this path represents, and
406 also figure out which path inside that tag it is.
407
408 Returns a tuple of (path within tag, tag name, server-side tag
409 path).
410 """
406 path = self._normalize_path(path) 411 path = self._normalize_path(path)
407 for tags_path in self.tag_locations: 412 for tags_path in self.tag_locations:
408 if path and (path.startswith(tags_path) and 413 if path and (path.startswith(tags_path) and
409 len(path) > len('%s/' % tags_path)): 414 len(path) > len('%s/' % tags_path)):
410 return path[len(tags_path)+1:] 415 tag, _, subpath = path[len(tags_path)+1:].partition('/')
411 return False 416 return (subpath, tag, '%s/%s' % (tags_path, tag))
417 return (None, None, None)
412 418
413 def get_parent_svn_branch_and_rev(self, number, branch): 419 def get_parent_svn_branch_and_rev(self, number, branch):
414 number -= 1 420 number -= 1
415 if (number, branch) in self.revmap: 421 if (number, branch) in self.revmap:
416 return number, branch 422 return number, branch