##// END OF EJS Templates
convert: rename get_entry_from_path() into an svn_source method
Patrick Mezard -
r6539:7814d7bb default
parent child Browse files
Show More
@@ -537,24 +537,6 b' class svn_source(converter_source):'
537 svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
537 svn.ra.reparent(self.ra, svn_url.encode(self.encoding))
538
538
539 def expandpaths(self, rev, paths, parents):
539 def expandpaths(self, rev, paths, parents):
540 def get_entry_from_path(path, module=self.module):
541 # Given the repository url of this wc, say
542 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch"
543 # extract the "entry" portion (a relative path) from what
544 # svn log --xml says, ie
545 # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py"
546 # that is to say "tests/PloneTestCase.py"
547 if path.startswith(module):
548 relative = path.rstrip('/')[len(module):]
549 if relative.startswith('/'):
550 return relative[1:]
551 elif relative == '':
552 return relative
553
554 # The path is outside our tracked tree...
555 self.ui.debug('%r is not under %r, ignoring\n' % (path, module))
556 return None
557
558 entries = []
540 entries = []
559 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions.
541 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions.
560 copies = {}
542 copies = {}
@@ -565,13 +547,13 b' class svn_source(converter_source):'
565 self.reparent(self.module)
547 self.reparent(self.module)
566
548
567 for path, ent in paths:
549 for path, ent in paths:
568 entrypath = get_entry_from_path(path, module=self.module)
550 entrypath = self.getrelpath(path)
569 entry = entrypath.decode(self.encoding)
551 entry = entrypath.decode(self.encoding)
570
552
571 kind = svn.ra.check_path(self.ra, entrypath, revnum)
553 kind = svn.ra.check_path(self.ra, entrypath, revnum)
572 if kind == svn.core.svn_node_file:
554 if kind == svn.core.svn_node_file:
573 if ent.copyfrom_path:
555 if ent.copyfrom_path:
574 copyfrom_path = get_entry_from_path(ent.copyfrom_path)
556 copyfrom_path = self.getrelpath(ent.copyfrom_path)
575 if copyfrom_path:
557 if copyfrom_path:
576 self.ui.debug("Copied to %s from %s@%s\n" %
558 self.ui.debug("Copied to %s from %s@%s\n" %
577 (entrypath, copyfrom_path,
559 (entrypath, copyfrom_path,
@@ -592,8 +574,8 b' class svn_source(converter_source):'
592 # a root revision.
574 # a root revision.
593 uuid, old_module, fromrev = self.revsplit(parents[0])
575 uuid, old_module, fromrev = self.revsplit(parents[0])
594
576
595 basepath = old_module + "/" + get_entry_from_path(path, module=self.module)
577 basepath = old_module + "/" + self.getrelpath(path)
596 entrypath = old_module + "/" + get_entry_from_path(path, module=self.module)
578 entrypath = basepath
597
579
598 def lookup_parts(p):
580 def lookup_parts(p):
599 rc = None
581 rc = None
@@ -649,7 +631,7 b' class svn_source(converter_source):'
649 # parent in the same commit? (probably can). Could
631 # parent in the same commit? (probably can). Could
650 # cause problems if instead of revnum -1,
632 # cause problems if instead of revnum -1,
651 # we have to look in (copyfrom_path, revnum - 1)
633 # we have to look in (copyfrom_path, revnum - 1)
652 entrypath = get_entry_from_path("/" + child, module=old_module)
634 entrypath = self.getrelpath("/" + child, module=old_module)
653 if entrypath:
635 if entrypath:
654 entry = self.recode(entrypath.decode(self.encoding))
636 entry = self.recode(entrypath.decode(self.encoding))
655 if entry in copies:
637 if entry in copies:
@@ -682,7 +664,7 b' class svn_source(converter_source):'
682 # parent in the same commit? (probably can). Could
664 # parent in the same commit? (probably can). Could
683 # cause problems if instead of revnum -1,
665 # cause problems if instead of revnum -1,
684 # we have to look in (copyfrom_path, revnum - 1)
666 # we have to look in (copyfrom_path, revnum - 1)
685 entrypath = get_entry_from_path("/" + child, module=self.module)
667 entrypath = self.getrelpath("/" + child)
686 # print child, self.module, entrypath
668 # print child, self.module, entrypath
687 if entrypath:
669 if entrypath:
688 # Need to filter out directories here...
670 # Need to filter out directories here...
@@ -693,20 +675,9 b' class svn_source(converter_source):'
693 # Copies here (must copy all from source)
675 # Copies here (must copy all from source)
694 # Probably not a real problem for us if
676 # Probably not a real problem for us if
695 # source does not exist
677 # source does not exist
696
697 # Can do this with the copy command "hg copy"
698 # if ent.copyfrom_path:
699 # copyfrom_entry = get_entry_from_path(ent.copyfrom_path.decode(self.encoding),
700 # module=self.module)
701 # copyto_entry = entrypath
702 #
703 # print "copy directory", copyfrom_entry, 'to', copyto_entry
704 #
705 # copies.append((copyfrom_entry, copyto_entry))
706
707 if ent.copyfrom_path:
678 if ent.copyfrom_path:
708 copyfrom_path = ent.copyfrom_path.decode(self.encoding)
679 copyfrom_path = ent.copyfrom_path.decode(self.encoding)
709 copyfrom_entry = get_entry_from_path(copyfrom_path, module=self.module)
680 copyfrom_entry = self.getrelpath(copyfrom_path)
710 if copyfrom_entry:
681 if copyfrom_entry:
711 copyfrom[path] = ent
682 copyfrom[path] = ent
712 self.ui.debug("mark %s came from %s\n" % (path, copyfrom[path]))
683 self.ui.debug("mark %s came from %s\n" % (path, copyfrom[path]))
@@ -717,12 +688,12 b' class svn_source(converter_source):'
717 children = self._find_children(self.recode(copyfrom_path), ent.copyfrom_rev)
688 children = self._find_children(self.recode(copyfrom_path), ent.copyfrom_rev)
718 children.sort()
689 children.sort()
719 for child in children:
690 for child in children:
720 entrypath = get_entry_from_path("/" + child, module=self.module)
691 entrypath = self.getrelpath("/" + child)
721 if entrypath:
692 if entrypath:
722 entry = entrypath.decode(self.encoding)
693 entry = entrypath.decode(self.encoding)
723 # print "COPY COPY From", copyfrom_entry, entry
694 # print "COPY COPY From", copyfrom_entry, entry
724 copyto_path = path + entry[len(copyfrom_entry):]
695 copyto_path = path + entry[len(copyfrom_entry):]
725 copyto_entry = get_entry_from_path(copyto_path, module=self.module)
696 copyto_entry = self.getrelpath(copyto_path)
726 # print "COPY", entry, "COPY To", copyto_entry
697 # print "COPY", entry, "COPY To", copyto_entry
727 copies[self.recode(copyto_entry)] = self.recode(entry)
698 copies[self.recode(copyto_entry)] = self.recode(entry)
728 # copy from quux splort/quuxfile
699 # copy from quux splort/quuxfile
@@ -887,6 +858,26 b' class svn_source(converter_source):'
887 rpath = '/'.join([self.base, path]).strip('/')
858 rpath = '/'.join([self.base, path]).strip('/')
888 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
859 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()]
889
860
861 def getrelpath(self, path, module=None):
862 if module is None:
863 module = self.module
864 # Given the repository url of this wc, say
865 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch"
866 # extract the "entry" portion (a relative path) from what
867 # svn log --xml says, ie
868 # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py"
869 # that is to say "tests/PloneTestCase.py"
870 if path.startswith(module):
871 relative = path.rstrip('/')[len(module):]
872 if relative.startswith('/'):
873 return relative[1:]
874 elif relative == '':
875 return relative
876
877 # The path is outside our tracked tree...
878 self.ui.debug('%r is not under %r, ignoring\n' % (path, module))
879 return None
880
890 pre_revprop_change = '''#!/bin/sh
881 pre_revprop_change = '''#!/bin/sh
891
882
892 REPOS="$1"
883 REPOS="$1"
General Comments 0
You need to be logged in to leave comments. Login now