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('ignored', file=self.outf) return 1 else: if not trace.is_quiet(): print('not ignored', file=self.outf) return 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(""" $ brz init --quiet a """) self.assertEqual(trace.is_quiet(), False)
def _run_command(command, basedir, msg, error_msg, not_installed_msg=None, env=None, success_exit_codes=None, indata=None): """ Run a command in a subprocess. :param command: list with command and parameters :param msg: message to display to the user :param error_msg: message to display if something fails. :param not_installed_msg: the message to display if the command isn't available. :param env: Optional environment to use rather than os.environ. :param success_exit_codes: Exit codes to consider succesfull, defaults to [0]. :param indata: Data to write to standard input """ def subprocess_setup(): signal.signal(signal.SIGPIPE, signal.SIG_DFL) trace.note(msg) # Hide output if -q is in use. quiet = trace.is_quiet() if quiet: kwargs = {"stderr": subprocess.STDOUT, "stdout": subprocess.PIPE} else: kwargs = {} if env is not None: kwargs["env"] = env trace.mutter("running: %r", command) try: proc = subprocess.Popen(command, cwd=basedir, stdin=subprocess.PIPE, preexec_fn=subprocess_setup, **kwargs) except OSError as e: if e.errno != errno.ENOENT: raise if not_installed_msg is None: raise raise MissingDependency(msg=not_installed_msg) output = proc.communicate(indata) if success_exit_codes is None: success_exit_codes = [0] if proc.returncode not in success_exit_codes: if quiet: raise errors.BzrCommandError("%s: %s" % (error_msg, output)) else: raise errors.BzrCommandError(error_msg)
def report(self, to_file): if not trace.is_quiet(): if self.old_revid in (self.new_revid, NULL_REVISION): to_file.write('No revisions to pull.\n') else: if self.new_revmeta is None: self.new_revmeta, _ = ( self.source_branch.repository._get_revmeta( self.new_revid)) to_file.write( 'Now on revision %d (svn revno: %d).\n' % (self.new_revno, self.new_revmeta.metarev.revnum)) self._show_tag_conficts(to_file)
def report(self, paths, versioned, renamed, copied, modified, exe_change, kind): """Report one change to a 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 copied: 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 trace.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 copied or modified == 'kind changed')): if renamed or copied: # on a rename or copy, we show old and new old_path, path = paths else: # if it's not renamed or copied, 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" elif copied: rename = "C" 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)