Skip to content

Commit 8d8e912

Browse files
get Mercurial information in a language-agnostic way
(fixes #56) Depending on the system's language, we can't rely on the output of `hg version` containing the string "Mercurial Distributed SCM".
1 parent 631fbf9 commit 8d8e912

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

src/ScmBackup/Scm/MercurialScm.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using ScmBackup.Http;
22
using System;
33
using System.IO;
4-
using System.Text.RegularExpressions;
54

65
namespace ScmBackup.Scm
76
{
@@ -37,7 +36,7 @@ public override bool IsOnThisComputer()
3736
{
3837
var result = this.ExecuteCommand("version");
3938

40-
if (result.Successful && result.StandardOutput.ToLower().Contains("mercurial distributed scm"))
39+
if (result.Successful && result.StandardOutput.ToLower().Contains("mercurial"))
4140
{
4241
return true;
4342
}
@@ -47,17 +46,11 @@ public override bool IsOnThisComputer()
4746

4847
public override string GetVersionNumber()
4948
{
50-
var result = this.ExecuteCommand("version");
49+
var result = this.ExecuteCommand("version -T {ver}");
5150

5251
if (result.Successful)
5352
{
54-
string pattern = @"mercurial distributed scm \(version (.*)\)";
55-
var regex = new Regex(pattern, RegexOptions.IgnoreCase);
56-
var match = regex.Match(result.StandardOutput);
57-
if (match.Success)
58-
{
59-
return match.Groups[1].ToString();
60-
}
53+
return result.StandardOutput;
6154
}
6255

6356
throw new InvalidOperationException(result.Output);

0 commit comments

Comments
 (0)