本文整理汇总了Python中bzrlib.bzrdir.BzrDir.open_containing_tree_or_branch方法的典型用法代码示例。如果您正苦于以下问题:Python BzrDir.open_containing_tree_or_branch方法的具体用法?Python BzrDir.open_containing_tree_or_branch怎么用?Python BzrDir.open_containing_tree_or_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzrlib.bzrdir.BzrDir
的用法示例。
在下文中一共展示了BzrDir.open_containing_tree_or_branch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_containing_tree_or_branch [as 别名]
def run(self, filename, all=False, plain=False, line='1', revision=None):
Gtk = open_display()
try:
line = int(line)
except ValueError:
raise BzrCommandError('Line argument ("%s") is not a number.' %
line)
from annotate.gannotate import GAnnotateWindow
from annotate.config import GAnnotateConfig
from bzrlib.bzrdir import BzrDir
wt, br, path = BzrDir.open_containing_tree_or_branch(filename)
if wt is not None:
tree = wt
else:
tree = br.basis_tree()
file_id = tree.path2id(path)
if file_id is None:
raise NotVersionedError(filename)
if revision is not None:
if len(revision) != 1:
raise BzrCommandError("Only 1 revion may be specified.")
revision_id = revision[0].as_revision_id(br)
tree = br.repository.revision_tree(revision_id)
else:
revision_id = getattr(tree, 'get_revision_id', lambda: None)()
window = GAnnotateWindow(all, plain, branch=br)
window.connect("destroy", lambda w: Gtk.main_quit())
config = GAnnotateConfig(window)
window.show()
br.lock_read()
if wt is not None:
wt.lock_read()
try:
window.annotate(tree, br, file_id)
window.jump_to_line(line)
Gtk.main()
finally:
br.unlock()
if wt is not None:
wt.unlock()
示例2: run
# 需要导入模块: from bzrlib.bzrdir import BzrDir [as 别名]
# 或者: from bzrlib.bzrdir.BzrDir import open_containing_tree_or_branch [as 别名]
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)