Re: [RFC] scripts/get_maintainer.pl: also find maintainers fromMercurial (hg log)

From: Marti Raudsepp
Date: Mon Oct 26 2009 - 14:27:38 EST


On Mon, Oct 26, 2009 at 7:27 PM, Joe Perches <joe@xxxxxxxxxxx> wrote:
> What about using hg annotate for the git blame?
> hg annotate -c $file

Sure, I will get around to it once this patch is done.

'hg blame' without any arguments already gives the locally-unique
revision number which can be input to 'hg log -r ####' like the git
revhash. I think this would be the way to go.

> Is there an hg annotate select line range capability?

No, but -l adds line numbers to output, so it can be filtered in Perl.

> I'm not a user of hg. I did:
> hg annotate -c -l README
> and the output line numbering style isn't clear to me.

It seems they reflect the line number in the original revision, the
documentation isn't clear on this; I will investigate it.
I guess we can get the real line number using a counter anyway.

> Maybe it's better not to introduce more arguments.
> Would it be acceptable to use --git instead of --hg
> and just execute hg if .git wasn't available but .hg
> was? Basically just consider --git the equivalent of
> --vcs and execute whatever vcs system was supported?
>
> Or maybe just add --vcs instead of --hg so that
> the perforce/cvs/svn/darcs/VisualSourceSafe/etc users
> could be happy in the future too...

I'm split on this. At first it seems adding a --vcs as an alias to --git
would make the most sense.

But that's confusing because there already is a --scm option. Also
renaming all existing --git-* options doesn't sound like a good idea.

Since will do the right thing by default, sticking with --git/--nogit
might be the best way to go.

Marti

---
scripts/get_maintainer.pl: also find maintainers from Mercurial (hg log)

When a .git directory doesn't exist, get_maintainer now tries to use Mercurial
instead.

The --nogit option also disables Mercurial.

Signed-off-by: Marti Raudsepp <marti@xxxxxxxxx>

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -30,6 +30,7 @@
my $email_git_min_percent = 5;
my $email_git_since = "1-year-ago";
my $email_git_blame = 0;
+my $email_hg_date = "-365";
my $email_remove_duplicates = 1;
my $output_multiline = 1;
my $output_separator = ", ";
@@ -72,6 +73,7 @@
'git-min-percent=i' => \$email_git_min_percent,
'git-since=s' => \$email_git_since,
'git-blame!' => \$email_git_blame,
+ 'hg-date=s' => \$email_hg_date,
'remove-duplicates!' => \$email_remove_duplicates,
'm!' => \$email_maintainer,
'n!' => \$email_usename,
@@ -278,7 +280,7 @@
}

if ($email && $email_git) {
- recent_git_signoffs($file);
+ recent_vcs_signoffs($file);
}

if ($email && $email_git_blame) {
@@ -360,13 +362,14 @@

MAINTAINER field selection options:
--email => print email address(es) if any
- --git => include recent git \*-by: signers
+ --git => include recent git or hg \*-by: signers
--git-chief-penguins => include ${penguin_chiefs}
--git-min-signatures => number of signatures required (default: 1)
--git-max-maintainers => maximum maintainers to add (default: 5)
--git-min-percent => minimum percentage of commits required (default: 5)
--git-since => git history to use (default: 1-year-ago)
--git-blame => use git blame to find modified commits for patch or file
+ --hg-date => hg history to use (default: -365)
--m => include maintainer(s) if any
--n => include name 'Full Name <addr\@domain.tld>'
--l => include list(s) if any
@@ -661,7 +664,7 @@
return @lines;
}

-sub recent_git_signoffs {
+sub recent_vcs_signoffs {
my ($file) = @_;

my $sign_offs = "";
@@ -672,18 +675,26 @@
my %hash;
my $total_sign_offs;

- if (which("git") eq "") {
- warn("$P: git not found. Add --nogit to options?\n");
- return;
- }
- if (!(-d ".git")) {
- warn("$P: .git directory not found. Use a git repository for better results.\n");
+ if (-d ".git") {
+ if (which("git") eq "") {
+ warn("$P: found .git directory but git is not installed. Use --nogit?\n");
+ return;
+ }
+
+ $cmd = "git log --since=${email_git_since} -- ${file}";
+ } elsif (-d ".hg") {
+ if (which("hg") eq "") {
+ warn("$P: found .hg directory but Mercurial is not installed. Use --nogit?\n");
+ return;
+ }
+
+ $cmd = "hg log --date=${email_hg_date} --template='{desc}\\n' -- ${file}";
+ } else {
+ warn("$P: .git or .hg directory not found. Use a git repository for better results.\n");
warn("$P: perhaps 'git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git'\n");
return;
}

- $cmd = "git log --since=${email_git_since} -- ${file}";
-
$output = `${cmd}`;
$output =~ s/^\s*//gm;



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/