PageRenderTime 56ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/Hooks/MercurialPreTransactionChangegroupHook.cs

#
C# | 53 lines | 25 code | 4 blank | 24 comment | 0 complexity | ebeefb555ad3bb37e285f5743f3421ef MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. using System.Diagnostics.CodeAnalysis;
  3. namespace Mercurial.Hooks
  4. {
  5. /// <summary>
  6. /// This <see cref="MercurialControllingHookBase"/> descendant implements the
  7. /// code necessary to handle the "pretxnchangegroup" hook:
  8. /// This is run after a changegroup has been added via push, pull, or unbundle, but before the transaction has
  9. /// been committed.
  10. /// </summary>
  11. /// <remarks>
  12. /// As with all controlling hooks (descendants of <see cref="MercurialControllingHookBase"/>), you can
  13. /// prevent the command from continuing, or let it continue, by calling
  14. /// <see cref="MercurialControllingHookBase.TerminateHookAndCancelCommand(int)"/>
  15. /// or <see cref="MercurialControllingHookBase.TerminateHookAndProceed"/> respectively.
  16. /// </remarks>
  17. public class MercurialPreTransactionChangegroupHook : MercurialControllingHookBase
  18. {
  19. /// <summary>
  20. /// This is the backing field for the <see cref="Url"/> property.
  21. /// </summary>
  22. private readonly string _Url = Environment.GetEnvironmentVariable("HG_URL") ?? string.Empty;
  23. /// <summary>
  24. /// This is the backing field for the <see cref="FirstRevision"/> property.
  25. /// </summary>
  26. private readonly RevSpec _FirstRevision = LoadRevision("HG_NODE");
  27. /// <summary>
  28. /// Gets the source of the incoming changesets.
  29. /// </summary>
  30. [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Cannot guarantee this is a valid Uri, but it is still given as an Url from Mercurial")]
  31. public string Url
  32. {
  33. get
  34. {
  35. return _Url;
  36. }
  37. }
  38. /// <summary>
  39. /// Gets the <see cref="RevSpec"/> of the first changeset.
  40. /// </summary>
  41. public RevSpec FirstRevision
  42. {
  43. get
  44. {
  45. return _FirstRevision;
  46. }
  47. }
  48. }
  49. }