threads / patch / 36667

patchbzr per-file comments in git-remote-bzr

Subject: [PATCH] bzr per-file comments in git-remote-bzr

## tl;dr

One message between May 15, 2014 and May 15, 2014. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Sergei Golubchik· May 15, 2014, 16:07 UTC · lore
>From 7fd7360ef5b4f453ceb8e32b18f73f9fbcaa95b7 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik <vuvova@gmail.com>
Date: Thu, 15 May 2014 17:50:16 +0200
Subject: [PATCH] git-remote-bzr: support bzr per-file comments

Bazaar supports per-file comments in revisions - using bzr-gtk one can write a global revisions comment and comments for individual files too (this was apparently modelled after a similar feature in BitKeeper). When exporting a bzr repository to git these file comments are lost.

This patch makes them to be not lost but appear as a part of the commit
comment instead. Empty file comments and file comments identical to the
commit comment are skipped (they add no value as a part of the commit
comment). Corrupted file comments are ignored too (there is one old
revision corrupted like that in the MariaDB/MySQL tree).
---
 contrib/remote-helpers/git-remote-bzr | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Show changes to contrib/remote-helpers/git-remote-bzr +16 −0
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 9abb58e..c659cf6 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -311,6 +311,22 @@ def export_branch(repo, name):
         else:
             author = committer
         msg = rev.message.encode('utf-8')
+        if rev.properties.has_key('file-info'):
+            from bzrlib import bencode
+            try:
+                files = bencode.bdecode(rev.properties['file-info'].encode('utf-8'))
+            except Exception, e:
+                warn ('file-info for revid:%s ignored, decoding error: %s', rev.revision_id, e)
+                files = ()
+
+            rmsg = msg.rstrip('\r\n ')
+            msg += '\n'
+            for file in files:
+              fmsg = file['message'].rstrip('\r\n ')
+              if fmsg != '' and fmsg != rmsg:
+                  msg += '\n%s:' % (file['path'],)
+                  for l in fmsg.split('\n'):
+                      msg += '\n  %s' % (l,)
 
         msg += '\n'
 
-- 
1.9.3

← back to recent threads