summaryrefslogtreecommitdiff
path: root/v4l/scripts/prep_commit_msg.pl
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/scripts/prep_commit_msg.pl')
-rwxr-xr-xv4l/scripts/prep_commit_msg.pl27
1 files changed, 21 insertions, 6 deletions
diff --git a/v4l/scripts/prep_commit_msg.pl b/v4l/scripts/prep_commit_msg.pl
index a4594c7f9..f4047c6ba 100755
--- a/v4l/scripts/prep_commit_msg.pl
+++ b/v4l/scripts/prep_commit_msg.pl
@@ -5,16 +5,31 @@ my $autopatch = shift;
# Get Hg username from environment
my $user = $ENV{HGUSER};
-# Didn't work? Try the .hgrc file
-if ($user eq "") {
- open IN, "<$ENV{HOME}/.hgrc";
+sub hgrcuser($)
+{
+ my $file = shift;
+ my $ui = 0;
+ open IN, '<', $file;
while (<IN>) {
- if(/^\s*username\s*=\s*(\S.*)$/) {
- $user = $1;
- last;
+ $ui = 1 if (/^\s*\[ui\]/);
+ if ($ui && /^\s*username\s*=\s*(\S.*?)\s*$/) {
+ close IN;
+ return($1);
}
}
close IN;
+ return("");
+}
+
+# Didn't work? Try the repo's .hgrc file
+if ($user eq "") {
+ my $hgroot = `hg root`;
+ chomp($hgroot);
+ $user = hgrcuser("$hgroot/.hg/hgrc");
+}
+# Ok, try ~/.hgrc next
+if ($user eq "") {
+ $user = hgrcuser("$ENV{HOME}/.hgrc");
}
# Still no luck? Try some other environment variables