open-src/common/set-elf-comments.pl
changeset 970 272328fe1b4a
parent 943 294f64612d23
child 994 ebd9341332ef
--- a/open-src/common/set-elf-comments.pl	Wed Jun 30 14:10:39 2010 -0700
+++ b/open-src/common/set-elf-comments.pl	Fri Jul 02 21:03:57 2010 -0700
@@ -56,8 +56,9 @@
   my $build_version_file = $opts{'B'};
 
   if ($build_version_file eq 'hg id') {
+    my $hg_id = 'revision unavailable';
     if (exists $ENV{'XBUILD_HG_ID'}) {
-      $build_info = $ENV{'XBUILD_HG_ID'};
+      $hg_id = $ENV{'XBUILD_HG_ID'};
     } else {
       open my $VERS, '-|', $build_version_file
 	or die "Can't run $build_version_file: $!\n";
@@ -65,11 +66,17 @@
       while ($_ = <$VERS>) {
 	chomp($_);
 	if ($_ =~ m/\S+/) {
-	  $build_info = "hg: $_ - " . $build_info;
+	  my ($rev, $tag) = split(' ', $_, 2);
+	  if ($tag eq 'tip') {
+	    $hg_id = $rev;
+	  } else {
+	    $hg_id = $_;
+	  }
 	}
       }
       close $VERS;
     }
+    $build_info = "hg: $hg_id - $build_info";
   } else {
     open my $VERS, '<', $build_version_file
       or die "Can't open $build_version_file for reading: $!\n";