git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
SGSergei Golubchik <vuvova@gmail.com>
Date
May 15, 2014, 16:07 UTC
Message-ID
<20140515160704.GA6028@meddwl.wlan.t-mobile.hu>
>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(+)
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
Message 1 of 1 in “bzr per-file comments in git-remote-bzr”
  1. bzr per-file comments in git-remote-bzrSergei Golubchik, May 15, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.