PageRenderTime 21ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/Mercurial.Net/Hooks/MercurialPreTagHook.cs

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