hg-to-git: do not include the branch name as the first line of commit msg
PATCH 1/1 hg-to-git: do not include the branch name as the first line of commit msg
--- contrib/hg-to-git/hg-to-git.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
contrib/hg-to-git/hg-to-git.py +1 -1
@@ -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)
Signature · 1 line
1.5.2.4
Quoted 10 lines · Mark Drago
Signed-off-by Mark Drago <[email protected]>--- contrib/hg-to-git/hg-to-git.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)contrib/hg-to-git/hg-to-git.py +0
-0
contrib/hg-to-git/hg-to-git.py for cset in range(int(tip) + 1): · line 163
Quoted 7 lines
contrib/hg-to-git/hg-to-git.py +1
-1@@ -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)Quoted 8 lines · Junio C Hamano
contrib/hg-to-git/hg-to-git.py for cset in range(int(tip) + 1): · line 163
Quoted 5 lines
(fdcomment, filecomment) =
tempfile.mkstemp()contrib/hg-to-git/hg-to-git.py +1
-1- 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.
Quoted 2 lines
I also wonder missing colon after "date" is a bug from the original version, and assuming that it is,
It is indeed a bug.
Quoted 13 lines
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.
Quoted 8 lines
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.
Signature · 1 line
Stelian Pop <[email protected]>
Quoted 45 lines · Stelian Pop
Quoted 8 lines · Junio C Hamano
contrib/hg-to-git/hg-to-git.py for cset in range(int(tip) + 1): · line 163
Quoted 5 lines
(fdcomment, filecomment) =
tempfile.mkstemp()contrib/hg-to-git/hg-to-git.py +1
-1- 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.
Quoted 2 lines
I also wonder missing colon after "date" is a bug from the original version, and assuming that it is,
It is indeed a bug.
Quoted 13 lines
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.
Quoted 8 lines
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 notheader_re.match(line)
Quoted 6 lines
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
Quoted 10 lines
--
Stelian Pop <[email protected]>-
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html