You forgot to document your option. (And possibly write a testcase.)
I am not sure if this is generic enough to be in git-svn.perl itself, or
perhaps there should be a hook make_log_entry() would call in the form of
some Perl scriptlet given by the user to munge $log_entry{log}, which
would be very specific to each project.
From: Jan Nieuwenhuizen <hidden> Date: 2016-06-15 22:45:06
On za, 2008-08-02 at 10:36 -0700, Junio C Hamano wrote:
quoted
You forgot to document your option. (And possibly write a testcase.)
I am not sure if this is generic enough to be in git-svn.perl itself, or
perhaps there should be a hook make_log_entry() would call in the form of
some Perl scriptlet given by the user to munge $log_entry{log}, which
would be very specific to each project.
If you're not sure, please make up your mind. I agree it's quite a hack
but now it's in the archives for others to find. Doing this in a single
regexp is a bit tricky and asking a user to write a perl snippet is even
worse, imho. Especially if would turn out that stripping changelog bits
is the only thing that the hook is getting used for, in the end. I have
gotten more careful to provide generic solutions to specific problems in
anticipation of possible future desires.
I could imagine that leaving git-svn alone and adding a hook to git-log
would be more useful, though.
Jan.
--
Jan Nieuwenhuizen [off-list ref] | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
From: Junio C Hamano <hidden> Date: 2016-06-15 22:45:06
Jan Nieuwenhuizen [off-list ref] writes:
On za, 2008-08-02 at 10:36 -0700, Junio C Hamano wrote:
quoted
quoted
You forgot to document your option. (And possibly write a testcase.)
I am not sure if this is generic enough to be in git-svn.perl itself, or
perhaps there should be a hook make_log_entry() would call in the form of
some Perl scriptlet given by the user to munge $log_entry{log}, which
would be very specific to each project.
If you're not sure, please make up your mind.
That's something you would say when I cannot decide the color of
bikeshed. I do not think your change falls into that category.
We could add an ad-hoc preprocessing option like this, and keep adding
more for different patterns, and at certain point we may be fed up with
millions of such options and try to introduce a more generic mechanism.
While doing so, the resulting code needs to support the ad-hoc ones that
are added earlier, forever.
We've done that in the past with other commands (cc-suppression scheme in
send-email comes to mind). It was very unpleasant.
... Doing this in a single
regexp is a bit tricky and asking a user to write a perl snippet is even
worse, imho.
What you are saying is that a built-in one, no matter what, won't be
sufficient for many projects. Unless a user writes Perl snippet to match
his project's needs, the noise at the beginning of the log won't be
stripped for him.
That's fine. I do not expect a single built-in transformation would fit
everybody's needs. I am not asking for miracles.
But you could at least keep the door open for people who are _willing_ to
write such transformation for their projects, right?
For one thing, your --cut-changelog-bits has one fixed pattern. Later
people either have to come up with different option, or modify your
pattern (potentially breaking your project). Neither is good.
Perhaps doing something like this a (admittedly slightly) better option?
It allows you to choose from a canned set, or give a series of s///
rewriting rules (or whatever you would want to have in the custom function)..
---
git-svn.perl | 34 +++++++++++++++++++++++++++++++++-
1 files changed, 33 insertions(+), 1 deletions(-)
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,$_version,$_fetch_all,$_no_rebase,$_merge,$_strategy,$_dry_run,$_local,$_prefix,$_no_checkout,$_url,$_verbose,-$_git_format);+$_git_format,$_clean_changelog,$_clean_log_message);$Git::SVN::_follow_parent=1;my%remote_opts=('username=s'=>\$Git::SVN::Prompt::_username,'config-dir=s'=>\$Git::SVN::Ra::config_dir,
@@ -109,9 +109,11 @@ my %cmd = (fetch=>[\&cmd_fetch,"Download new revisions from SVN",{'revision|r=s'=>\$_revision,'fetch-all|all'=>\$_fetch_all,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts}],clone=>[\&cmd_clone,"Initialize and fetch revisions",{'revision|r=s'=>\$_revision,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts,%init_opts}],init=>[\&cmd_init,"Initialize a repo for tracking"." (requires URL argument)",
@@ -238,6 +240,33 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,$Git::SVN::default_repo_id=$_[1]});exit1if(!$rv&&$cmd&&$cmdne'log');+my%canned_changelog_cleaner=+(+'ooo'=>sub{+local($_)=@_;+s/(^|\n)\s*((\n|\s)*(199[0-9]|20[0-1][0-9])(-[0-9]{2}){2}\s+.*<.*>\s*\n\s+)?/$1/g;+s/(^|\n)\* /\n$1/g;+s/^[\n\s]*//;+s/\n\s*/ /giflength($_)<81;+"\n";+}+);++if(defined$_clean_changelog){+if(exists$canned_changelog_cleaner{$_clean_changelog}){+$_clean_log_message=$canned_changelog_cleaner{$_clean_changelog};+}elsif($_clean_changelogne''){+$_clean_log_message=eval"+sub{local(\$_)=\@_;$_clean_changelog;return\$_;}+";+if($@){+die"$!: $_clean_changelog";+}+}else{+die"$_clean_changelog: unknown way to clean log message";+}+}+usage(0)if$_help;version()if$_version;usage(1)unlessdefined$cmd;
@@ -2463,6 +2492,9 @@ sub make_log_entry {close$unorcroak$!;$log_entry{date}=parse_svn_date($log_entry{date});+if($_clean_log_message){+$log_entry{log}=$_clean_log_message->($log_entry{log});+}$log_entry{log}.="\n";my$author=$log_entry{author}=check_author($log_entry{author});my($name,$email)=defined$::users{$author}?@{$::users{$author}}
From: Jan Nieuwenhuizen <hidden> Date: 2016-06-15 22:45:06
On za, 2008-08-02 at 14:13 -0700, Junio C Hamano wrote:
Perhaps doing something like this a (admittedly slightly) better option?
It allows you to choose from a canned set, or give a series of s///
rewriting rules (or whatever you would want to have in the custom function)..
Yes, this is (a bit) much nicer, thanks.
I fixed the function to actually return the log entry, renamed it to
'gnu', as it--although this is ooo's silly convention--is a GNU style
ChangeLog that is being stripped, added it to the 'rebase' command,
added some doco and a test.
Jan.
Signed-off-by: Jan Nieuwenhuizen <redacted>
---
Documentation/RelNotes-1.6.0.txt | 3 +
Documentation/git-svn.txt | 4 +
git-svn.perl | 36 ++++++++-
t/t9125-git-svn-clean-changelog.sh | 171 ++++++++++++++++++++++++++++++++++++
4 files changed, 213 insertions(+), 1 deletions(-)
create mode 100644 t/t9125-git-svn-clean-changelog.sh
@@ -206,6 +206,9 @@ Updates since v1.5.6 * "git-svn dcommit" is now aware of auto-props setting the subversion user has.+* git-svn can process changelog entries in order to produce nicer+ commit messages with the new option --clean-changelog=gnu.+ * You can tell "git status -u" to even more aggressively omit checking untracked files with --untracked-files=no.
@@ -118,6 +118,10 @@ accept. However, '--fetch-all' only fetches from the current Like 'git-rebase'; this requires that the working tree be clean and have no uncommitted changes.+--clean-changelog=gnu;;+ Manipulate SVN commit log messages to produce clean commit+ messages. Supported formats are: 'gnu', which strips+ GNU ChangeLog bits. -l;; --local;; Do not fetch remotely; only run 'git-rebase' against the
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,$_version,$_fetch_all,$_no_rebase,$_merge,$_strategy,$_dry_run,$_local,$_prefix,$_no_checkout,$_url,$_verbose,-$_git_format);+$_git_format,$_clean_changelog,$_clean_log_message);$Git::SVN::_follow_parent=1;my%remote_opts=('username=s'=>\$Git::SVN::Prompt::_username,'config-dir=s'=>\$Git::SVN::Ra::config_dir,
@@ -109,9 +109,11 @@ my %cmd = (fetch=>[\&cmd_fetch,"Download new revisions from SVN",{'revision|r=s'=>\$_revision,'fetch-all|all'=>\$_fetch_all,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts}],clone=>[\&cmd_clone,"Initialize and fetch revisions",{'revision|r=s'=>\$_revision,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts,%init_opts}],init=>[\&cmd_init,"Initialize a repo for tracking"." (requires URL argument)",
@@ -178,6 +180,7 @@ my %cmd = ('local|l'=>\$_local,'fetch-all|all'=>\$_fetch_all,'dry-run|n'=>\$_dry_run,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts}],'commit-diff'=>[\&cmd_commit_diff,'Commit a diff between two trees',
@@ -238,6 +241,34 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,$Git::SVN::default_repo_id=$_[1]});exit1if(!$rv&&$cmd&&$cmdne'log');+my%canned_changelog_cleaner=+(+'gnu'=>sub{+local($_)=@_;+s/(^|\n)\s*((\n|\s)*(199[0-9]|20[0-1][0-9])(-[0-9]{2}){2}\s+.*<.*>\s*\n\s+)?/$1/g;+s/(^|\n)\* /\n$1/g;+s/^[\n\s]*//;+s/[\n\s]*$//;+s/\n\s*/ /giflength($_)<81;+$_."\n";+}+);++if(defined$_clean_changelog){+if(exists$canned_changelog_cleaner{$_clean_changelog}){+$_clean_log_message=$canned_changelog_cleaner{$_clean_changelog};+}elsif($_clean_changelogne''){+$_clean_log_message=eval"+sub{local(\$_)=\@_;$_clean_changelog;return\$_;}+";+if($@){+die"$!: $_clean_changelog";+}+}else{+die"$_clean_changelog: unknown way to clean log message";+}+}+usage(0)if$_help;version()if$_version;usage(1)unlessdefined$cmd;
@@ -2463,6 +2494,9 @@ sub make_log_entry {close$unorcroak$!;$log_entry{date}=parse_svn_date($log_entry{date});+if($_clean_log_message){+$log_entry{log}=$_clean_log_message->($log_entry{log});+}$log_entry{log}.="\n";my$author=$log_entry{author}=check_author($log_entry{author});my($name,$email)=defined$::users{$author}?@{$::users{$author}}
--
1.6.0.rc0.44.g67270
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
From: Junio C Hamano <hidden> Date: 2016-06-15 22:45:06
Jan Nieuwenhuizen [off-list ref] writes:
Documentation/RelNotes-1.6.0.txt | 3 +
Nice try, but after -rc1 we won't take feature enhancements on the
'master' branch. The earliest this will appear is in 1.6.1.
Thanks for clean-up, and starting tests, but I have a few more comments:
* Documentation; introduce this with heading --clean-changelog=<style>; I
kept the list of supported styles in-line, but we may later want to
have other supported styles at which time it might become easier to
read if it were a separate itemized list.
You seem to have taken the "arbitrary Perl snippet" part of my patch as
well, but it is not described here...
* Script; two separate _clean_changelog and _clean_log_message variables
are not necessary (I removed the extra variable in the patch below).
* Tests.
Your new tests do not seem to check these, but I think you should:
- what should happen without --clean-changelog=gnu? (iow, additional
code does not regress the behaviour when this shiny new toy is not
used).
- what should happen when an unknown style is given e.g. --clean-changelog=yak?
We prefer to use "test_cmp" for comparing expected and actual result,
not bare "cmp".
Here is what I tested and based the above comments on after minor fixes to
ask comments from Eric.
-- >8 --
From: Jan Nieuwenhuizen <redacted>
Subject: git-svn: --clean-changelog=<style> to sanitize messages
Some projects write ChangeLog entries and use those for Subverison commit
messages. Converting such a repository makes for a most uninteresting git
log --pretty=oneline output:
482cfc6... 2008-08-01 Kohei Yoshida [off-list ref]
90c16d7... 2008-08-01 Fong Lin [off-list ref] * patches/dev300/cws-npow
...
The --clean-changelog=<style> option can be used to remove useless bits
when reading log messages from Subversion side, to produce more readable
result:
44e7784... patches/dev300/apply: added upstream issue numbers to some of my p
1a19026... patches/dev300/cws-npower11.diff: Add vba events stuff.
...
Signed-off-by: Jan Nieuwenhuizen <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
Documentation/git-svn.txt | 4 +
git-svn.perl | 37 +++++++-
t/t9125-git-svn-clean-changelog.sh | 187 ++++++++++++++++++++++++++++++++++++
3 files changed, 227 insertions(+), 1 deletions(-)
create mode 100755 t/t9125-git-svn-clean-changelog.sh
@@ -118,6 +118,10 @@ accept. However, '--fetch-all' only fetches from the current Like 'git-rebase'; this requires that the working tree be clean and have no uncommitted changes.+--clean-changelog=<style>;;+ Manipulate SVN commit log messages to produce clean commit+ messages. Supported styles are: 'gnu', which strips+ GNU ChangeLog bits. -l;; --local;; Do not fetch remotely; only run 'git-rebase' against the
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,$_version,$_fetch_all,$_no_rebase,$_merge,$_strategy,$_dry_run,$_local,$_prefix,$_no_checkout,$_url,$_verbose,-$_git_format);+$_git_format,$_clean_changelog);$Git::SVN::_follow_parent=1;my%remote_opts=('username=s'=>\$Git::SVN::Prompt::_username,'config-dir=s'=>\$Git::SVN::Ra::config_dir,
@@ -109,9 +109,11 @@ my %cmd = (fetch=>[\&cmd_fetch,"Download new revisions from SVN",{'revision|r=s'=>\$_revision,'fetch-all|all'=>\$_fetch_all,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts}],clone=>[\&cmd_clone,"Initialize and fetch revisions",{'revision|r=s'=>\$_revision,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts,%init_opts}],init=>[\&cmd_init,"Initialize a repo for tracking"." (requires URL argument)",
@@ -178,6 +180,7 @@ my %cmd = ('local|l'=>\$_local,'fetch-all|all'=>\$_fetch_all,'dry-run|n'=>\$_dry_run,+'clean-changelog=s'=>\$_clean_changelog,%fc_opts}],'commit-diff'=>[\&cmd_commit_diff,'Commit a diff between two trees',
@@ -238,6 +241,35 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version,$Git::SVN::default_repo_id=$_[1]});exit1if(!$rv&&$cmd&&$cmdne'log');+my%canned_changelog_cleaner=+(+'gnu'=>sub{+local($_)=@_;+s/(^|\n)\s*((\n|\s)*(199[0-9]|20[0-1][0-9])(-[0-9]{2}){2}\s+.*<.*>\s*\n\s+)?/$1/g;+s/(^|\n)\* /\n$1/g;+s/^[\n\s]*//;+s/[\n\s]*$//;+s/\n\s*/ /giflength($_)<81;+$_."\n";+}+);++if(defined$_clean_changelog){+my$ccl=$_clean_changelog;+if(exists$canned_changelog_cleaner{$_clean_changelog}){+$_clean_changelog=$canned_changelog_cleaner{$_clean_changelog};+}elsif($_clean_changelogne''){+$_clean_changelog=eval"+sub{local(\$_)=\@_;$_clean_changelog;return\$_;}+";+if($@){+die"$!: $ccl";+}+}else{+die"$ccl: unknown way to clean log message";+}+}+usage(0)if$_help;version()if$_version;usage(1)unlessdefined$cmd;
@@ -2463,6 +2495,9 @@ sub make_log_entry {close$unorcroak$!;$log_entry{date}=parse_svn_date($log_entry{date});+if($_clean_changelog){+$log_entry{log}=$_clean_changelog->($log_entry{log});+}$log_entry{log}.="\n";my$author=$log_entry{author}=check_author($log_entry{author});my($name,$email)=defined$::users{$author}?@{$::users{$author}}
From: Eric Wong <hidden> Date: 2016-06-15 22:45:06
Jan Nieuwenhuizen [off-list ref] wrote:
On za, 2008-08-02 at 10:36 -0700, Junio C Hamano wrote:
quoted
quoted
You forgot to document your option. (And possibly write a testcase.)
I am not sure if this is generic enough to be in git-svn.perl itself, or
perhaps there should be a hook make_log_entry() would call in the form of
some Perl scriptlet given by the user to munge $log_entry{log}, which
would be very specific to each project.
If you're not sure, please make up your mind. I agree it's quite a hack
but now it's in the archives for others to find. Doing this in a single
regexp is a bit tricky and asking a user to write a perl snippet is even
worse, imho. Especially if would turn out that stripping changelog bits
is the only thing that the hook is getting used for, in the end. I have
gotten more careful to provide generic solutions to specific problems in
anticipation of possible future desires.
I could imagine that leaving git-svn alone and adding a hook to git-log
would be more useful, though.
NACK on modifying git-svn to support more changelog formats.
A better idea would be to write a generic script that takes "git log",
"git svn log" or even plain "svn log" output and filters it
independently.
This way existing projects don't have to be re-imported (a bad idea to
modify things SVN feeds us anyways), and plain svn users can benefit,
too.
This filter should be reusable for both plain svn and git-svn:
svn log | changelog-filter --input=svn --style=gnu
git svn log | changelog-filter --input=svn --style=gnu
git log --pretty=raw | changelog-filter --input=git-raw --style=gnu
However, I would support a generic --log-filter parameter in git-svn
that would have git-svn filter its output through any given command
before piping it to less.
git config svn.logFilter "changelog-filter --input=svn --style=gnu"
git svn log
or...
git svn log --log-filter="changelog-filter --input=svn --style=yak"
git svn log --log-filter="svn-log-to-LaTeX"
git svn log --log-filter="svn-log-to-HTML"
git svn log --log-filter="svn-log-to-XML"
git svn log --log-filter="svn-log-to-JSON"
git svn log --log-filter="svn-log-to-PNG" > log.png
git svn log --log-filter="svn-log-to-theora" > log.ogg
The possibilities are endless :)
--
Eric Wong
From: Jan Nieuwenhuizen <hidden> Date: 2016-06-15 22:45:06
On zo, 2008-08-03 at 19:09 -0700, Eric Wong wrote:
Jan Nieuwenhuizen [off-list ref] wrote:
quoted
I could imagine that leaving git-svn alone and adding a hook to git-log
would be more useful, though.
NACK on modifying git-svn to support more changelog formats.
A better idea would be to write a generic script that takes "git log",
"git svn log" or even plain "svn log" output and filters it
independently.
This filter should be reusable for both plain svn and git-svn:
The possibilities are endless :)
Yes, but we'll most probably drop SVN rsn, possibly after a short period
of supporting both; and not stripping the cruft in the conversion means
we carry this with us until eternity. Besides, who is going to
distribute the script, inform users about its availability?
What we have now suffices for our ooo-build conversion. If you do not
find it useful, more power/less code to you. Let others search the
archives and/or patch git-svn themselves, if indeed there are any.
Jan.
--
Jan Nieuwenhuizen [off-list ref] | GNU LilyPond - The music typesetter
http://www.xs4all.nl/~jantien | http://www.lilypond.org
From: Jan Nieuwenhuizen <hidden> Date: 2016-06-15 22:45:06
On zo, 2008-08-03 at 13:45 -0700, Junio C Hamano wrote:
Nice try, but after -rc1 we won't take feature enhancements on the
'master' branch. The earliest this will appear is in 1.6.1.
Ok, I'm not that familiar with git development and I did not find any
newer/UNRELEASED list of features?
* Documentation; introduce this with heading --clean-changelog=<style>; I
Ok. I tried ={gnu} first, which seems to be the style for multiple
choice arguments, but the document parser does not grok that. {gnu|foo}
or {gnu|no-other-yet} did not really please me.
You seem to have taken the "arbitrary Perl snippet" part of my patch as
well, but it is not described here...
It all depends upon how you read the future. I would most have chosen
to postpone that work until the second (or third) request for different
munging came in, but now that the code is already written...
* Script; two separate _clean_changelog and _clean_log_message variables
are not necessary (I removed the extra variable in the patch below).
Good, I didn't really look at that.
Your new tests do not seem to check these, but I think you should:
- what should happen without --clean-changelog=gnu? (iow, additional
code does not regress the behaviour when this shiny new toy is not
used).
We could add a test to make sure that git-svn does not alter commit
messages, but it has little to do with this patch.
If this is not being tested atm, it is probably not deemed important
enough to test. This could have regressed at any time.
I would add a test for existing working code only if experience tells
you it is fragile and it (often) regresses, ie, when you fix a bug:
new/revised code.
- what should happen when an unknown style is given e.g. --clean-changelog=yak?
It would be nice if the script failed with an error message, telling
what the options are, but I do not really care that much about wrong
use. You have that automatically if you use a sensible option parser,
this is where such a feature should be implemented, imho.
We prefer to use "test_cmp" for comparing expected and actual result,
not bare "cmp".
Ok.
Here is what I tested and based the above comments on after minor fixes to
ask comments from Eric.
From: Eric Wong <hidden> Date: 2016-06-15 22:45:06
Jan Nieuwenhuizen [off-list ref] wrote:
On zo, 2008-08-03 at 19:09 -0700, Eric Wong wrote:
quoted
Jan Nieuwenhuizen [off-list ref] wrote:
quoted
I could imagine that leaving git-svn alone and adding a hook to git-log
would be more useful, though.
NACK on modifying git-svn to support more changelog formats.
A better idea would be to write a generic script that takes "git log",
"git svn log" or even plain "svn log" output and filters it
independently.
quoted
This filter should be reusable for both plain svn and git-svn:
quoted
The possibilities are endless :)
Yes, but we'll most probably drop SVN rsn, possibly after a short period
of supporting both; and not stripping the cruft in the conversion means
we carry this with us until eternity. Besides, who is going to
distribute the script, inform users about its availability?
What we have now suffices for our ooo-build conversion. If you do not
find it useful, more power/less code to you. Let others search the
archives and/or patch git-svn themselves, if indeed there are any.
In the one-shot case, a git filter-branch script would probably be ideal
and reusable for other projects.
Anyways, I strongly believe changelog modification/reformatting should
be done in a more generic way that can benefit users of other tools
(archimport/cvsimport etc...), too.
--
Eric Wong