public RevisionRange[] GetFromTillHead(RevisionId @from, int pageSize)
		{
			var currentRevision = from;
			var lastRevision = long.Parse(Revisions.Last().Id.Value);

			return GetFromTo(currentRevision, lastRevision, pageSize);
		}
		private RevisionId GetToRevision(RevisionRange processedRevisionRange, RevisionId newToRevision)
		{
			if (RevisionComparer.Is(newToRevision).GreaterThan(processedRevisionRange.ToChangeset))
			{
				return newToRevision;
			}
			return processedRevisionRange.ToChangeset;
		}
		public override void CheckRevision(RevisionId revision, PluginProfileErrorCollection errors)
		{
			TfsRevisionId revisionId = revision;
			if (Int32.Parse(revisionId.Value) <= 0 || Int32.Parse(revisionId.Value) > Int32.MaxValue)
			{
				_errorResolver.HandleConnectionError(new InvalidRevisionException(), errors);
			}
		}
		public override void CheckRevision(RevisionId revision, PluginProfileErrorCollection errors)
		{
			GitRevisionId revisionId = revision;
			if (revisionId.Time > GitRevisionId.UtcTimeMax)
			{
				_errorResolver.HandleConnectionError(new InvalidRevisionException(), errors);
			}
		}
		public RevisionInfo[] GetRevisions(RevisionId fromChangeset, RevisionId toChangeset)
		{
			var revisionInfos = GetChangesets(changeset => changeset.ChangesetId >= int.Parse(fromChangeset.Value) && changeset.ChangesetId <= int.Parse(toChangeset.Value))
					.Select(changeset => changeset.ToRevisionInfo())
					.ToArray();

			return revisionInfos;
		}
		private static long ConvertToRevision(RevisionId revision)
		{
			long revisionId;
			if (!Int64.TryParse(revision.Value, out revisionId))
			{
				revisionId = 0;
			}
			return revisionId;
		}
		public RevisionInfo[] GetRevisions(RevisionId fromChangeset, RevisionId toChangeset)
		{
			var revisionInfos =
				GetChangesets(VersionSpec.ParseSingleSpec((fromChangeset.Value).ToString(CultureInfo.InvariantCulture), null),
					VersionSpec.ParseSingleSpec((toChangeset.Value).ToString(CultureInfo.InvariantCulture), null))
					.Select(changeset => changeset.ToRevisionInfo())
					.ToArray();

			return revisionInfos;
		}
		public void ShouldHandlePosixTime()
		{
			var initialTime = DateTime.Today.AddHours(6);
            TfsRevisionId revisionId = new RevisionId { Time = initialTime, Value = Guid.NewGuid().ToString() };

			RevisionId revisionIdDto = revisionId;
            TfsRevisionId restoredRevisionId = revisionIdDto;

			restoredRevisionId.Time.Should(Be.EqualTo(initialTime));
		}
		private RevisionId GetFrom(RevisionId @from)
		{
			var startRevision = _revisionComparer.ConvertToRevisionId(_settings.StartRevision);
			var missingRevisionsCheckInterval = @from.Time.Value.AddDays(-MissingRevisionsCheckInterval);
			var toChangeset = startRevision.Time > missingRevisionsCheckInterval
								  ? startRevision
								  : new RevisionId { Time = missingRevisionsCheckInterval };

			return toChangeset;
		}
		private RevisionId GetFromRevision(RevisionRange processedRevisionRange, RevisionId newFromRevision)
		{
			if (RevisionComparer.Is(StartRevision).LessThan(newFromRevision))
				newFromRevision = StartRevision;

			if (RevisionComparer.Is(newFromRevision).LessThan(processedRevisionRange.FromChangeset))
			{
				return newFromRevision;
			}
			return processedRevisionRange.FromChangeset;
		}
		public bool Equals(RevisionId other)
		{
			if (ReferenceEquals(null, other))
			{
				return false;
			}
			if (ReferenceEquals(this, other))
			{
				return true;
			}
			return Equals(other.Value, Value);
		}
 public RevCommit GetCommit(RevisionId id)
 {
     var revWalk = CreateRevWalker();
     try
     {
         return revWalk.ParseCommit(ObjectId.FromString(id.Value));
     }
     finally
     {
         revWalk.Dispose();
     }
 }
예제 #13
0
 public bool Equals(RevisionId other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Value, Value));
 }
        public IEnumerable<RevisionRange> GetAfterTillHead(RevisionId revisionId, int pageSize)
        {
	        var revSpec = new RevSpec(revisionId.Value);
			var command = new LogCommand().WithRevision(RevSpec.From(revSpec) && !new RevSpec(revisionId.Value));
            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;
        }
