comparison hg_delta_editor.py @ 312:4dc197f533c1

hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
author Patrick Mezard <pmezard@gmail.com>
date Sun, 03 May 2009 21:42:41 -0500
parents 153266401676
children 942f198b8ff5
comparison
equal deleted inserted replaced
311:b6a9cdee2f68 312:4dc197f533c1
446 return 'trunk' 446 return 'trunk'
447 elif branch.startswith('../'): 447 elif branch.startswith('../'):
448 return branch[3:] 448 return branch[3:]
449 return 'branches/%s' % branch 449 return 'branches/%s' % branch
450 450
451 def __determine_parent_branch(self, p, src_path, src_rev, revnum): 451 def _determine_parent_branch(self, p, src_path, src_rev, revnum):
452 if src_path is not None: 452 if src_path is not None:
453 src_file, src_branch = self._path_and_branch_for_path(src_path) 453 src_file, src_branch = self._path_and_branch_for_path(src_path)
454 src_tag = self._is_path_tag(src_path) 454 src_tag = self._is_path_tag(src_path)
455 if src_tag != False: 455 if src_tag != False:
456 # also case 2 456 # also case 2
488 added_tags[t_name] = branch, src_rev 488 added_tags[t_name] = branch, src_rev
489 elif (paths[p].action == 'D' and p.endswith(t_name) 489 elif (paths[p].action == 'D' and p.endswith(t_name)
490 and t_name in self.tags): 490 and t_name in self.tags):
491 tags_to_delete.add(t_name) 491 tags_to_delete.add(t_name)
492 continue 492 continue
493 # At this point we know the path is not a tag. In that case, we only care if it 493 # At this point we know the path is not a tag. In that
494 # is the root of a new branch (in this function). This is determined by the 494 # case, we only care if it is the root of a new branch (in
495 # following checks: 495 # this function). This is determined by the following
496 # 1. Is the file located inside any currently known branch? 496 # checks:
497 # If yes, then we're done with it, this isn't interesting. 497 # 1. Is the file located inside any currently known
498 # 2. Does the file have copyfrom information that means it is a copy from the root 498 # branch? If yes, then we're done with it, this isn't
499 # of some other branch? 499 # interesting.
500 # If yes, then we're done: this is a new branch, and we record the copyfrom in 500 # 2. Does the file have copyfrom information that means it
501 # added_branches 501 # is a copy from the root of some other branch? If
502 # 3. Neither of the above. This could be a branch, but it might never work out for 502 # yes, then we're done: this is a new branch, and we
503 # us. It's only ever a branch (as far as we're concerned) if it gets committed 503 # record the copyfrom in added_branches
504 # to, which we have to detect at file-write time anyway. So we do nothing here. 504 # 3. Neither of the above. This could be a branch, but it
505 # 4. It's the root of an already-known branch, with an action of 'D'. We mark the 505 # might never work out for us. It's only ever a branch
506 # branch as deleted. 506 # (as far as we're concerned) if it gets committed to,
507 # 5. It's the parent directory of one or more already-known branches, so we mark them 507 # which we have to detect at file-write time anyway. So
508 # as deleted. 508 # we do nothing here.
509 # 6. It's a branch being replaced by another branch - the action will be 'R'. 509 # 4. It's the root of an already-known branch, with an
510 # action of 'D'. We mark the branch as deleted.
511 # 5. It's the parent directory of one or more
512 # already-known branches, so we mark them as deleted.
513 # 6. It's a branch being replaced by another branch - the
514 # action will be 'R'.
510 fi, br = self._path_and_branch_for_path(p) 515 fi, br = self._path_and_branch_for_path(p)
511 if fi is not None: 516 if fi is not None:
512 if fi == '': 517 if fi == '':
513 if paths[p].action == 'D': 518 if paths[p].action == 'D':
514 self.branches_to_delete.add(br) # case 4 519 self.branches_to_delete.add(br) # case 4
515 elif paths[p].action == 'R': 520 elif paths[p].action == 'R':
516 added_branches.update(self.__determine_parent_branch(p, paths[p].copyfrom_path, 521 parent = self._determine_parent_branch(
517 paths[p].copyfrom_rev, 522 p, paths[p].copyfrom_path, paths[p].copyfrom_rev,
518 revision.revnum)) 523 revision.revnum)
524 added_branches.update(parent)
519 continue # case 1 525 continue # case 1
520 if paths[p].action == 'D': 526 if paths[p].action == 'D':
521 # check for case 5
522 for known in self.branches: 527 for known in self.branches:
523 if self._svnpath(known).startswith(p): 528 if self._svnpath(known).startswith(p):
524 self.branches_to_delete.add(known) # case 5 529 self.branches_to_delete.add(known) # case 5
525 added_branches.update(self.__determine_parent_branch(p, paths[p].copyfrom_path, 530 parent = self._determine_parent_branch(
526 paths[p].copyfrom_rev, revision.revnum)) 531 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum)
532 added_branches.update(parent)
527 for t in tags_to_delete: 533 for t in tags_to_delete:
528 del self.tags[t] 534 del self.tags[t]
529 for br in self.branches_to_delete: 535 for br in self.branches_to_delete:
530 del self.branches[br] 536 del self.branches[br]
531 for t, info in added_tags.items(): 537 for t, info in added_tags.items():