PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Examples/018 - Bisect.linq

#
Unknown | 52 lines | 44 code | 8 blank | 0 comment | 0 complexity | 103fcf8ab5f016676842bcb2f147cd42 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  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. // * This example shows how to do a bisection of a
  9. // * repository, to subdivide looking for the first
  10. // * good revision according to some test criteria.
  11. // *
  12. // ***********************
  13. void Main()
  14. {
  15. var repoPath = @"C:\Temp\SomeOtherRepo";
  16. var repo = new Repository(repoPath);
  17. repo.Bisect(BisectState.Reset);
  18. repo.Update(0);
  19. repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
  20. repo.Update();
  21. BisectResult result = repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
  22. while (!result.Done)
  23. {
  24. Debug.WriteLine("at: " + result.Revision);
  25. result = repo.Bisect(GoodToBisectState(IsCurrentChangesetGood(repo)));
  26. }
  27. Debug.WriteLine("found: " + result.Revision);
  28. repo.Log(result.Revision).Dump();
  29. }
  30. public BisectState GoodToBisectState(bool isGood)
  31. {
  32. if (isGood)
  33. return BisectState.Good;
  34. else
  35. return BisectState.Bad;
  36. }
  37. public bool IsCurrentChangesetGood(Repository repo)
  38. {
  39. var revno = repo.Log(RevSpec.WorkingDirectoryParent).First().RevisionNumber;
  40. if (revno == 0)
  41. return false;
  42. else
  43. return true;
  44. }