{"thread":{"id":"11081","subject":"[PATCH] hg-to-git: do not include the branch name as the first line of commit msg","startedAt":"2007-12-01T17:56:06Z","lastAt":"2007-12-06T14:36:43Z","messageCount":4,"participants":["Mark Drago","Junio C Hamano","Stelian Pop","Baz"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"61591","messageId":"4751A036.1080209@gmail.com","threadId":"11081","inReplyTo":null,"subject":"[PATCH] hg-to-git: do not include the branch name as the first line of commit msg","fromName":"Mark Drago","fromEmail":"markdrago@gmail.com","sentAt":"2007-12-01T17:56:06Z","receivedAt":"2007-12-01T17:56:06Z","isPatch":true,"sender":{"key":"markdrago@gmail.com","avatar":"https://gravatar.com/avatar/44978f3f99c6ac0e3f95f9a6be0846a07005d7ce1fd17a28d175f745b4401e6d?d=mp&s=160"},"body":"Signed-off-by: Mark Drago <markdrago@gmail.com>\n---\n contrib/hg-to-git/hg-to-git.py |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py\nindex 7a1c3e4..6bff49b 100755\n--- a/contrib/hg-to-git/hg-to-git.py\n+++ b/contrib/hg-to-git/hg-to-git.py\n@@ -158,7 +158,7 @@ for cset in range(int(tip) + 1):\n         mparent = None\n \n     (fdcomment, filecomment) = tempfile.mkstemp()\n-    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()\n+    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag: | grep -v ^branch:' % cset).read().strip()\n     os.write(fdcomment, csetcomment)\n     os.close(fdcomment)\n \n-- \n1.5.2.4\n"},{"id":"61847","messageId":"7vsl2jcl32.fsf@gitster.siamese.dyndns.org","threadId":"11081","inReplyTo":"4751A036.1080209@gmail.com","subject":"Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-12-04T01:20:01Z","receivedAt":"2007-12-04T01:20:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mark Drago <markdrago@gmail.com> writes:\n\n> Signed-off-by: Mark Drago <markdrago@gmail.com>\n> ---\n>  contrib/hg-to-git/hg-to-git.py |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py\n> index 7a1c3e4..6bff49b 100755\n> --- a/contrib/hg-to-git/hg-to-git.py\n> +++ b/contrib/hg-to-git/hg-to-git.py\n> @@ -158,7 +158,7 @@ for cset in range(int(tip) + 1):\n>          mparent = None\n>  \n>      (fdcomment, filecomment) = tempfile.mkstemp()\n> -    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()\n> +    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag: | grep -v ^branch:' % cset).read().strip()\n>      os.write(fdcomment, csetcomment)\n>      os.close(fdcomment)\n\nIsn't this one of the ugliest lines in the whole git.git project, I have\nto wonder?\n\nI also wonder missing colon after \"date\" is a bug from the original\nversion, and assuming that it is, how about doing something less error\nprone like this?\n\n        def included(line):\n            keywords = ('changeset', 'parent', 'user', 'date', 'files',\n                        'description', 'tag', 'branch')\n            for kw in keywords:\n                if line.startswith(kw + ':'):\n                    return 0\n            return 1\n\n        hglog = os.popen('hg log -r %d -v' % cset).read();\n        csetcomment = '\\n'.join(filter(included, hglog.split('\\n'))).strip()\n\nIf you are excluding _all_ of the <word>: header lines, the \"included\"\nfunction may have to become cleverer but much simpler by doing something\nlike:\n\n\timport re\n\theader_re = re.compile(r'^\\w+:')\n\tdef included(line):\n        \treturn not header_re.match(line)\n"},{"id":"62147","messageId":"1196949043.5388.18.camel@galileo","threadId":"11081","inReplyTo":"7vsl2jcl32.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg","fromName":"Stelian Pop","fromEmail":"stelian@popies.net","sentAt":"2007-12-06T13:50:43Z","receivedAt":"2007-12-06T13:50:43Z","isPatch":true,"sender":{"key":"stelian@popies.net","avatar":"https://gravatar.com/avatar/c99e49c3b3d851deb85e4557b368712c890a09985211f183bd151f8ab6357c03?d=mp&s=160"},"body":"\nLe lundi 03 décembre 2007 à 17:20 -0800, Junio C Hamano a écrit :\n\n> >      (fdcomment, filecomment) = tempfile.mkstemp()\n> > -    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()\n> > +    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag: | grep -v ^branch:' % cset).read().strip()\n> >      os.write(fdcomment, csetcomment)\n> >      os.close(fdcomment)\n> \n> Isn't this one of the ugliest lines in the whole git.git project, I have\n> to wonder?\n\nIt probably is, and I take full resposibility for the original\nversion :). Incremental development woes.\n\n> I also wonder missing colon after \"date\" is a bug from the original\n> version, and assuming that it is, \n\nIt is indeed a bug.\n\n> how about doing something less error\n> prone like this?\n> \n>         def included(line):\n>             keywords = ('changeset', 'parent', 'user', 'date', 'files',\n>                         'description', 'tag', 'branch')\n>             for kw in keywords:\n>                 if line.startswith(kw + ':'):\n>                     return 0\n>             return 1\n> \n>         hglog = os.popen('hg log -r %d -v' % cset).read();\n>         csetcomment = '\\n'.join(filter(included, hglog.split('\\n'))).strip()\n\nSeems great to me.\n\n> If you are excluding _all_ of the <word>: header lines, the \"included\"\n> function may have to become cleverer but much simpler by doing something\n> like:\n> \n> \timport re\n> \theader_re = re.compile(r'^\\w+:')\n> \tdef included(line):\n>         \treturn not header_re.match(line)\n\nI'm afraid something like this will be much more prone to false\npositives. \n\nMaybe an even better alternative, given the way mercurial outputs the\nchangeset information, is to search for the '^description:' tag and take\nall the text that follows.\n\n-- \nStelian Pop <stelian@popies.net>\n"},{"id":"62152","messageId":"2faad3050712060636i5eab2169vc4588c075fcd73f1@mail.gmail.com","threadId":"11081","inReplyTo":"1196949043.5388.18.camel@galileo","subject":"Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg","fromName":"Baz","fromEmail":"brian.ewins@gmail.com","sentAt":"2007-12-06T14:36:43Z","receivedAt":"2007-12-06T14:36:43Z","isPatch":true,"sender":{"key":"brian.ewins@gmail.com","avatar":"https://gravatar.com/avatar/9ac03d89105e50a7151e695a1b4b1228151064ec3ac380a73b74ab397796baf7?d=mp&s=160"},"body":"On Dec 6, 2007 1:50 PM, Stelian Pop <stelian@popies.net> wrote:\n>\n> Le lundi 03 décembre 2007 à 17:20 -0800, Junio C Hamano a écrit :\n>\n> > >      (fdcomment, filecomment) = tempfile.mkstemp()\n> > > -    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag:' % cset).read().strip()\n> > > +    csetcomment = os.popen('hg log -r %d -v | grep -v ^changeset: | grep -v ^parent: | grep -v ^user: | grep -v ^date | grep -v ^files: | grep -v ^description: | grep -v ^tag: | grep -v ^branch:' % cset).read().strip()\n> > >      os.write(fdcomment, csetcomment)\n> > >      os.close(fdcomment)\n> >\n> > Isn't this one of the ugliest lines in the whole git.git project, I have\n> > to wonder?\n>\n> It probably is, and I take full resposibility for the original\n> version :). Incremental development woes.\n>\n> > I also wonder missing colon after \"date\" is a bug from the original\n> > version, and assuming that it is,\n>\n> It is indeed a bug.\n>\n> > how about doing something less error\n> > prone like this?\n> >\n> >         def included(line):\n> >             keywords = ('changeset', 'parent', 'user', 'date', 'files',\n> >                         'description', 'tag', 'branch')\n> >             for kw in keywords:\n> >                 if line.startswith(kw + ':'):\n> >                     return 0\n> >             return 1\n> >\n> >         hglog = os.popen('hg log -r %d -v' % cset).read();\n> >         csetcomment = '\\n'.join(filter(included, hglog.split('\\n'))).strip()\n>\n> Seems great to me.\n>\n> > If you are excluding _all_ of the <word>: header lines, the \"included\"\n> > function may have to become cleverer but much simpler by doing something\n> > like:\n> >\n> >       import re\n> >       header_re = re.compile(r'^\\w+:')\n> >       def included(line):\n> >               return not header_re.match(line)\n>\n> I'm afraid something like this will be much more prone to false\n> positives.\n>\n> Maybe an even better alternative, given the way mercurial outputs the\n> changeset information, is to search for the '^description:' tag and take\n> all the text that follows.\n\nWould it not be better to use hg log --template to output only the\ninformation needed?\neg\n\ndate = os.popen('hg log -r %d --template \"{date|isodate}\"' %\ncset).read().strip()\n... or even just create a template to pull in everything needed in a\nsingle popen.\n\n-Baz\n\n>\n> --\n> Stelian Pop <stelian@popies.net>\n>\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"}]}