PageRenderTime 13ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/Hooks/MercurialOutgoingHook.cs

#
C# | 62 lines | 33 code | 6 blank | 23 comment | 0 complexity | 242dfaaed9ce6805bfa5da6ed81d030d MD5 | raw file
 1using System;
 2using System.Diagnostics.CodeAnalysis;
 3
 4namespace Mercurial.Hooks
 5{
 6    /// <summary>
 7    /// This <see cref="MercurialHookBase"/> descendant implements the
 8    /// code necessary to handle the "outgoing" hook:
 9    /// This is run after sending changes from local repository to another.
10    /// </summary>
11    public class MercurialOutgoingHook : MercurialHookBase
12    {
13        /// <summary>
14        /// This is the backing field for the <see cref="Source"/> property.
15        /// </summary>
16        private readonly string _Source = Environment.GetEnvironmentVariable("HG_SOURCE") ?? string.Empty;
17
18        /// <summary>
19        /// This is the backing field for the <see cref="FirstRevision"/> property.
20        /// </summary>
21        private readonly RevSpec _FirstRevision = LoadRevision("HG_NODE");
22
23        /// <summary>
24        /// This is the backing field for the <see cref="Url"/> property.
25        /// </summary>
26        private readonly string _Url = Environment.GetEnvironmentVariable("HG_URL") ?? string.Empty;
27
28        /// <summary>
29        /// Gets the source of the operation.
30        /// </summary>
31        public string Source
32        {
33            get
34            {
35                return _Source;
36            }
37        }
38
39        /// <summary>
40        /// Gets the <see cref="RevSpec"/> of the first changeset that was sent.
41        /// </summary>
42        public RevSpec FirstRevision
43        {
44            get
45            {
46                return _FirstRevision;
47            }
48        }
49
50        /// <summary>
51        /// Gets the url of the remote repository, if known.
52        /// </summary>
53        [SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings", Justification = "Cannot guarantee this is a valid Uri, but it is still given as an Url from Mercurial")]
54        public string Url
55        {
56            get
57            {
58                return _Url;
59            }
60        }
61    }
62}