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

/Mercurial.Net/Hooks/MercurialPreTagHook.cs

#
C# | 67 lines | 31 code | 6 blank | 30 comment | 1 complexity | 4a4243f24e05c064db389fa759e474e9 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. namespace Mercurial.Hooks
  3. {
  4. /// <summary>
  5. /// This <see cref="MercurialControllingHookBase"/> descendant implements the
  6. /// code necessary to handle the "pretag" hook:
  7. /// This is run before creating a tag.
  8. /// </summary>
  9. /// <remarks>
  10. /// As with all controlling hooks (descendants of <see cref="MercurialControllingHookBase"/>), you can
  11. /// prevent the command from continuing, or let it continue, by calling
  12. /// <see cref="MercurialControllingHookBase.TerminateHookAndCancelCommand(int)"/>
  13. /// or <see cref="MercurialControllingHookBase.TerminateHookAndProceed"/> respectively.
  14. /// </remarks>
  15. public class MercurialPreTagHook : MercurialControllingHookBase
  16. {
  17. /// <summary>
  18. /// This is the backing field for the <see cref="Revision"/> property.
  19. /// </summary>
  20. private readonly RevSpec _Revision = LoadRevision("HG_NODE");
  21. /// <summary>
  22. /// This is the backing field for the <see cref="IsLocal"/> property.
  23. /// </summary>
  24. private readonly bool _IsLocal = (Environment.GetEnvironmentVariable("HG_LOCAL") ?? "0") == "1";
  25. /// <summary>
  26. /// This is the backing field for the <see cref="Name"/> property.
  27. /// </summary>
  28. private readonly string _Name = Environment.GetEnvironmentVariable("HG_TAG") ?? string.Empty;
  29. /// <summary>
  30. /// Gets the <see cref="RevSpec"/> of the changeset that was tagged.
  31. /// </summary>
  32. public RevSpec Revision
  33. {
  34. get
  35. {
  36. return _Revision;
  37. }
  38. }
  39. /// <summary>
  40. /// Gets the name of the tag that was created.
  41. /// </summary>
  42. public string Name
  43. {
  44. get
  45. {
  46. return _Name;
  47. }
  48. }
  49. /// <summary>
  50. /// Gets a value indicating whether the tag is a local tag or one that has been
  51. /// added to the repository.
  52. /// </summary>
  53. public bool IsLocal
  54. {
  55. get
  56. {
  57. return _IsLocal;
  58. }
  59. }
  60. }
  61. }