PageRenderTime 37ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net/Extensions/Churn/ChurnExtension.cs

#
C# | 52 lines | 25 code | 3 blank | 24 comment | 3 complexity | 0c5c8be082a7a81c26297ba1e2c51ac0 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Mercurial.Extensions.Churn
  4. {
  5. /// <summary>
  6. /// This class contains logic for the caseguard Mercurial extension.
  7. /// </summary>
  8. public static class ChurnExtension
  9. {
  10. /// <summary>
  11. /// Gets a value indicating whether the caseguard extension is installed and active.
  12. /// </summary>
  13. public static bool IsInstalled
  14. {
  15. get
  16. {
  17. return ClientExecutable.Configuration.ValueExists("extensions", "churn");
  18. }
  19. }
  20. /// <summary>
  21. /// Calculates the churn report; a histogram of changes to the repository.
  22. /// </summary>
  23. /// <param name="repository">
  24. /// The <see cref="Repository"/> to calculate the churn report for.
  25. /// </param>
  26. /// <param name="command">
  27. /// Any extra options to the churn method, or <c>null</c> for default options.
  28. /// </param>
  29. /// <returns>
  30. /// A collection of <see cref="ChurnGroup" /> instances.
  31. /// </returns>
  32. /// <exception cref="ArgumentNullException">
  33. /// <para><paramref name="repository"/> is <c>null</c>.</para>
  34. /// </exception>
  35. /// <exception cref="InvalidOperationException">
  36. /// The Churn extension is not installed and active.
  37. /// </exception>
  38. public static IEnumerable<ChurnGroup> Churn(this Repository repository, ChurnCommand command = null)
  39. {
  40. if (repository == null)
  41. throw new ArgumentNullException("repository");
  42. if (!IsInstalled)
  43. throw new InvalidOperationException("The churn extension is not installed and active");
  44. command = command ?? new ChurnCommand();
  45. repository.Execute(command);
  46. return command.Result;
  47. }
  48. }
  49. }