Ejemplo n.º 1
0
 def run(self, filename):
     tree, relpath = workingtree.WorkingTree.open_containing(filename)
     if tree.is_ignored(relpath) and not tree.path2id(relpath):
         if not trace.is_quiet():
             print >>self.outf, 'ignored'
         return 1
     else:
         if not trace.is_quiet():
             print >>self.outf, 'not ignored'
         return 0
Ejemplo n.º 2
0
 def test_verbosity_level(self):
     set_verbosity_level(1)
     self.assertEqual(1, get_verbosity_level())
     self.assertTrue(is_verbose())
     self.assertFalse(is_quiet())
     set_verbosity_level(-1)
     self.assertEqual(-1, get_verbosity_level())
     self.assertFalse(is_verbose())
     self.assertTrue(is_quiet())
     set_verbosity_level(0)
     self.assertEqual(0, get_verbosity_level())
     self.assertFalse(is_verbose())
     self.assertFalse(is_quiet())
Ejemplo n.º 3
0
 def test_verbosity_level(self):
     set_verbosity_level(1)
     self.assertEqual(1, get_verbosity_level())
     self.assertTrue(is_verbose())
     self.assertFalse(is_quiet())
     set_verbosity_level(-1)
     self.assertEqual(-1, get_verbosity_level())
     self.assertFalse(is_verbose())
     self.assertTrue(is_quiet())
     set_verbosity_level(0)
     self.assertEqual(0, get_verbosity_level())
     self.assertFalse(is_verbose())
     self.assertFalse(is_quiet())
Ejemplo n.º 4
0
 def test_verbosity_isolated(self):
     """Global verbosity is isolated from commands run in scripts.
     """
     # see also 656694; we should get rid of global verbosity
     self.run_script("""
     $ bzr init --quiet a
     """)
     self.assertEquals(trace.is_quiet(), False)
Ejemplo n.º 5
0
 def test_verbosity_isolated(self):
     """Global verbosity is isolated from commands run in scripts.
     """
     # see also 656694; we should get rid of global verbosity
     self.run_script("""
     $ bzr init --quiet a
     """)
     self.assertEqual(trace.is_quiet(), False)
Ejemplo n.º 6
0
 def apply(self, bzrdir):
     branch = bzrdir.open_branch()
     branch.lock_write()
     try:
         branch.set_stacked_on_url(None)
         if not trace.is_quiet():
             ui.ui_factory.note(gettext(
                 "%s is now not stacked\n")
                 % (branch.base,))
     finally:
         branch.unlock()
Ejemplo n.º 7
0
 def apply(self, bzrdir, stacked_on_url):
     branch = bzrdir.open_branch()
     # it may be a path relative to the cwd or a url; the branch wants
     # a path relative to itself...
     on_url = urlutils.relative_url(branch.base,
         urlutils.normalize_url(stacked_on_url))
     branch.lock_write()
     try:
         branch.set_stacked_on_url(on_url)
         if not trace.is_quiet():
             ui.ui_factory.note(gettext(
                 "{0} is now stacked on {1}\n").format(
                   branch.base, branch.get_stacked_on_url()))
     finally:
         branch.unlock()
Ejemplo n.º 8
0
    def run(self, command_list, externals_only=False, shell=False, dry_run=False):
        # TODO: support setting the base location with -d
        externals.disable_hooks = True
        (tree, branch, relpath) = BzrDir.open_containing_tree_or_branch('.')

        global _main_base
        if _main_base is None:
            _main_base = branch.base

        ex = externals.Externals(branch, branch.last_revision(),
            root=tree.basedir)
        if ex.read_config():
            # run ecmd command in each externals for multilevel
            ecmd = ['ecmd']
            if shell:
                ecmd += ['--shell']
            if dry_run:
                ecmd += ['--dry-run']
            ex.adjust_verbosity(ecmd)

            for location, rel_path, revision in ex.branch_iterator(): #@UnusedVariable
                os.chdir(os.path.join(ex.cwd, rel_path))
                run_bzr_catch_user_errors(ecmd + ['--'] + command_list)

        if not externals_only:
            # parse arguments of command and execute
            if not is_quiet():
                if branch.base != _main_base:
                    note('Run command in external: ' + self._relpath(ex.root))
                else:
                    note('Run command in main branch:')
            command_list = self._substitute_in_commandlist(
                command_list, self._relpath(ex.root))
            ex.adjust_verbosity(command_list)
            if not dry_run:
                os.chdir(ex.root)
                if shell:
                    os.system(' '.join(command_list))
                else:
                    run_bzr_catch_user_errors(command_list)

        os.chdir(ex.cwd)
