Commits

Palmer, 2E0EOL committed 2fde7c1

Write function to retrieve history.

Comments (0)

Files changed (1)

 use warnings;
 use diagnostics;
 use boolean;
+use Data::Dumper;
 
 use constant BRANCH_MAINLINE => 'develop';
 use constant BRANCH_DEFAULT  => 'default';
 	return $found;
 }
 
+sub GetHistory(@)
+{
+	my %history = ( );
+	my %Params = ( );
+	my $changeset = '0' x 12;
+
+	%Params = @_ if ( scalar(@_) && (scalar(@_) % 2 == 0) );
+	my $b = $Params{'Branch'} || '.'; # . means 'this' branch
+	my @rawLog = `hg log -b $b`;
+	foreach my $logLine ( @rawLog ) {
+		chomp($logLine);
+		printf("Line: %s\n", $logLine);
+		if ( $logLine =~ m/^(\w+):\s+(.*)$/ ) {
+			if ( $1 eq 'changeset' ) { # New changeset?
+				$changeset = $2;
+				next;
+			}
+			$history{$changeset}->{$1} = $2;
+		}
+	}
+	return %history;
+}
+
 sub Main()
 {
 	my $b = $ARGV[0] || GetWSNamedBranchName();
 		printf(STDERR "Warning: It is atypical to test whether the %s branch is merged\n", BRANCH_DEFAULT());
 	}
 
-	if ( NamedBranchExists($b) ) {
-		printf("Yes, the branch %s exists\n", $b);
-	} else {
-		printf("No, the branch %s, doesn\'t exist\n", $b);
+	if ( !NamedBranchExists($b) ) {
+		printf(STDERR "ERROR: The branch \'%s\' is not in the repository\n", $b);
+		return 2;
 	}
+
+	my %history = GetHistory(Branch => $b);
+	warn Dumper \%history;
 }
 exit(Main());