Looking for a way to get merge directive contents
Frits Jalvingh
jal at etc.to
Mon Jun 2 23:52:42 BST 2008
Thanks a million. I tried that command but the result looks like the unbase64'ed bunzipped result of the blob in the message..
I've already spent a small hour in some Python hacking, and after some shameless stealing from the Bazaar and Bundle Buggy source code have wrought the following, which actually does most of what I need:
from StringIO import StringIO
from bzrlib.commands import Command, register_command, errors
from bzrlib import merge_directive
from bzrlib.errors import (NotABundle, BundleNotSupported, BadBundle, NotAMergeDirective)
from bzrlib.bundle import serializer
class mergeinfo(Command):
"""Displays information about a merge directive
This retrieves the log messages and commit information that is contained in a merge directive
passed to this command.
"""
# see bzrlib/builtins.py for information about what to put here
takes_args = ['file']
takes_options = []
aliases = ['minf']
# @display_command
def run(self, file=None):
f = open(file, 'r')
lines = f.readlines()
f.close()
try:
md = merge_directive.MergeDirective.from_lines(lines)
except NotAMergeDirective:
bundle_text = lines
merge_directive_message = None
else:
merge_directive_message = md.message
bundle_text = md.get_raw_bundle()
if bundle_text is None:
commit_messages = []
else:
try:
bundle_info = serializer.read_bundle(StringIO(bundle_text))
except (NotABundle, BundleNotSupported, BadBundle):
commit_messages = []
else:
print "--------- bundle-info --------------------"
print "Target: ", bundle_info.target
print dir(bundle_info)
commit_messages = []
for revision in bundle_info.real_revisions:
commit_messages.append(revision.message)
print "------- revision ---------------"
print "Committer : ", revision.committer
print "Inventory SHA1: ", revision.inventory_sha1
print "Message : ", revision.message
print "Summary : ", revision.get_summary()
print "Properties : ", revision.properties
print dir(revision)
# find line count
patch_lines = md.patch.splitlines()
self.num_patch_lines = len(patch_lines)
print "Merge lines is ", self.num_patch_lines
print "Merge log is ", commit_messages
# Decode the bundle in it,
raise errors.BzrCommandError("Not there yet")
register_command(mergeinfo)
The only thing left is to find out how bzr handles output; I'll go look into xmloutput for that ;-)
Greetings,
Frits
On Mon, 2008-06-02 at 16:41 -0400, Aaron Bentley wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Frits Jalvingh wrote:
> > Is there a bzr command which shows the contents of a merge directive? I
> > specifically need the log messages contained therein.
>
> bzr bundle-info -v. But it won't be what you want-- it will output the
> mpdiff records, which you won't be able to apply.
>
> > (I hope I do not have to write a plugin; my Python is not exactly
> > good ;-)
>
> It is certainly easiest to write Bazaar-based programs in Python.
>
> Aaron
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFIRFrq0F+nu1YWqI0RAlyQAJ4zS3AWRxwZ2jiwVB3f1fBbrlc2YwCghoCU
> E6vxarZ/tpTb/fpnENQxYe8=
> =xODf
> -----END PGP SIGNATURE-----
----------------- Now playing -
More information about the bazaar
mailing list