PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 1ms

/Examples/018 - Bisect.linq

#
Unknown | 52 lines | 44 code | 8 blank | 0 comment | 0 complexity | 103fcf8ab5f016676842bcb2f147cd42 MD5 | raw file
 1<Query Kind="Program">
 2  <Reference Relative="..\Mercurial.Net\bin\Debug\Mercurial.Net.dll">C:\dev\vs.net\Mercurial.Net\Mercurial.Net\bin\Debug\Mercurial.Net.dll</Reference>
 3  <Namespace>Mercurial</Namespace>
 4  <Namespace>Mercurial.Extensions.Churn</Namespace>
 5</Query>
 6
 7// *****************************************************
 8// *
 9// * This example shows how to do a bisection of a
10// * repository, to subdivide looking for the first
11// * good revision according to some test criteria.
12// *
13// ***********************
14
15void Main()
16{
17	var repoPath = @"C:\Temp\SomeOtherRepo";
18    var repo = new Repository(repoPath);
19    
20    repo.Bisect(BisectState.Reset);
21    
22    repo.Update(0);
23    repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
24    
25    repo.Update();
26    BisectResult result = repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
27    while (!result.Done)
28    {
29        Debug.WriteLine("at: " + result.Revision);
30        result = repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
31    }
32    Debug.WriteLine("found: " + result.Revision);
33    
34    repo.Log(result.Revision).Dump();
35}
36
37public BisectState GoodToBisectState(bool isGood)
38{
39    if (isGood)
40        return BisectState.Good;
41    else
42        return BisectState.Bad;
43}
44
45public bool IsCurrentChangesetGood(Repository repo)
46{
47    var revno = repo.Log(RevSpec.WorkingDirectoryParent).First().RevisionNumber;
48    if (revno == 0)
49        return false;
50    else
51        return true;
52}