本文整理汇总了Python中bzrlib.revisionspec.RevisionSpec.from_string方法的典型用法代码示例。如果您正苦于以下问题:Python RevisionSpec.from_string方法的具体用法?Python RevisionSpec.from_string怎么用?Python RevisionSpec.from_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bzrlib.revisionspec.RevisionSpec
的用法示例。
在下文中一共展示了RevisionSpec.from_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_branch_status_revisions
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_branch_status_revisions(self):
"""Tests branch status with revisions"""
wt = self.make_branch_and_tree('.')
self.build_tree(['hello.c', 'bye.c'])
wt.add('hello.c')
wt.add('bye.c')
wt.commit('Test message')
revs = [RevisionSpec.from_string('0')]
self.assertStatus([
'added:\n',
' bye.c\n',
' hello.c\n'
],
wt,
revision=revs)
self.build_tree(['more.c'])
wt.add('more.c')
wt.commit('Another test message')
revs.append(RevisionSpec.from_string('1'))
self.assertStatus([
'added:\n',
' bye.c\n',
' hello.c\n',
],
wt,
revision=revs)
示例2: test_tree_statusxml_specific_files
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_tree_statusxml_specific_files(self):
"""Tests branch status with given specific files"""
wt = self.make_branch_and_tree('.')
b = wt.branch
self.build_tree(['directory/','directory/hello.c',
'bye.c','test.c','dir2/'])
wt.add('directory')
wt.add('test.c')
wt.commit('testing')
xml_status = create_xml(wt, {'unknown':[('file','bye.c', {}),
('directory', 'dir2', {}), ('file', 'directory/hello.c', {})]})
self.assertStatus(xml_status, wt)
tof = StringIO()
show_tree_status_xml(wt, specific_files=['bye.c','test.c','absent.c'], to_file=tof)
log_xml = fromstring(tof.getvalue())
nonexistents = log_xml.findall('nonexistents/nonexistent')
unknowns = log_xml.findall('unknown')
self.assertEquals(1, len(nonexistents))
self.assertEquals(1, len(unknowns))
self.assertStatus(create_xml(wt, {'unknown':[('file',
'directory/hello.c', {})]}), wt, specific_files=['directory'])
self.assertStatus(create_xml(wt, {'unknown':[('directory',
'dir2', {})]}), wt, specific_files=['dir2'])
revs = [RevisionSpec.from_string('0'), RevisionSpec.from_string('1')]
self.assertStatus(create_xml(wt, {'added':[('file', 'test.c', {})]}),
wt, revs, specific_files=['test.c'])
示例3: tests_revision_to_revision
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def tests_revision_to_revision(self):
"""doing a status between two revision trees should work."""
tree = self.make_branch_and_tree('.')
r1_id = tree.commit('one', allow_pointless=True)
r2_id = tree.commit('two', allow_pointless=True)
r2_tree = tree.branch.repository.revision_tree(r2_id)
output = StringIO()
show_tree_status(tree, to_file=output,
revision=[RevisionSpec.from_string("revid:%s" % r1_id),
RevisionSpec.from_string("revid:%s" % r2_id)])
示例4: test_invalid_line
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_invalid_line(self):
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:q')
e = self.assertRaises(errors.InvalidRevisionSpec,
spec.as_revision_id, self.tree.branch)
self.assertContainsRe(str(e),
r"Requested revision: \'annotate:annotate-tree/file1:q\' does not"
" exist in branch: .*\nNo such line: q")
示例5: test_no_such_file_with_colon
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_no_such_file_with_colon(self):
spec = RevisionSpec.from_string('annotate:annotate-tree/fi:le2:1')
e = self.assertRaises(errors.InvalidRevisionSpec,
spec.as_revision_id, self.tree.branch)
self.assertContainsRe(str(e),
r"Requested revision: \'annotate:annotate-tree/fi:le2:1\' does not"
" exist in branch: .*\nFile 'fi:le2' is not versioned")
示例6: test_line_log_single_merge_revision
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_line_log_single_merge_revision(self):
wt = self.make_branch_and_memory_tree('.')
wt.lock_write()
try:
wt.add('')
wt.commit('rev-1', rev_id='rev-1',
timestamp=1132586655, timezone=36000,
committer='Joe Foo <[email protected]>')
wt.commit('rev-merged', rev_id='rev-2a',
timestamp=1132586700, timezone=36000,
committer='Joe Foo <[email protected]>')
wt.set_parent_ids(['rev-1', 'rev-2a'])
wt.branch.set_last_revision_info(1, 'rev-1')
wt.commit('rev-2', rev_id='rev-2b',
timestamp=1132586800, timezone=36000,
committer='Joe Foo <[email protected]>')
logfile = self.make_utf8_encoded_stringio()
formatter = LineLogFormatter(to_file=logfile)
revspec = RevisionSpec.from_string('1.1.1')
wtb = wt.branch
rev = revspec.in_history(wtb)
show_log(wtb, formatter, start_revision=rev, end_revision=rev)
self.assertEqualDiff(logfile.getvalue(), """\
1.1.1: Joe Foo 2005-11-22 rev-merged
""")
finally:
wt.unlock()
示例7: test_merges_nonsupporting_formatter
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_merges_nonsupporting_formatter(self):
"""Tests that show_log will raise if the formatter doesn't
support merge revisions."""
wt = self.make_branch_and_memory_tree('.')
wt.lock_write()
try:
wt.add('')
wt.commit('rev-1', rev_id='rev-1',
timestamp=1132586655, timezone=36000,
committer='Joe Foo <[email protected]>')
wt.commit('rev-merged', rev_id='rev-2a',
timestamp=1132586700, timezone=36000,
committer='Joe Foo <[email protected]>')
wt.set_parent_ids(['rev-1', 'rev-2a'])
wt.branch.set_last_revision_info(1, 'rev-1')
wt.commit('rev-2', rev_id='rev-2b',
timestamp=1132586800, timezone=36000,
committer='Joe Foo <[email protected]>')
logfile = self.make_utf8_encoded_stringio()
formatter = ShortLogFormatter(to_file=logfile)
wtb = wt.branch
lf = LogCatcher()
revspec = RevisionSpec.from_string('1.1.1')
rev = revspec.in_history(wtb)
self.assertRaises(BzrCommandError, show_log, wtb, lf,
start_revision=rev, end_revision=rev)
finally:
wt.unlock()
示例8: test_as_revision_id_uncommitted
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_as_revision_id_uncommitted(self):
spec = RevisionSpec.from_string('annotate:annotate-tree/file1:3')
e = self.assertRaises(errors.InvalidRevisionSpec,
spec.as_revision_id, self.tree.branch)
self.assertContainsRe(str(e),
r"Requested revision: \'annotate:annotate-tree/file1:3\' does not"
" exist in branch: .*\nLine 3 has not been committed.")
示例9: log
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def log(self, uri, rev=None):
"""
Return the changelog of data stored at or under @param:uri
as of time @param:rev in JSON-listing format.
@raise:ResourceUnchanged
etc.
"""
from bzrlib.log import LogFormatter
def get_formatter(lst):
class ListLogFormatter(LogFormatter):
def __init__(self, *args, **kw):
LogFormatter.__init__(self, *args, **kw)
self._loglist = lst
def log_revision(self, revision):
revno = int(revision.revno)
author = revision.rev.committer # @@@ what about get_apparent_authors?
message = revision.rev.message.rstrip('\r\n')
timestamp = revision.rev.timestamp
self._loglist.append(dict(version=revno,
author=author,
message=message,
timestamp=timestamp,
id=uri,
revprops=revision.rev.properties))
return ListLogFormatter
from bzrlib.builtins import cmd_log
from bzrlib.revisionspec import RevisionSpec
log = cmd_log()
log.outf = None
foo = []
absolute_uri = os.path.join(self.checkout_dir, self.normalized(uri))
log.run(file_list=[absolute_uri],
revision=rev and [RevisionSpec.from_string("1"),
RevisionSpec.from_string(str(rev))] or None,
log_format = get_formatter(foo),
)
return [dict(href=uri, fields=i) for i in foo]
示例10: get_file_content
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def get_file_content(self, filename, revision):
rev_spec = RevisionSpec.from_string(revision)
tree = rev_spec.as_tree(self.branch)
file_id = tree.path2id(unicode(filename, 'utf8'))
if file_id == None:
return None
content = tree.get_file_text(file_id)
return content
示例11: g_revid
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def g_revid(repo, rev):
try:
if isinstance(rev, int) or isinstance(rev, long):
return repo.branch.get_rev_id(rev)
else:
return RevisionSpec.from_string(rev).in_history(repo.branch).rev_id
except (NoSuchRevision, InvalidRevisionSpec):
vim_throw('norev', rev, repo.basedir)
示例12: getheads
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def getheads(self):
if not self.rev:
return [self.branch.last_revision()]
try:
r = RevisionSpec.from_string(self.rev)
info = r.in_history(self.branch)
except errors.BzrError:
raise util.Abort(_('%s is not a valid revision in current branch')
% self.rev)
return [info.rev_id]
示例13: test_as_revision_id
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_as_revision_id(self):
self.assertAsRevisionId('r1', 'mainline:1')
self.assertAsRevisionId('r2', 'mainline:1.1.1')
self.assertAsRevisionId('r2', 'mainline:revid:alt_r2')
spec = RevisionSpec.from_string('mainline:revid:alt_r22')
e = self.assertRaises(errors.InvalidRevisionSpec,
spec.as_revision_id, self.tree.branch)
self.assertContainsRe(str(e),
"Requested revision: 'mainline:revid:alt_r22' does not exist in"
" branch: ")
示例14: get_revision_id
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def get_revision_id(revision, from_branch, tip=False):
"""Return revision id for a revision number and a branch.
If the revision is empty, the revision_id will be None.
If ``tip`` is True, the revision value will be ignored.
"""
if not tip and revision:
spec = RevisionSpec.from_string(revision)
return spec.as_revision_id(from_branch)
示例15: test_branch_statusxml_revisions
# 需要导入模块: from bzrlib.revisionspec import RevisionSpec [as 别名]
# 或者: from bzrlib.revisionspec.RevisionSpec import from_string [as 别名]
def test_branch_statusxml_revisions(self):
"""Tests branch status with revisions"""
wt = self.make_branch_and_tree('.')
self.build_tree(['hello.c', 'bye.c'])
wt.add('hello.c')
wt.add('bye.c')
wt.commit('Test message')
revs = [RevisionSpec.from_string('0')]
two_added = create_xml(wt, {'added':[('file', 'bye.c', {}),
('file', 'hello.c', {})]})
self.assertStatus(two_added, wt, revision=revs)
self.build_tree(['more.c'])
wt.add('more.c')
wt.commit('Another test message')
revs.append(RevisionSpec.from_string('1'))
self.assertStatus(two_added, wt, revision=revs)