comparison hgext/convert/subversion.py @ 8884:8b603c7c808e

convert/svn: remove dead code from entry deletion code path It was made obsolete when multi-branches commit were split into multiple Mercurial commits.
author Patrick Mezard <pmezard@gmail.com>
date Sun, 21 Jun 2009 23:04:02 +0200
parents ede2247e61aa
children 2c184bd2b37a
comparison
equal deleted inserted replaced
8883:ede2247e61aa 8884:8b603c7c808e
642 self.ui.debug(_("copied to %s from %s@%s\n") % 642 self.ui.debug(_("copied to %s from %s@%s\n") %
643 (entrypath, copyfrom_path, ent.copyfrom_rev)) 643 (entrypath, copyfrom_path, ent.copyfrom_rev))
644 copies[self.recode(entry)] = self.recode(copyfrom_path) 644 copies[self.recode(entry)] = self.recode(copyfrom_path)
645 elif kind == 0: # gone, but had better be a deleted *file* 645 elif kind == 0: # gone, but had better be a deleted *file*
646 self.ui.debug(_("gone from %s\n") % ent.copyfrom_rev) 646 self.ui.debug(_("gone from %s\n") % ent.copyfrom_rev)
647 647 pmodule, prevnum = self.revsplit(parents[0])[1:]
648 # if a branch is created but entries are removed in 648 parentpath = pmodule + "/" + entrypath
649 # the same changeset, get the right fromrev 649 self.ui.debug(_("entry %s\n") % parentpath)
650 # parents cannot be empty here, you cannot remove
651 # things from a root revision.
652 uuid, old_module, fromrev = self.revsplit(parents[0])
653
654 basepath = old_module + "/" + self.getrelpath(path)
655 entrypath = basepath
656
657 def lookup_parts(p):
658 rc = None
659 parts = p.split("/")
660 for i in range(len(parts)):
661 part = "/".join(parts[:i])
662 info = part, copyfrom.get(part, None)
663 if info[1] is not None:
664 self.ui.debug(_("found parent directory %s\n") % info[1])
665 rc = info
666 return rc
667
668 self.ui.debug(_("base, entry %s %s\n") % (basepath, entrypath))
669
670 frompath, froment = lookup_parts(entrypath) or (None, revnum - 1)
671
672 # need to remove fragment from lookup_parts and
673 # replace with copyfrom_path
674 if frompath is not None:
675 self.ui.debug(_("munge-o-matic\n"))
676 self.ui.debug(entrypath + '\n')
677 self.ui.debug(entrypath[len(frompath):] + '\n')
678 entrypath = froment.copyfrom_path + entrypath[len(frompath):]
679 fromrev = froment.copyfrom_rev
680 self.ui.debug(_("info: %s %s %s %s\n") % (frompath, froment, ent, entrypath))
681 650
682 # We can avoid the reparent calls if the module has 651 # We can avoid the reparent calls if the module has
683 # not changed but it probably does not worth the pain. 652 # not changed but it probably does not worth the pain.
684 prevmodule = self.reparent('') 653 prevmodule = self.reparent('')
685 fromkind = svn.ra.check_path(self.ra, entrypath.strip('/'), fromrev) 654 fromkind = svn.ra.check_path(self.ra, parentpath.strip('/'), prevnum)
686 self.reparent(prevmodule) 655 self.reparent(prevmodule)
687 656
688 if fromkind == svn.core.svn_node_file: 657 if fromkind == svn.core.svn_node_file:
689 entries.append(self.recode(entry)) 658 entries.append(self.recode(entry))
690 elif fromkind == svn.core.svn_node_dir: 659 elif fromkind == svn.core.svn_node_dir:
691 # Sometimes this is tricky. For example: in The
692 # Subversion Repository revision 6940 a dir was
693 # copied and one of its files was deleted from the
694 # new location in the same commit. This code can't
695 # deal with that yet.
696 if ent.action == 'C': 660 if ent.action == 'C':
697 children = self._find_children(path, fromrev) 661 children = self._find_children(path, prevnum)
698 else: 662 else:
699 oroot = entrypath.strip('/') 663 oroot = parentpath.strip('/')
700 nroot = path.strip('/') 664 nroot = path.strip('/')
701 children = self._find_children(oroot, fromrev) 665 children = self._find_children(oroot, prevnum)
702 children = [s.replace(oroot,nroot) for s in children] 666 children = [s.replace(oroot,nroot) for s in children]
703 667
704 for child in children: 668 for child in children:
705 entrypath = self.getrelpath("/" + child, old_module) 669 childpath = self.getrelpath("/" + child, pmodule)
706 if not entrypath: 670 if not childpath:
707 continue 671 continue
708 if entrypath in copies: 672 if childpath in copies:
709 del copies[entrypath] 673 del copies[childpath]
710 entries.append(entrypath) 674 entries.append(childpath)
711 else: 675 else:
712 self.ui.debug(_('unknown path in revision %d: %s\n') % \ 676 self.ui.debug(_('unknown path in revision %d: %s\n') % \
713 (revnum, path)) 677 (revnum, path))
714 elif kind == svn.core.svn_node_dir: 678 elif kind == svn.core.svn_node_dir:
715 # If the directory just had a prop change, 679 # If the directory just had a prop change,