本文整理汇总了Python中bzrlib.workingtree.WorkingTree.open_containing方法的典型用法代码示例。如果您正苦于以下问题:Python WorkingTree.open_containing方法的具体用法?Python WorkingTree.open_containing怎么用?Python WorkingTree.open_containing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzrlib.workingtree.WorkingTree
的用法示例。
在下文中一共展示了WorkingTree.open_containing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def run(self, merge_type=None, directory="."):
from bzrlib.plugins.rewrite.rebase import RebaseState1, WorkingTreeRevisionRewriter
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open_containing(directory)[0]
wt.lock_write()
try:
state = RebaseState1(wt)
replayer = WorkingTreeRevisionRewriter(wt, state, merge_type=merge_type)
# Abort if there are any conflicts
if len(wt.conflicts()) != 0:
raise BzrCommandError(
gettext(
"There are still conflicts present. "
"Resolve the conflicts and then run "
"'bzr resolve' and try again."
)
)
# Read plan file
try:
replace_map = state.read_plan()[1]
except NoSuchFile:
raise BzrCommandError(gettext("No rebase to continue"))
oldrevid = state.read_active_revid()
if oldrevid is not None:
oldrev = wt.branch.repository.get_revision(oldrevid)
replayer.commit_rebase(oldrev, replace_map[oldrevid][0])
finish_rebase(state, wt, replace_map, replayer)
finally:
wt.unlock()
示例2: run
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def run(self, location=None, remember=False, directory=None,
no_rebase=False, strict=None):
from bzrlib import urlutils
from bzrlib.controldir import ControlDir
from bzrlib.errors import BzrCommandError, NoWorkingTree
from bzrlib.workingtree import WorkingTree
if directory is None:
directory = "."
try:
source_wt = WorkingTree.open_containing(directory)[0]
source_branch = source_wt.branch
except NoWorkingTree:
source_branch = Branch.open(directory)
source_wt = None
if source_wt is not None:
source_wt.check_changed_or_out_of_date(
strict, 'dpush_strict',
more_error='Use --no-strict to force the push.',
more_warning='Uncommitted changes will not be pushed.')
stored_loc = source_branch.get_push_location()
if location is None:
if stored_loc is None:
raise BzrCommandError(gettext("No push location known or specified."))
else:
display_url = urlutils.unescape_for_display(stored_loc,
self.outf.encoding)
self.outf.write(
gettext("Using saved location: %s\n") % display_url)
location = stored_loc
controldir = ControlDir.open(location)
target_branch = controldir.open_branch()
target_branch.lock_write()
try:
try:
push_result = source_branch.push(target_branch, lossy=True)
except errors.LossyPushToSameVCS:
raise BzrCommandError(gettext("{0!r} and {1!r} are in the same VCS, lossy "
"push not necessary. Please use regular push.").format(
source_branch, target_branch))
# We successfully created the target, remember it
if source_branch.get_push_location() is None or remember:
# FIXME: Should be done only if we succeed ? -- vila 2012-01-18
source_branch.set_push_location(target_branch.base)
if not no_rebase:
old_last_revid = source_branch.last_revision()
source_branch.pull(target_branch, overwrite=True)
new_last_revid = source_branch.last_revision()
if source_wt is not None and old_last_revid != new_last_revid:
source_wt.lock_write()
try:
target = source_wt.branch.repository.revision_tree(
new_last_revid)
update_workingtree_fileids(source_wt, target)
finally:
source_wt.unlock()
push_result.report(self.outf)
finally:
target_branch.unlock()
示例3: run
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def run(self, file_list):
wt = WorkingTree.open_containing('.')
# Create the files if they don't exist.
for filename in file_list:
filepath = os.path.join(os.getcwd(), filename)
fd = os.open(filepath, FLAGS, 0666)
os.close(fd)
wt[0].smart_add(file_list, recurse=False)
示例4: run
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def run(self, location=None, remember=False, directory=None,
no_rebase=False):
from bzrlib import urlutils
from bzrlib.bzrdir import BzrDir
from bzrlib.errors import BzrCommandError, NoWorkingTree
from bzrlib.trace import info
from bzrlib.workingtree import WorkingTree
from upgrade import update_workingtree_fileids
if directory is None:
directory = "."
try:
source_wt = WorkingTree.open_containing(directory)[0]
source_branch = source_wt.branch
except NoWorkingTree:
source_branch = Branch.open_containing(directory)[0]
source_wt = None
stored_loc = source_branch.get_push_location()
if location is None:
if stored_loc is None:
raise BzrCommandError("No push location known or specified.")
else:
display_url = urlutils.unescape_for_display(stored_loc,
self.outf.encoding)
self.outf.write("Using saved location: %s\n" % display_url)
location = stored_loc
bzrdir = BzrDir.open(location)
target_branch = bzrdir.open_branch()
target_branch.lock_write()
try:
if not isinstance(target_branch, ForeignBranch):
info("target branch is not a foreign branch, using regular push.")
target_branch.pull(source_branch)
no_rebase = True
else:
revid_map = target_branch.dpull(source_branch)
# We successfully created the target, remember it
if source_branch.get_push_location() is None or remember:
source_branch.set_push_location(target_branch.base)
if not no_rebase:
_, old_last_revid = source_branch.last_revision_info()
new_last_revid = revid_map[old_last_revid]
if source_wt is not None:
source_wt.pull(target_branch, overwrite=True,
stop_revision=new_last_revid)
source_wt.lock_write()
try:
update_workingtree_fileids(source_wt,
source_wt.branch.repository.revision_tree(old_last_revid),
source_wt.branch.repository.revision_tree(new_last_revid))
finally:
source_wt.unlock()
else:
source_branch.pull(target_branch, overwrite=True,
stop_revision=new_last_revid)
finally:
target_branch.unlock()
示例5: test_open_containing
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def test_open_containing(self):
branch = self.make_branch_and_tree('.').branch
local_base = urlutils.local_path_from_url(branch.base)
# Empty opens '.'
wt, relpath = WorkingTree.open_containing()
self.assertEqual('', relpath)
self.assertEqual(wt.basedir + '/', local_base)
# '.' opens this dir
wt, relpath = WorkingTree.open_containing(u'.')
self.assertEqual('', relpath)
self.assertEqual(wt.basedir + '/', local_base)
# './foo' finds '.' and a relpath of 'foo'
wt, relpath = WorkingTree.open_containing('./foo')
self.assertEqual('foo', relpath)
self.assertEqual(wt.basedir + '/', local_base)
# abspath(foo) finds '.' and relpath of 'foo'
wt, relpath = WorkingTree.open_containing('./foo')
wt, relpath = WorkingTree.open_containing(getcwd() + '/foo')
self.assertEqual('foo', relpath)
self.assertEqual(wt.basedir + '/', local_base)
# can even be a url: finds '.' and relpath of 'foo'
wt, relpath = WorkingTree.open_containing('./foo')
wt, relpath = WorkingTree.open_containing(
urlutils.local_path_to_url(getcwd() + '/foo'))
self.assertEqual('foo', relpath)
self.assertEqual(wt.basedir + '/', local_base)
示例6: vimdiff_to_file
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def vimdiff_to_file(vimdiff_args, file_to_diff, revision=None):
from bzrlib.workingtree import WorkingTree
work_tree, rel_path = WorkingTree.open_containing(file_to_diff)
work_tree.lock_read()
try:
_vimdiff_to_file(work_tree, rel_path, vimdiff_args, file_to_diff,
revision=revision)
finally:
work_tree.unlock()
示例7: run
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def run(self, text=False):
from bzrlib.workingtree import WorkingTree
wt = WorkingTree.open_containing(u'.')[0]
for conflict in wt.conflicts():
if text:
if conflict.typestring != 'text conflict':
continue
self.outf.write(conflict.path + '\n')
else:
self.outf.write(str(conflict) + '\n')
示例8: update_file_info
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def update_file_info(self, file):
if file.get_uri_scheme() != 'file':
return
try:
tree, path = WorkingTree.open_containing(file.get_uri())
except NotBranchError:
return
except NoWorkingTree:
return
disabled_flag = self.check_branch_enabled(tree.branch)
if disabled_flag == 'False':
return
emblem = None
status = None
id = tree.path2id(path)
if id == None:
if tree.is_ignored(path):
status = 'ignored'
emblem = 'bzr-ignored'
else:
status = 'unversioned'
elif tree.has_filename(path):
emblem = 'bzr-controlled'
status = 'unchanged'
delta = tree.changes_from(tree.branch.basis_tree())
if delta.touches_file_id(id):
emblem = 'bzr-modified'
status = 'modified'
for f, _, _ in delta.added:
if f == path:
emblem = 'bzr-added'
status = 'added'
for of, f, _, _, _, _ in delta.renamed:
if f == path:
status = 'renamed from %s' % f
elif tree.branch.basis_tree().has_filename(path):
emblem = 'bzr-removed'
status = 'removed'
else:
# FIXME: Check for ignored files
status = 'unversioned'
if emblem is not None:
file.add_emblem(emblem)
file.add_string_attribute('bzr_status', status)
示例9: remove_cb
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def remove_cb(self, menu, vfs_file):
# We can only cope with local files
if vfs_file.get_uri_scheme() != 'file':
return
file = vfs_file.get_uri()
try:
tree, path = WorkingTree.open_containing(file)
except NotBranchError:
return
tree.remove(path)
示例10: newtree_cb
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def newtree_cb(self, menu, vfs_file):
# We can only cope with local files
if vfs_file.get_uri_scheme() != 'file':
return
file = vfs_file.get_uri()
# We only want to continue here if we get a NotBranchError
try:
tree, path = WorkingTree.open_containing(file)
except NotBranchError:
BzrDir.create_standalone_workingtree(file)
示例11: update
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def update(self, update_file=False):
self.tree = None
self.root = self.path
try:
self.tree = WorkingTree.open_containing(self.path)[0]
self.root = self.tree.basedir
except NoWorkingTree:
pass
if update_file:
self.update_file()
示例12: toggle_integration
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def toggle_integration(self, menu, action, vfs_file=None):
try:
tree, path = WorkingTree.open_containing(vfs_file.get_uri())
except NotBranchError:
return
except NoWorkingTree:
return
branch = tree.branch
if branch is None:
config = GlobalConfig()
else:
config = branch.get_config()
config.set_user_option('nautilus_integration', action)
示例13: commit_cb
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def commit_cb(self, menu, vfs_file=None):
# We can only cope with local files
if vfs_file.get_uri_scheme() != 'file':
return
file = vfs_file.get_uri()
tree = None
branch = None
try:
tree, path = WorkingTree.open_containing(file)
branch = tree.branch
except NotBranchError, e:
path = e.path
示例14: test_resolve_in_subdir
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def test_resolve_in_subdir(self):
"""resolve when run from subdirectory should handle relative paths"""
orig_dir = os.getcwdu()
try:
os.mkdir("subdir")
os.chdir("subdir")
self.run_bzr("resolve ../myfile")
os.chdir("../../b")
self.run_bzr("resolve ../a/myfile")
wt = WorkingTree.open_containing('.')[0]
conflicts = wt.conflicts()
if not conflicts.is_empty():
self.fail("tree still contains conflicts: %r" % conflicts)
finally:
os.chdir(orig_dir)
示例15: merge_cb
# 需要导入模块: from bzrlib.workingtree import WorkingTree [as 别名]
# 或者: from bzrlib.workingtree.WorkingTree import open_containing [as 别名]
def merge_cb(self, menu, vfs_file):
# We can only cope with local files
if vfs_file.get_uri_scheme() != 'file':
return
file = vfs_file.get_uri()
# We only want to continue here if we get a NotBranchError
try:
tree, path = WorkingTree.open_containing(file)
except NotBranchError:
return
from bzrlib.plugins.gtk.merge import MergeDialog
dialog = MergeDialog(tree, path)
dialog.run()
dialog.destroy()