예제 #15
0
        public IEnumerable<RevisionRange> GetFromAndBefore(RevisionId fromRevision, RevisionId toRevision, int pageSize)
        {
            var command = new LogCommand();
            var pages = _repository.Log(command)
                .Where(ch => (ch.Timestamp >= fromRevision.Time.Value && ch.Timestamp <= toRevision.Time.Value))
                .OrderBy(ch => ch.Timestamp)
                .ToArray()
                .Split(pageSize);

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

            return result;
        }
        public IEnumerable<RevisionRange> GetFromAndBefore(RevisionId fromRevision, RevisionId toRevision, int pageSize)
        {
			var from = new RevSpec(fromRevision.Value);
			var to = new RevSpec(toRevision.Value);
	        var command = new LogCommand().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;
        }
        public override DiffResult GetDiff(RevisionId changeset, string path)
        {
            var commit = _git.GetCommit(changeset);
            var parent = _git.GetCommit(commit.GetParent(0).Id.Name);

            try
            {
                return GetDiff(path, parent, commit);
            }
            catch (GitAPIException ex)
            {
                throw new VersionControlException(String.Format("Git exception: {0}", ex.Message));
            }
        }
        public override DiffResult GetDiff(RevisionId changeset, string path)
        {
            var commit = _mercurial.GetCommit(changeset);
            var parent = _mercurial.GetParentCommit(commit);

            try
            {
                return GetDiff(path, parent, commit);
            }
            catch (MercurialException ex)
            {
                throw new VersionControlException(String.Format("Mercurial exception: {0}", ex.Message));
            }
        }
		public override DiffResult GetDiff(RevisionId changeset, string path)
		{
			var commit = _tfsClient.GetCommit(changeset);
			var parent = _tfsClient.GetParentCommit(commit);

			try
			{
				return GetDiff(path, parent, commit);
			}
			catch (Exception ex)
			{
				throw new VersionControlException($"TFS exception: {ex.Message}");
			}
		}
		private static RevisionRange[] GetFromTo(RevisionId @from, long to, int pageSize)
		{
			var result = new List<RevisionRange>();
			while (long.Parse(@from.Value) <= to)
			{
				var currentRevisionId = long.Parse(@from.Value);

				if ((currentRevisionId + pageSize) < to)
				{
					result.Add(new RevisionRange(@from, (currentRevisionId + pageSize - 1).ToString()));
				}
				else
				{
					result.Add(new RevisionRange(@from, to.ToString()));
				}

				@from = (currentRevisionId + pageSize).ToString();
			}
			return result.ToArray();
		}
        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;
        }
		public override byte[] GetBinaryFileContent(RevisionId changeset, string path)
		{
			throw new NotImplementedException();
		}
		public override string GetTextFileContent(RevisionId changeset, string path)
		{
			var commit = _git.GetCommit(changeset);

			return GetFileContent(commit, path);
		}
		public RevisionRange[] GetAfterTillHead(RevisionId @from, int pageSize)
		{
			var revisionInfo = Revisions.Find(x => long.Parse(x.Id.Value) == long.Parse(@from.Value));
			if (revisionInfo == null)
			{
				return new RevisionRange[] {};
			}

			if (Revisions.Last() == revisionInfo)
			{
				return new RevisionRange[] {};
			}

			var revision = Revisions[Revisions.IndexOf(revisionInfo) + 1];
			return GetFromTillHead(revision.Id, pageSize);
		}
 public abstract void CheckRevision(RevisionId revision, PluginProfileErrorCollection errors);
		public void CheckRevision(RevisionId revision, PluginProfileErrorCollection errors) {}
		public string GetTextFileContent(RevisionId changeset, string path)
		{
			throw new NotImplementedException();
		}
		public DiffResult GetDiff(RevisionId changeset, string path)
		{
			throw new NotImplementedException();
		}
		public RevisionRange[] GetFromAndBefore(RevisionId @from, RevisionId to, int pageSize)
		{
			return GetFromTo(@from, long.Parse(to.Value) - 1, pageSize);
		}
 public abstract DiffResult GetDiff(RevisionId changeset, string path);
		public override RevisionRange[] GetAfterTillHead(RevisionId @from, int pageSize)
		{
			var actualFrom = GetFrom(@from);
			return _git.GetAfterTillHead(actualFrom, pageSize).ToArray();
		}
 public abstract byte[] GetBinaryFileContent(RevisionId changeset, string path);
 public abstract RevisionRange[] GetFromAndBefore(RevisionId @from, RevisionId to, int pageSize);
 public abstract RevisionRange[] GetAfterTillHead(RevisionId @from, int pageSize);
 public abstract string GetTextFileContent(RevisionId changeset, string path);
예제 #36
0
 public RevisionRange(RevisionId fromChangeset, RevisionId toChangeset)
 {
     FromChangeset = fromChangeset;
     ToChangeset   = toChangeset;
 }
		public override RevisionRange[] GetFromAndBefore(RevisionId @from, RevisionId to, int pageSize)
		{
			return _git.GetFromAndBefore(from, to, pageSize).ToArray();
		}
		bool ICompareRevisionSecondArg.LessThan(RevisionId revisionId)
		{
			return int.Parse(_firstArg.Value) < int.Parse(revisionId.Value);
		}