def test_canonicalize_path(self): """Canonicalizing paths should be fast.""" wt = self.make_kernel_like_tree(link_working=True) paths = [] for dirpath, dirnames, filenames in os.walk('.'): paths.extend(pathjoin(dirpath, d) for d in dirnames) paths.extend(pathjoin(dirpath, f) for f in filenames) tt = TreeTransform(wt) self.time(self.canonicalize_paths, tt, paths) tt.finalize()
def set_executability(wt, path, executable=True): """Set the executable bit for the file at path in the working tree os.chmod() doesn't work on windows. But TreeTransform can mark or unmark a file as executable. """ file_id = wt.path2id(path) tt = TreeTransform(wt) try: tt.set_executability(executable, tt.trans_id_tree_file_id(file_id)) tt.apply() finally: tt.finalize()
def get_limbodir_deletiondir(self, wt): transform = TreeTransform(wt) limbodir = transform._limbodir deletiondir = transform._deletiondir transform.finalize() return (limbodir, deletiondir)