git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hg-to-git: do not include the branch name as the first line of commit msg
@ 2007-12-01 17:56 Mark Drago
  2007-12-04  1:20 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Drago @ 2007-12-01 17:56 UTC (permalink / raw)
  To: stelian, gitster; +Cc: git

Signed-off-by: Mark Drago <markdrago@gmail.com>
---
 contrib/hg-to-git/hg-to-git.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
index 7a1c3e4..6bff49b 100755
--- a/contrib/hg-to-git/hg-to-git.py
+++ b/contrib/hg-to-git/hg-to-git.py
@@ -158,7 +158,7 @@ for cset in range(int(tip) + 1):
         mparent = None
 
     (fdcomment, filecomment) = tempfile.mkstemp()
-    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()
+    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()
     os.write(fdcomment, csetcomment)
     os.close(fdcomment)
 
-- 
1.5.2.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg
  2007-12-01 17:56 [PATCH] hg-to-git: do not include the branch name as the first line of commit msg Mark Drago
@ 2007-12-04  1:20 ` Junio C Hamano
  2007-12-06 13:50   ` Stelian Pop
  0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2007-12-04  1:20 UTC (permalink / raw)
  To: Mark Drago; +Cc: stelian, gitster, git

Mark Drago <markdrago@gmail.com> writes:

> Signed-off-by: Mark Drago <markdrago@gmail.com>
> ---
>  contrib/hg-to-git/hg-to-git.py |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/contrib/hg-to-git/hg-to-git.py b/contrib/hg-to-git/hg-to-git.py
> index 7a1c3e4..6bff49b 100755
> --- a/contrib/hg-to-git/hg-to-git.py
> +++ b/contrib/hg-to-git/hg-to-git.py
> @@ -158,7 +158,7 @@ for cset in range(int(tip) + 1):
>          mparent = None
>  
>      (fdcomment, filecomment) = tempfile.mkstemp()
> -    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()
> +    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()
>      os.write(fdcomment, csetcomment)
>      os.close(fdcomment)

Isn't this one of the ugliest lines in the whole git.git project, I have
to wonder?

I also wonder missing colon after "date" is a bug from the original
version, and assuming that it is, how about doing something less error
prone like this?

        def included(line):
            keywords = ('changeset', 'parent', 'user', 'date', 'files',
                        'description', 'tag', 'branch')
            for kw in keywords:
                if line.startswith(kw + ':'):
                    return 0
            return 1

        hglog = os.popen('hg log -r %d -v' % cset).read();
        csetcomment = '\n'.join(filter(included, hglog.split('\n'))).strip()

If you are excluding _all_ of the <word>: header lines, the "included"
function may have to become cleverer but much simpler by doing something
like:

	import re
	header_re = re.compile(r'^\w+:')
	def included(line):
        	return not header_re.match(line)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg
  2007-12-04  1:20 ` Junio C Hamano
@ 2007-12-06 13:50   ` Stelian Pop
  2007-12-06 14:36     ` Baz
  0 siblings, 1 reply; 4+ messages in thread
From: Stelian Pop @ 2007-12-06 13:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Mark Drago, git


Le lundi 03 décembre 2007 à 17:20 -0800, Junio C Hamano a écrit :

> >      (fdcomment, filecomment) = tempfile.mkstemp()
> > -    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()
> > +    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()
> >      os.write(fdcomment, csetcomment)
> >      os.close(fdcomment)
> 
> Isn't this one of the ugliest lines in the whole git.git project, I have
> to wonder?

It probably is, and I take full resposibility for the original
version :). Incremental development woes.

> I also wonder missing colon after "date" is a bug from the original
> version, and assuming that it is, 

It is indeed a bug.

> how about doing something less error
> prone like this?
> 
>         def included(line):
>             keywords = ('changeset', 'parent', 'user', 'date', 'files',
>                         'description', 'tag', 'branch')
>             for kw in keywords:
>                 if line.startswith(kw + ':'):
>                     return 0
>             return 1
> 
>         hglog = os.popen('hg log -r %d -v' % cset).read();
>         csetcomment = '\n'.join(filter(included, hglog.split('\n'))).strip()

Seems great to me.

> If you are excluding _all_ of the <word>: header lines, the "included"
> function may have to become cleverer but much simpler by doing something
> like:
> 
> 	import re
> 	header_re = re.compile(r'^\w+:')
> 	def included(line):
>         	return not header_re.match(line)

I'm afraid something like this will be much more prone to false
positives. 

Maybe an even better alternative, given the way mercurial outputs the
changeset information, is to search for the '^description:' tag and take
all the text that follows.

-- 
Stelian Pop <stelian@popies.net>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hg-to-git: do not include the branch name as the first line of commit msg
  2007-12-06 13:50   ` Stelian Pop
@ 2007-12-06 14:36     ` Baz
  0 siblings, 0 replies; 4+ messages in thread
From: Baz @ 2007-12-06 14:36 UTC (permalink / raw)
  To: Stelian Pop; +Cc: Junio C Hamano, Mark Drago, git

On Dec 6, 2007 1:50 PM, Stelian Pop <stelian@popies.net> wrote:
>
> Le lundi 03 décembre 2007 à 17:20 -0800, Junio C Hamano a écrit :
>
> > >      (fdcomment, filecomment) = tempfile.mkstemp()
> > > -    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()
> > > +    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()
> > >      os.write(fdcomment, csetcomment)
> > >      os.close(fdcomment)
> >
> > Isn't this one of the ugliest lines in the whole git.git project, I have
> > to wonder?
>
> It probably is, and I take full resposibility for the original
> version :). Incremental development woes.
>
> > I also wonder missing colon after "date" is a bug from the original
> > version, and assuming that it is,
>
> It is indeed a bug.
>
> > how about doing something less error
> > prone like this?
> >
> >         def included(line):
> >             keywords = ('changeset', 'parent', 'user', 'date', 'files',
> >                         'description', 'tag', 'branch')
> >             for kw in keywords:
> >                 if line.startswith(kw + ':'):
> >                     return 0
> >             return 1
> >
> >         hglog = os.popen('hg log -r %d -v' % cset).read();
> >         csetcomment = '\n'.join(filter(included, hglog.split('\n'))).strip()
>
> Seems great to me.
>
> > If you are excluding _all_ of the <word>: header lines, the "included"
> > function may have to become cleverer but much simpler by doing something
> > like:
> >
> >       import re
> >       header_re = re.compile(r'^\w+:')
> >       def included(line):
> >               return not header_re.match(line)
>
> I'm afraid something like this will be much more prone to false
> positives.
>
> Maybe an even better alternative, given the way mercurial outputs the
> changeset information, is to search for the '^description:' tag and take
> all the text that follows.

Would it not be better to use hg log --template to output only the
information needed?
eg

date = os.popen('hg log -r %d --template "{date|isodate}"' %
cset).read().strip()
... or even just create a template to pull in everything needed in a
single popen.

-Baz

>
> --
> Stelian Pop <stelian@popies.net>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-06 14:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-01 17:56 [PATCH] hg-to-git: do not include the branch name as the first line of commit msg Mark Drago
2007-12-04  1:20 ` Junio C Hamano
2007-12-06 13:50   ` Stelian Pop
2007-12-06 14:36     ` Baz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).