Example #1
0
    def test_add_duplicate(self):
        """Adding the same ignore twice shouldn't add a new entry."""
        ignores.add_runtime_ignores(['foo', 'bar'])
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())

        ignores.add_runtime_ignores(['bar'])
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())
Example #2
0
    def test_add_duplicate(self):
        """Adding the same ignore twice shouldn't add a new entry."""
        ignores.add_runtime_ignores(['foo', 'bar'])
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())

        ignores.add_runtime_ignores(['bar'])
        self.assertEqual(set(['foo', 'bar']), ignores.get_runtime_ignores())
Example #3
0
File: bzr.py Project: yut148/tailor
    def __init__(self, repository):
        from os.path import split
        from bzrlib import version_info, IGNORE_FILENAME

        if version_info > (0, 9):
            from bzrlib.ignores import add_runtime_ignores, parse_ignore_file
        else:
            from bzrlib import DEFAULT_IGNORE

        WorkingDir.__init__(self, repository)
        # TODO: check if there is a "repository" in the configuration,
        # and use it as a bzr repository
        self.ignored = []
        self._working_tree = None

        # The bzr repository may have some plugins that needs to be activated
        load_plugins()

        try:
            bzrdir = BzrDir.open(self.repository.basedir)
            wt = self._working_tree = bzrdir.open_workingtree()

            # read .bzrignore for _addSubtree()
            if wt.has_filename(IGNORE_FILENAME):
                f = wt.get_file_byname(IGNORE_FILENAME)
                if version_info > (0, 9):
                    self.ignored.extend(parse_ignore_file(f))
                else:
                    self.ignored.extend(
                        [line.rstrip("\n\r") for line in f.readlines()])
                f.close()
        except (errors.NotBranchError, errors.NoWorkingTree):
            pass

        # Omit our own log...
        logfile = self.repository.projectref().logfile
        dir, file = split(logfile)
        if dir == self.repository.basedir:
            self.ignored.append(file)

        # ... and state file
        sfname = self.repository.projectref().state_file.filename
        dir, file = split(sfname)
        if dir == self.repository.basedir:
            self.ignored.append(file)
            self.ignored.append(file + '.old')
            self.ignored.append(file + '.journal')

        if version_info > (0, 9):
            add_runtime_ignores(self.ignored)
        else:
            DEFAULT_IGNORE.extend(self.ignored)
Example #4
0
    def test_remove_changed_ignored_files(self):
        """Changed ignored files should be backed up."""
        files = ['an_ignored_file']
        tree = self.get_tree(files)
        tree.add(files)
        ignores.add_runtime_ignores(["*ignored*"])
        self.assertInWorkingTree(files)
        self.assertNotEqual(None, tree.is_ignored(files[0]))

        tree.remove(files, keep_files=False)
        self.assertNotInWorkingTree(files)
        self.assertPathExists('an_ignored_file.~1~')
        tree._validate()
Example #5
0
File: bzr.py Project: yut148/tailor
    def _prepareTargetRepository(self):
        from bzrlib import version_info
        from vcpx.dualwd import IGNORED_METADIRS

        if self._working_tree is None:
            self._working_tree = self.repository.create()

        if version_info > (0, 9):
            from bzrlib.ignores import add_runtime_ignores
            add_runtime_ignores(IGNORED_METADIRS)
        else:
            from bzrlib import DEFAULT_IGNORE
            DEFAULT_IGNORE.extend(IGNORED_METADIRS)
Example #6
0
File: bzr.py Project: lelit/tailor
    def _prepareTargetRepository(self):
        from bzrlib import version_info
        from vcpx.dualwd import IGNORED_METADIRS

        if self._working_tree is None:
            self._working_tree = self.repository.create()

        if version_info > (0,9):
            from bzrlib.ignores import add_runtime_ignores
            add_runtime_ignores(IGNORED_METADIRS)
        else:
            from bzrlib import DEFAULT_IGNORE
            DEFAULT_IGNORE.extend(IGNORED_METADIRS)
Example #7
0
    def test_remove_changed_ignored_files(self):
        """Changed ignored files should be backed up."""
        files = ['an_ignored_file']
        tree = self.get_tree(files)
        tree.add(files)
        ignores.add_runtime_ignores(["*ignored*"])
        self.assertInWorkingTree(files)
        self.assertNotEquals(None, tree.is_ignored(files[0]))

        tree.remove(files, keep_files=False)
        self.assertNotInWorkingTree(files)
        self.assertPathExists('an_ignored_file.~1~')
        tree._validate()
Example #8
0
File: bzr.py Project: lelit/tailor
    def __init__(self, repository):
        from os.path import split
        from bzrlib import version_info, IGNORE_FILENAME

        if version_info > (0,9):
            from bzrlib.ignores import add_runtime_ignores, parse_ignore_file
        else:
            from bzrlib import DEFAULT_IGNORE

        WorkingDir.__init__(self, repository)
        # TODO: check if there is a "repository" in the configuration,
        # and use it as a bzr repository
        self.ignored = []
        self._working_tree = None

        # The bzr repository may have some plugins that needs to be activated
        load_plugins()

        try:
            bzrdir = BzrDir.open(self.repository.basedir)
            wt = self._working_tree = bzrdir.open_workingtree()

            # read .bzrignore for _addSubtree()
            if wt.has_filename(IGNORE_FILENAME):
                f = wt.get_file_byname(IGNORE_FILENAME)
                if version_info > (0,9):
                    self.ignored.extend(parse_ignore_file(f))
                else:
                    self.ignored.extend([ line.rstrip("\n\r") for line in f.readlines() ])
                f.close()
        except (errors.NotBranchError, errors.NoWorkingTree):
            pass

        # Omit our own log...
        logfile = self.repository.projectref().logfile
        dir, file = split(logfile)
        if dir == self.repository.basedir:
            self.ignored.append(file)

        # ... and state file
        sfname = self.repository.projectref().state_file.filename
        dir, file = split(sfname)
        if dir == self.repository.basedir:
            self.ignored.append(file)
            self.ignored.append(file+'.old')
            self.ignored.append(file+'.journal')

        if version_info > (0,9):
            add_runtime_ignores(self.ignored)
        else:
            DEFAULT_IGNORE.extend(self.ignored)
