Exemplo n.º 1
0
        public void To_WithRevisionByRevisionNumber_ProducesCorrectRevisionSpecification()
        {
            string       output   = RevSpec.To(7).ToString();
            const string expected = ":7";

            Assert.That(output, Is.EqualTo(expected));
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public ICommit CurrentCommit()
        {
            var id       = _repository.Identify();
            var revision = new HgLogQuery(RevSpec.To(id))
                           .ExceptTaggingCommits()
                           .Last()
                           .Revision;

            return(GetCommit(revision));
        }
        public IEnumerable <RevisionRange> GetFromAndBefore(RevisionId fromRevision, RevisionId toRevision, int pageSize)
        {
            var command = new LogCommand();

            if (string.IsNullOrEmpty(fromRevision.Value))
            {
                if (string.IsNullOrEmpty(toRevision.Value))
                {
                    command = command.WithAdditionalArgument("-d {0:yyyy-MM-dd} to {1:yyyy-MM-dd}".Fmt(fromRevision.Time.Value, toRevision.Time.Value));
                }
                else
                {
                    var to = new RevSpec(toRevision.Value);
                    command = command.WithRevision(RevSpec.To(to));
                    command = command.WithAdditionalArgument("-d >{0:yyyy-MM-dd}".Fmt(fromRevision.Time.Value));
                }
            }
            else
            {
                var from = new RevSpec(fromRevision.Value);
                if (string.IsNullOrEmpty(toRevision.Value))
                {
                    command = command.WithAdditionalArgument("-d <{0:yyyy-MM-dd}".Fmt(toRevision.Time.Value));
                    command = command.WithRevision(RevSpec.From(from));
                }
                else
                {
                    var to = new RevSpec(toRevision.Value);
                    command = command.WithRevision(RevSpec.Range(from, to));
                }
            }

            var pages = _repository.Log(command)
                        .OrderBy(ch => ch.Timestamp)
                        .ToArray()
                        .Split(pageSize);

            var result = pages.Select(page => new RevisionRange(page.First().ToRevisionId(), page.Last().ToRevisionId()));

            return(result);
        }
Exemplo n.º 4
0
 public void To_WithNullRevision_ThrowsArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => RevSpec.To(null));
 }