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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 7fd7360ef5b4f453ceb8e32b18f73f9fbcaa95b7 Mon Sep 17 00:00:00 2001
From: Sergei Golubchik <vuvova@xxxxxxxxx>
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(+)

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]