comparison hgext/convert/subversion.py @ 6762:f67d1468ac50

util: add sort helper
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Jun 2008 18:28:45 -0500
parents c9b8d2565b92
children 1a9577da9d02
comparison
equal deleted inserted replaced
6761:cb981fc955fb 6762:f67d1468ac50
656 # whether this will matter. Maybe should make entries a set. 656 # whether this will matter. Maybe should make entries a set.
657 # print "Changed directory", revnum, path, ent.action, ent.copyfrom_path, ent.copyfrom_rev 657 # print "Changed directory", revnum, path, ent.action, ent.copyfrom_path, ent.copyfrom_rev
658 # This will fail if a directory was copied 658 # This will fail if a directory was copied
659 # from another branch and then some of its files 659 # from another branch and then some of its files
660 # were deleted in the same transaction. 660 # were deleted in the same transaction.
661 children = self._find_children(path, revnum) 661 children = util.sort(self._find_children(path, revnum))
662 children.sort()
663 for child in children: 662 for child in children:
664 # Can we move a child directory and its 663 # Can we move a child directory and its
665 # parent in the same commit? (probably can). Could 664 # parent in the same commit? (probably can). Could
666 # cause problems if instead of revnum -1, 665 # cause problems if instead of revnum -1,
667 # we have to look in (copyfrom_path, revnum - 1) 666 # we have to look in (copyfrom_path, revnum - 1)
730 return None, branched 729 return None, branched
731 730
732 parents = [] 731 parents = []
733 # check whether this revision is the start of a branch or part 732 # check whether this revision is the start of a branch or part
734 # of a branch renaming 733 # of a branch renaming
735 orig_paths = orig_paths.items() 734 orig_paths = util.sort(orig_paths.items())
736 orig_paths.sort()
737 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)] 735 root_paths = [(p,e) for p,e in orig_paths if self.module.startswith(p)]
738 if root_paths: 736 if root_paths:
739 path, ent = root_paths[-1] 737 path, ent = root_paths[-1]
740 if ent.copyfrom_path: 738 if ent.copyfrom_path:
741 # If dir was moved while one of its file was removed 739 # If dir was moved while one of its file was removed
1043 for i in strutil.rfindall(f, '/'): 1041 for i in strutil.rfindall(f, '/'):
1044 dirs.add(f[:i]) 1042 dirs.add(f[:i])
1045 return dirs 1043 return dirs
1046 1044
1047 def add_dirs(self, files): 1045 def add_dirs(self, files):
1048 add_dirs = [d for d in self.dirs_of(files) 1046 add_dirs = [d for d in util.sort(self.dirs_of(files))
1049 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))] 1047 if not os.path.exists(self.wjoin(d, '.svn', 'entries'))]
1050 if add_dirs: 1048 if add_dirs:
1051 add_dirs.sort()
1052 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True) 1049 self.xargs(add_dirs, 'add', non_recursive=True, quiet=True)
1053 return add_dirs 1050 return add_dirs
1054 1051
1055 def add_files(self, files): 1052 def add_files(self, files):
1056 if files: 1053 if files:
1057 self.xargs(files, 'add', quiet=True) 1054 self.xargs(files, 'add', quiet=True)
1058 return files 1055 return files
1059 1056
1060 def tidy_dirs(self, names): 1057 def tidy_dirs(self, names):
1061 dirs = list(self.dirs_of(names)) 1058 dirs = util.sort(self.dirs_of(names))
1062 dirs.sort()
1063 dirs.reverse() 1059 dirs.reverse()
1064 deleted = [] 1060 deleted = []
1065 for d in dirs: 1061 for d in dirs:
1066 wd = self.wjoin(d) 1062 wd = self.wjoin(d)
1067 if os.listdir(wd) == '.svn': 1063 if os.listdir(wd) == '.svn':