Example #9
0
 def test_remove_changed_ignored_files(self):
     """Changed ignored files should not be deleted."""
     files = ['an_ignored_file']
     tree = self.get_tree(files)
     tree.add(files)
     ignores.add_runtime_ignores(["*ignored*"])
     self.assertInWorkingTree(files)
     self.assertNotEquals(None, tree.is_ignored(files[0]))
     err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove,
         files, keep_files=False)
     self.assertContainsRe(err.changes_as_text,
         '(?s)added:.*' + files[0])
     self.assertInWorkingTree(files)
     tree._validate()
Example #10
0
 def test_remove_changed_ignored_files(self):
     """Changed ignored files should not be deleted."""
     files = ['an_ignored_file']
     tree = self.get_tree(files)
     tree.add(files)
     ignores.add_runtime_ignores(["*ignored*"])
     self.assertInWorkingTree(files)
     self.assertNotEquals(None, tree.is_ignored(files[0]))
     err = self.assertRaises(errors.BzrRemoveChangedFilesError,
                             tree.remove,
                             files,
                             keep_files=False)
     self.assertContainsRe(err.changes_as_text, '(?s)added:.*' + files[0])
     self.assertInWorkingTree(files)
     tree._validate()
Example #11
0
    def test_remove_unknown_ignored_files(self):
        """Unknown ignored files should be deleted."""
        tree = self.get_committed_tree(['b/'])
        ignores.add_runtime_ignores(["*ignored*"])

        self.build_tree(['unknown_ignored_file'])
        self.assertNotEquals(None, tree.is_ignored('unknown_ignored_file'))
        tree.remove('unknown_ignored_file', keep_files=False)
        self.assertRemovedAndDeleted('unknown_ignored_file')

        self.build_tree(['b/unknown_ignored_file', 'b/unknown_ignored_dir/'])
        self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_file'))
        self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_dir'))
        tree.remove('b', keep_files=False)
        self.assertRemovedAndDeleted('b')
        tree._validate()
Example #12
0
    def test_remove_unknown_ignored_files(self):
        """Unknown ignored files should be deleted."""
        tree = self.get_committed_tree(['b/'])
        ignores.add_runtime_ignores(["*ignored*"])

        self.build_tree(['unknown_ignored_file'])
        self.assertNotEquals(None, tree.is_ignored('unknown_ignored_file'))
        tree.remove('unknown_ignored_file', keep_files=False)
        self.assertRemovedAndDeleted('unknown_ignored_file')

        self.build_tree(['b/unknown_ignored_file', 'b/unknown_ignored_dir/'])
        self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_file'))
        self.assertNotEquals(None, tree.is_ignored('b/unknown_ignored_dir'))
        tree.remove('b', keep_files=False)
        self.assertRemovedAndDeleted('b')
        tree._validate()
Example #13
0
    def test_runtime_ignores(self):
        tree = self.make_branch_and_tree('.')
        self.build_tree_contents([('.bzrignore', '')])
        ignores._set_user_ignores([])

        orig_runtime = ignores._runtime_ignores
        try:
            ignores._runtime_ignores = set()
            self.assertEqual(None, tree.is_ignored('foobar.py'))

            tree._flush_ignore_list_cache()
            ignores.add_runtime_ignores(['./foobar.py'])
            self.assertEqual(set(['./foobar.py']), ignores.get_runtime_ignores())
            self.assertEqual('./foobar.py', tree.is_ignored('foobar.py'))
        finally:
            ignores._runtime_ignores = orig_runtime
Example #14
0
    def test_runtime_ignores(self):
        tree = self.make_branch_and_tree('.')
        self.build_tree_contents([('.bzrignore', '')])
        ignores._set_user_ignores([])

        orig_runtime = ignores._runtime_ignores
        try:
            ignores._runtime_ignores = set()
            self.assertEqual(None, tree.is_ignored('foobar.py'))

            tree._flush_ignore_list_cache()
            ignores.add_runtime_ignores(['./foobar.py'])
            self.assertEqual(set(['./foobar.py']),
                             ignores.get_runtime_ignores())
            self.assertEqual('./foobar.py', tree.is_ignored('foobar.py'))
        finally:
            ignores._runtime_ignores = orig_runtime
Example #15
0
    def test_add(self):
        """Test that we can add an entry to the list."""
        self.assertEqual(set(), ignores.get_runtime_ignores())

        ignores.add_runtime_ignores(['foo'])
        self.assertEqual(set(['foo']), ignores.get_runtime_ignores())
Example #16
0
    def test_add(self):
        """Test that we can add an entry to the list."""
        self.assertEqual(set(), ignores.get_runtime_ignores())

        ignores.add_runtime_ignores(['foo'])
        self.assertEqual(set(['foo']), ignores.get_runtime_ignores())
Example #17
0
 def test_is_ignored_1000_patterns(self):
     t = self.make_branch_and_tree('.')
     ignores.add_runtime_ignores([u'*.%i' % i for i in range(1, 999)])
     ignores.add_runtime_ignores(['./foo', 'foo/bar'])
     self.time(t.is_ignored, 'bar')
     ignores._runtime_ignores = set()