##// END OF EJS Templates
convert: (svn) simplify _find_children
Brendan Cully -
r5050:2bd996d0 default
parent child Browse files
Show More
@@ -46,8 +46,6 b' def geturl(path):'
46 return 'file://%s' % os.path.normpath(os.path.abspath(path))
46 return 'file://%s' % os.path.normpath(os.path.abspath(path))
47 return path
47 return path
48
48
49 class CompatibilityException(Exception): pass
50
51 class changedpath(object):
49 class changedpath(object):
52 def __init__(self, p):
50 def __init__(self, p):
53 self.copyfrom_path = p.copyfrom_path
51 self.copyfrom_path = p.copyfrom_path
@@ -626,52 +624,9 b' class convert_svn(converter_source):'
626 return data, mode
624 return data, mode
627
625
628 def _find_children(self, path, revnum):
626 def _find_children(self, path, revnum):
629 path = path.strip("/")
630
631 def _find_children_fallback(path, revnum):
632 # SWIG python bindings for getdir are broken up to at least 1.4.3
633 pool = Pool()
634 optrev = svn.core.svn_opt_revision_t()
635 optrev.kind = svn.core.svn_opt_revision_number
636 optrev.value.number = revnum
637 rpath = '/'.join([self.base, path]).strip('/')
638 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev, True, self.ctx, pool).keys()]
639
640 if hasattr(self, '_find_children_fallback'):
641 return _find_children_fallback(path, revnum)
642
643 self.reparent("/" + path)
644 pool = Pool()
627 pool = Pool()
645
628 optrev = svn.core.svn_opt_revision_t()
646 children = []
629 optrev.kind = svn.core.svn_opt_revision_number
647 def find_children_inner(children, path, revnum = revnum):
630 optrev.value.number = revnum
648 if hasattr(svn.ra, 'get_dir2'): # Since SVN 1.4
631 rpath = '/'.join([self.base, path.strip('/')]).strip('/')
649 fields = 0xffffffff # Binding does not provide SVN_DIRENT_ALL
632 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev, True, self.ctx, pool).keys()]
650 getdir = svn.ra.get_dir2(self.ra, path, revnum, fields, pool)
651 else:
652 getdir = svn.ra.get_dir(self.ra, path, revnum, pool)
653 if type(getdir) == dict:
654 # python binding for getdir is broken up to at least 1.4.3
655 raise CompatibilityException()
656 dirents = getdir[0]
657 if type(dirents) == int:
658 # got here once due to infinite recursion bug
659 return
660 c = dirents.keys()
661 c.sort()
662 for child in c:
663 dirent = dirents[child]
664 if dirent.kind == svn.core.svn_node_dir:
665 find_children_inner(children, (path + "/" + child).strip("/"))
666 else:
667 children.append((path + "/" + child).strip("/"))
668
669 try:
670 find_children_inner(children, "")
671 except CompatibilityException:
672 self._find_children_fallback = True
673 self.reparent(self.module)
674 return _find_children_fallback(path, revnum)
675
676 self.reparent(self.module)
677 return [path + "/" + c for c in children]
General Comments 0
You need to be logged in to leave comments. Login now