{"thread":{"id":"36667","subject":"[PATCH] bzr per-file comments in git-remote-bzr","startedAt":"2014-05-15T16:07:04Z","lastAt":"2014-05-15T16:07:04Z","messageCount":1,"participants":["Sergei Golubchik"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"241688","messageId":"20140515160704.GA6028@meddwl.wlan.t-mobile.hu","threadId":"36667","inReplyTo":null,"subject":"[PATCH] bzr per-file comments in git-remote-bzr","fromName":"Sergei Golubchik","fromEmail":"vuvova@gmail.com","sentAt":"2014-05-15T16:07:04Z","receivedAt":"2014-05-15T16:07:04Z","isPatch":true,"sender":{"key":"vuvova@gmail.com","avatar":null},"body":">From 7fd7360ef5b4f453ceb8e32b18f73f9fbcaa95b7 Mon Sep 17 00:00:00 2001\nFrom: Sergei Golubchik <vuvova@gmail.com>\nDate: Thu, 15 May 2014 17:50:16 +0200\nSubject: [PATCH] git-remote-bzr: support bzr per-file comments\n\nBazaar supports per-file comments in revisions - using bzr-gtk one can\nwrite a global revisions comment and comments for individual files too\n(this was apparently modelled after a similar feature in BitKeeper).\nWhen exporting a bzr repository to git these file comments are lost.\n\nThis patch makes them to be not lost but appear as a part of the commit\ncomment instead. Empty file comments and file comments identical to the\ncommit comment are skipped (they add no value as a part of the commit\ncomment). Corrupted file comments are ignored too (there is one old\nrevision corrupted like that in the MariaDB/MySQL tree).\n---\n contrib/remote-helpers/git-remote-bzr | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr\nindex 9abb58e..c659cf6 100755\n--- a/contrib/remote-helpers/git-remote-bzr\n+++ b/contrib/remote-helpers/git-remote-bzr\n@@ -311,6 +311,22 @@ def export_branch(repo, name):\n         else:\n             author = committer\n         msg = rev.message.encode('utf-8')\n+        if rev.properties.has_key('file-info'):\n+            from bzrlib import bencode\n+            try:\n+                files = bencode.bdecode(rev.properties['file-info'].encode('utf-8'))\n+            except Exception, e:\n+                warn ('file-info for revid:%s ignored, decoding error: %s', rev.revision_id, e)\n+                files = ()\n+\n+            rmsg = msg.rstrip('\\r\\n ')\n+            msg += '\\n'\n+            for file in files:\n+              fmsg = file['message'].rstrip('\\r\\n ')\n+              if fmsg != '' and fmsg != rmsg:\n+                  msg += '\\n%s:' % (file['path'],)\n+                  for l in fmsg.split('\\n'):\n+                      msg += '\\n  %s' % (l,)\n \n         msg += '\\n'\n \n-- \n1.9.3\n"}]}