comparison hg_delta_editor.py @ 313:942f198b8ff5

hg_delta_editor: detect new branches issued from non-branch directories This fix solves the following case: let's /dumb/layout/project be an existing project. To normalize the trunk/branches/tags layout, people may do: $ mkdir /project $ mv /dumb/layout/project /project/project # Oups, should have been trunk! $ mv /project/project /project/trunk trunk creation was ignore because: - update_branch_map() sees it come from a non-branch copy source and ignores it (case #3). - since it is not in self.branches, add_directory() ignores the non-existing path. Then trunk is left uninitialized. To solve this, we allow update_branch_map() to detect branches copied from non-canonical locations.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 03 May 2009 21:42:42 -0500
parents 4dc197f533c1
children 2257bfc01749
comparison
equal deleted inserted replaced
312:4dc197f533c1 313:942f198b8ff5
295 test += '/%s' % path_comps.pop(0) 295 test += '/%s' % path_comps.pop(0)
296 if self._localname(test) in self.branches: 296 if self._localname(test) in self.branches:
297 return path[len(test)+1:], self._localname(test), test 297 return path[len(test)+1:], self._localname(test), test
298 if existing: 298 if existing:
299 return None, None, None 299 return None, None, None
300 if path.startswith('trunk/'): 300 if path == 'trunk' or path.startswith('trunk/'):
301 path = test.split('/')[1:] 301 path = path.split('/')[1:]
302 test = 'trunk' 302 test = 'trunk'
303 elif path.startswith('branches/'): 303 elif path.startswith('branches/'):
304 elts = path.split('/') 304 elts = path.split('/')
305 test = '/'.join(elts[:2]) 305 test = '/'.join(elts[:2])
306 path = '/'.join(elts[2:]) 306 path = '/'.join(elts[2:])
495 # this function). This is determined by the following 495 # this function). This is determined by the following
496 # checks: 496 # checks:
497 # 1. Is the file located inside any currently known 497 # 1. Is the file located inside any currently known
498 # branch? If yes, then we're done with it, this isn't 498 # branch? If yes, then we're done with it, this isn't
499 # interesting. 499 # interesting.
500 # 2. Does the file have copyfrom information that means it 500 # 2. Does the file have copyfrom information? If yes, then
501 # is a copy from the root of some other branch? If 501 # we're done: this is a new branch, and we record the
502 # yes, then we're done: this is a new branch, and we 502 # copyfrom in added_branches if it comes from the root
503 # record the copyfrom in added_branches 503 # of another branch, or create it from scratch.
504 # 3. Neither of the above. This could be a branch, but it 504 # 3. Neither of the above. This could be a branch, but it
505 # might never work out for us. It's only ever a branch 505 # might never work out for us. It's only ever a branch
506 # (as far as we're concerned) if it gets committed to, 506 # (as far as we're concerned) if it gets committed to,
507 # which we have to detect at file-write time anyway. So 507 # which we have to detect at file-write time anyway. So
508 # we do nothing here. 508 # we do nothing here.
527 for known in self.branches: 527 for known in self.branches:
528 if self._svnpath(known).startswith(p): 528 if self._svnpath(known).startswith(p):
529 self.branches_to_delete.add(known) # case 5 529 self.branches_to_delete.add(known) # case 5
530 parent = self._determine_parent_branch( 530 parent = self._determine_parent_branch(
531 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum) 531 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum)
532 if not parent and paths[p].copyfrom_path:
533 bpath, branch = self._path_and_branch_for_path(p, False)
534 if bpath is not None and branch not in self.branches:
535 parent = {branch: (None, 0, revision.revnum)}
532 added_branches.update(parent) 536 added_branches.update(parent)
533 for t in tags_to_delete: 537 for t in tags_to_delete:
534 del self.tags[t] 538 del self.tags[t]
535 for br in self.branches_to_delete: 539 for br in self.branches_to_delete:
536 del self.branches[br] 540 del self.branches[br]