Example #1
0
 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()
Example #2
0
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()
Example #3
0
 def setUp(self):
     super(TestamentSetup, self).setUp()
     self.wt = self.make_branch_and_tree('.',
                                         format='dirstate-with-subtree')
     self.wt.set_root_id('TREE_ROT')
     b = self.b = self.wt.branch
     b.nick = "test branch"
     self.wt.commit(
         message='initial null commit',
         committer='test@user',
         timestamp=1129025423,  # 'Tue Oct 11 20:10:23 2005'
         timezone=0,
         rev_id='test@user-1')
     self.build_tree_contents([('hello', 'contents of hello file'),
                               ('src/', ),
                               ('src/foo.c', 'int main()\n{\n}\n')])
     self.wt.add(['hello', 'src', 'src/foo.c'],
                 ['hello-id', 'src-id', 'foo.c-id'])
     tt = TreeTransform(self.wt)
     trans_id = tt.trans_id_tree_path('hello')
     tt.set_executability(True, trans_id)
     tt.apply()
     self.wt.commit(message='add files and directories',
                    timestamp=1129025483,
                    timezone=36000,
                    rev_id='test@user-2',
                    committer='test@user')
Example #4
0
 def wt(name):
     path = pathjoin(self.dir, name)
     os.mkdir(path)
     wt = controldir.ControlDir.create_standalone_workingtree(path)
     # the tests perform pulls, so need a branch that is writeable.
     wt.lock_write()
     wt.set_root_id(self.tree_root)
     wt.flush()
     tt = TreeTransform(wt)
     return wt, tt
Example #5
0
    def setUp(self):
        super(TestExecutable, self).setUp()
        self.a_id = "a-20051208024829-849e76f7968d7a86"
        self.b_id = "b-20051208024829-849e76f7968d7a86"
        wt = self.make_branch_and_tree('b1')
        b = wt.branch
        tt = TreeTransform(wt)
        tt.new_file('a', tt.root, 'a test\n', self.a_id, True)
        tt.new_file('b', tt.root, 'b test\n', self.b_id, False)
        tt.apply()

        self.wt = wt
Example #6
0
 def setUp(self):
     super(TestamentSetup, self).setUp()
     self.wt = self.make_branch_and_tree('.', format='development-subtree')
     self.wt.set_root_id('TREE_ROT')
     b = self.b = self.wt.branch
     b.nick = "test branch"
     self.wt.commit(message='initial null commit',
              committer='test@user',
              timestamp=1129025423, # 'Tue Oct 11 20:10:23 2005'
              timezone=0,
              rev_id='test@user-1')
     self.build_tree_contents([('hello', 'contents of hello file'),
                          ('src/', ),
                          ('src/foo.c', 'int main()\n{\n}\n')])
     self.wt.add(['hello', 'src', 'src/foo.c'],
                          ['hello-id', 'src-id', 'foo.c-id'])
     tt = TreeTransform(self.wt)
     trans_id = tt.trans_id_tree_path('hello')
     tt.set_executability(True, trans_id)
     tt.apply()
     self.wt.commit(message='add files and directories',
              timestamp=1129025483,
              timezone=36000,
              rev_id='test@user-2',
              committer='test@user')
Example #7
0
    def setUp(self):
        super(TestExecutable, self).setUp()
        self.a_id = "a-20051208024829-849e76f7968d7a86"
        self.b_id = "b-20051208024829-849e76f7968d7a86"
        wt = self.make_branch_and_tree('b1')
        b = wt.branch
        tt = TreeTransform(wt)
        tt.new_file('a', tt.root, 'a test\n', self.a_id, True)
        tt.new_file('b', tt.root, 'b test\n', self.b_id, False)
        tt.apply()

        self.wt = wt
 def test_set_get_tree_reference(self):
     """This tests that setting a tree reference is persistent."""
     tree = self.make_branch_and_tree('.')
     transform = TreeTransform(tree)
     trans_id = transform.new_directory('reference', transform.root,
                                        'subtree-id')
     transform.set_tree_reference('subtree-revision', trans_id)
     transform.apply()
     tree = tree.bzrdir.open_workingtree()
     tree.lock_read()
     self.addCleanup(tree.unlock)
     self.assertEqual('subtree-revision',
                      tree.root_inventory['subtree-id'].reference_revision)
Example #9
0
 def test_set_get_tree_reference(self):
     """This tests that setting a tree reference is persistent."""
     tree = self.make_branch_and_tree('.')
     transform = TreeTransform(tree)
     trans_id = transform.new_directory('reference', transform.root,
         'subtree-id')
     transform.set_tree_reference('subtree-revision', trans_id)
     transform.apply()
     tree = tree.bzrdir.open_workingtree()
     tree.lock_read()
     self.addCleanup(tree.unlock)
     self.assertEqual('subtree-revision',
         tree.root_inventory['subtree-id'].reference_revision)
Example #10
0
 def get_limbodir_deletiondir(self, wt):
     transform = TreeTransform(wt)
     limbodir = transform._limbodir
     deletiondir = transform._deletiondir
     transform.finalize()
     return (limbodir, deletiondir)
Example #11
0
 def get_limbodir_deletiondir(self, wt):
     transform = TreeTransform(wt)
     limbodir = transform._limbodir
     deletiondir = transform._deletiondir
     transform.finalize()
     return (limbodir, deletiondir)