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