Ejemplo n.º 9
0
    def report(self, file_id, paths, versioned, renamed, modified, exe_change,
               kind):
        """Report one change to a file

        :param file_id: The file_id of the file
        :param path: The old and new paths as generated by Tree.iter_changes.
        :param versioned: may be 'added', 'removed', 'unchanged', or
            'unversioned.
        :param renamed: may be True or False
        :param modified: may be 'created', 'deleted', 'kind changed',
            'modified' or 'unchanged'.
        :param exe_change: True if the execute bit has changed
        :param kind: A pair of file kinds, as generated by Tree.iter_changes.
            None indicates no file present.
        """
        if is_quiet():
            return
        if paths[1] == '' and versioned == 'added' and self.suppress_root_add:
            return
        if self.view_files and not osutils.is_inside_any(self.view_files,
            paths[1]):
            return
        if versioned == 'unversioned':
            # skip ignored unversioned files if needed.
            if self.unversioned_filter is not None:
                if self.unversioned_filter(paths[1]):
                    return
            # dont show a content change in the output.
            modified = 'unchanged'
        # we show both paths in the following situations:
        # the file versioning is unchanged AND
        # ( the path is different OR
        #   the kind is different)
        if (versioned == 'unchanged' and
            (renamed or modified == 'kind changed')):
            if renamed:
                # on a rename, we show old and new
                old_path, path = paths
            else:
                # if it's not renamed, we're showing both for kind changes
                # so only show the new path
                old_path, path = paths[1], paths[1]
            # if the file is not missing in the source, we show its kind
            # when we show two paths.
            if kind[0] is not None:
                old_path += self.kind_marker(kind[0])
            old_path += " => "
        elif versioned == 'removed':
            # not present in target
            old_path = ""
            path = paths[0]
        else:
            old_path = ""
            path = paths[1]
        if renamed:
            rename = "R"
        else:
            rename = self.versioned_map[versioned]
        # we show the old kind on the new path when the content is deleted.
        if modified == 'deleted':
            path += self.kind_marker(kind[0])
        # otherwise we always show the current kind when there is one
        elif kind[1] is not None:
            path += self.kind_marker(kind[1])
        if exe_change:
            exe = '*'
        else:
            exe = ' '
        self.output("%s%s%s %s%s", rename, self.modified_map[modified], exe,
                    old_path, path)
Ejemplo n.º 10
0
 def adjust_verbosity(cmd):
     if is_quiet():
         cmd += ['-q']
     if is_verbose():
         cmd += ['-v']
Ejemplo n.º 11
0
 def _report(cmd):
     if not is_quiet():
         note('External ' + ' '.join(cmd))
Ejemplo n.º 12
0
 def _select_reporter(self):
     """Select the CommitReporter to use."""
     if is_quiet():
         return NullCommitReporter()
     return ReportCommitToLog()
Ejemplo n.º 13
0
    def report(self, file_id, paths, versioned, renamed, modified, exe_change,
               kind):
        """Report one change to a file

        :param file_id: The file_id of the file
        :param path: The old and new paths as generated by Tree.iter_changes.
        :param versioned: may be 'added', 'removed', 'unchanged', or
            'unversioned.
        :param renamed: may be True or False
        :param modified: may be 'created', 'deleted', 'kind changed',
            'modified' or 'unchanged'.
        :param exe_change: True if the execute bit has changed
        :param kind: A pair of file kinds, as generated by Tree.iter_changes.
            None indicates no file present.
        """
        if is_quiet():
            return
        if paths[1] == '' and versioned == 'added' and self.suppress_root_add:
            return
        if self.view_files and not osutils.is_inside_any(
                self.view_files, paths[1]):
            return
        if versioned == 'unversioned':
            # skip ignored unversioned files if needed.
            if self.unversioned_filter is not None:
                if self.unversioned_filter(paths[1]):
                    return
            # dont show a content change in the output.
            modified = 'unchanged'
        # we show both paths in the following situations:
        # the file versioning is unchanged AND
        # ( the path is different OR
        #   the kind is different)
        if (versioned == 'unchanged'
                and (renamed or modified == 'kind changed')):
            if renamed:
                # on a rename, we show old and new
                old_path, path = paths
            else:
                # if it's not renamed, we're showing both for kind changes
                # so only show the new path
                old_path, path = paths[1], paths[1]
            # if the file is not missing in the source, we show its kind
            # when we show two paths.
            if kind[0] is not None:
                old_path += self.kind_marker(kind[0])
            old_path += " => "
        elif versioned == 'removed':
            # not present in target
            old_path = ""
            path = paths[0]
        else:
            old_path = ""
            path = paths[1]
        if renamed:
            rename = "R"
        else:
            rename = self.versioned_map[versioned]
        # we show the old kind on the new path when the content is deleted.
        if modified == 'deleted':
            path += self.kind_marker(kind[0])
        # otherwise we always show the current kind when there is one
        elif kind[1] is not None:
            path += self.kind_marker(kind[1])
        if exe_change:
            exe = '*'
        else:
            exe = ' '
        self.output("%s%s%s %s%s", rename, self.modified_map[modified], exe,
                    old_path, path)