상속: IComparable
예제 #1
0
        private static SvnRevisionRange CreateSvnRevisionRangeBy(RevisionRange revisionRange)
        {
            SvnRevisionId fromChangeset = revisionRange.FromChangeset;
            SvnRevisionId toChangeSet   = revisionRange.ToChangeset;

            return(new SvnRevisionRange(fromChangeset.Value, toChangeSet.Value));
        }
예제 #2
0
        private MemoryStream GetSVNFileStream(SvnRevisionId changeset, string path)
        {
            var       memoryStream = new MemoryStream();
            SvnTarget target;

            //If you use Uri you should encode '#' as %23, as Uri's define the # as Fragment separator.
            //And in this case the fragment is not send to the server.
            path = path.Replace("#", "%23");
            if (SvnTarget.TryParse(GetPath(path).AbsolutePath, out target))
            {
                if (FileWasDeleted(path, changeset))
                {
                    return(new MemoryStream());
                }

                var uriTarget    = new SvnUriTarget(_root + path, changeset.Value);
                var svnWriteArgs = new SvnWriteArgs {
                    Revision = changeset.Value
                };

                Client.Write(uriTarget, memoryStream, svnWriteArgs);
                return(memoryStream);
            }
            return(new MemoryStream());
        }
예제 #3
0
        bool ICompareRevisionSecondArg.Belong(RevisionRange revisionRange)
        {
            SvnRevisionId fromChangeset = revisionRange.FromChangeset;
            SvnRevisionId toChangeset   = revisionRange.ToChangeset;

            return(fromChangeset.Value <= _firstArg.Value && _firstArg.Value <= toChangeset.Value);
        }
예제 #4
0
        private static RevisionRange[] GetFromTo(SvnRevisionId @from, SvnRevisionId lastRevision, int pageSize)
        {
            var result = new List <RevisionRange>();

            while (from.Value <= lastRevision.Value)
            {
                var fromRevisionId = from;

                RevisionRange revisionRange;

                var fromRevision = fromRevisionId;
                if ((fromRevisionId.Value + pageSize) < lastRevision.Value)
                {
                    revisionRange = new RevisionRange(fromRevision, new RevisionId {
                        Value = (fromRevisionId.Value + pageSize - 1).ToString()
                    });
                }
                else
                {
                    revisionRange = new RevisionRange(fromRevision, lastRevision);
                }

                result.Add(revisionRange);

                from = new SvnRevisionId(fromRevisionId.Value + pageSize);
            }
            return(result.ToArray());
        }
예제 #5
0
        public override RevisionRange[] GetAfterTillHead(RevisionId @from, int pageSize)
        {
            SvnRevisionId svnRevisionId = from;

            svnRevisionId = svnRevisionId.Value + 1;
            return(GetFromTillHead(svnRevisionId, pageSize));
        }
		public void ShouldRetrieve()
		{
			var settings = GetLocalRepositorySettings();
			settings.Uri = new Uri("http://svn.apache.org/repos/asf/spamassassin/trunk").ToString();
			var vcs = new Subversion(settings, ObjectFactory.GetInstance<ICheckConnectionErrorResolver>(), ObjectFactory.GetInstance<IActivityLogger>(), ObjectFactory.GetInstance<IDiffProcessor>());
			var svnRevisionId = new SvnRevisionId(1000000);
			var endRevision = vcs.GetFromTillHead(svnRevisionId, 50);
			var result = vcs.GetRevisions(endRevision.Last());
			result.Should(Be.Not.Empty);
		}
        public void ShouldRetrieve()
        {
            var settings = GetLocalRepositorySettings();

            settings.Uri = new Uri("http://svn.apache.org/repos/asf/spamassassin/trunk").ToString();
            var vcs           = new Subversion(settings, ObjectFactory.GetInstance <ICheckConnectionErrorResolver>(), ObjectFactory.GetInstance <IActivityLogger>(), ObjectFactory.GetInstance <IDiffProcessor>());
            var svnRevisionId = new SvnRevisionId(1000000);
            var endRevision   = vcs.GetFromTillHead(svnRevisionId, 50);
            var result        = vcs.GetRevisions(endRevision.Last());

            result.Should(Be.Not.Empty);
        }
예제 #8
0
        public override DiffResult GetDiff(RevisionId changeset, string path)
        {
            var revisionId         = new SvnRevisionId(changeset);
            var previousRevisionId = ((revisionId).Value - 1).ToString();

            try
            {
                return(GetDiff(changeset, path, previousRevisionId));
            }
            catch (SvnFileSystemException ex)
            {
                throw new VersionControlException(String.Format("Subversion exception: {0}", ex.Message));
            }
        }
예제 #9
0
        private bool FileWasDeleted(string path, SvnRevisionId changeset)
        {
            var revisionId = new RevisionId {
                Value = changeset.Value.ToString()
            };
            var arg = new SvnLogArgs(CreateSvnRevisionRangeBy(new RevisionRange(revisionId, revisionId)))
            {
                BaseUri = new Uri(_root), ThrowOnError = true
            };

            var revisions = GetSvnRevisions(arg);

            var item = revisions[0].ChangedPaths.FirstOrDefault(itemCollection => itemCollection.Path == path);

            return(item != null && item.Action == SvnChangeAction.Delete);
        }
예제 #10
0
        public override RevisionInfo[] GetRevisions(RevisionRange revisionRange)
        {
            try
            {
                SvnRevisionId fromChangeset = revisionRange.FromChangeset;
                SvnRevisionId toChangeset   = revisionRange.ToChangeset;

                _logger.DebugFormat("Getting revision infos [{0}:{1}]", fromChangeset, toChangeset);
                var arg = new SvnLogArgs(new SvnRevisionRange(fromChangeset.Value, toChangeset.Value))
                {
                    ThrowOnError = true
                };
                return(SubversionUtils.ArrayOfSvnRevisionToArrayOfRevisionInfo(GetSvnRevisions(arg), this).ToArray());
            }
            catch (SvnException e)
            {
                throw new VersionControlException(String.Format("Subversion exception: {0}", e.Message), e);
            }
        }
		private MemoryStream GetSVNFileStream(SvnRevisionId changeset, string path)
		{
			var memoryStream = new MemoryStream();
			SvnTarget target;
			//If you use Uri you should encode '#' as %23, as Uri's define the # as Fragment separator.
			//And in this case the fragment is not send to the server.
			path = path.Replace("#", "%23");
			if (SvnTarget.TryParse(GetPath(path).AbsolutePath, out target))
			{
				if (FileWasDeleted(path, changeset))
				{
					return new MemoryStream();
				}

				var uriTarget = new SvnUriTarget(_root + path, changeset.Value);
				var svnWriteArgs = new SvnWriteArgs {Revision = changeset.Value};

				Client.Write(uriTarget, memoryStream, svnWriteArgs);
				return memoryStream;
			}
			return new MemoryStream();
		}
예제 #12
0
        bool ICompareRevisionSecondArg.Behind(RevisionRange revisionRange)
        {
            SvnRevisionId toChangeSet = revisionRange.ToChangeset;

            return(_firstArg.Value > toChangeSet.Value);
        }
예제 #13
0
        bool ICompareRevisionSecondArg.GreaterThan(RevisionId revisionId)
        {
            SvnRevisionId svnRevisionId = revisionId;

            return(_firstArg.Value > svnRevisionId.Value);
        }
예제 #14
0
        bool ICompareRevisionSecondArg.LessThan(RevisionId revisionId)
        {
            SvnRevisionId svnRevisionId = revisionId;

            return(_firstArg.Value < svnRevisionId.Value);
        }
		public override DiffResult GetDiff(RevisionId changeset, string path)
		{
			var revisionId = new SvnRevisionId(changeset);
			var previousRevisionId = ((revisionId).Value - 1).ToString();
			try
			{
				return GetDiff(changeset, path, previousRevisionId);
			}
			catch (SvnFileSystemException ex)
			{
				throw new VersionControlException(String.Format("Subversion exception: {0}", ex.Message));
			}
		}
		private static RevisionRange[] GetFromTo(SvnRevisionId @from, SvnRevisionId lastRevision, int pageSize)
		{
			var result = new List<RevisionRange>();

			while (from.Value <= lastRevision.Value)
			{
				var fromRevisionId = from;

				RevisionRange revisionRange;

				var fromRevision = fromRevisionId;
				if ((fromRevisionId.Value + pageSize) < lastRevision.Value)
				{
					revisionRange = new RevisionRange(fromRevision, new RevisionId {Value = (fromRevisionId.Value + pageSize - 1).ToString()});
				}
				else
				{
					revisionRange = new RevisionRange(fromRevision, lastRevision);
				}

				result.Add(revisionRange);

				from = new SvnRevisionId(fromRevisionId.Value + pageSize);
			}
			return result.ToArray();
		}
예제 #17
0
        bool ICompareRevisionSecondArg.Before(RevisionRange revisionRange)
        {
            SvnRevisionId fromChangeSet = revisionRange.FromChangeset;

            return(_firstArg.Value < fromChangeSet.Value);
        }
예제 #18
0
        public override RevisionRange[] GetFromAndBefore(RevisionId @from, RevisionId to, int pageSize)
        {
            SvnRevisionId lastRevision = ((SvnRevisionId)to).Value - 1;

            return(GetFromTo(@from, lastRevision, pageSize));
        }
		public ICompareRevisionSecondArg Does(RevisionId firstArg)
		{
			_firstArg = firstArg;
			return this;
		}
		private bool FileWasDeleted(string path, SvnRevisionId changeset)
		{
			var revisionId = new RevisionId {Value = changeset.Value.ToString()};
			var arg = new SvnLogArgs(CreateSvnRevisionRangeBy(new RevisionRange(revisionId, revisionId)))
			{BaseUri = new Uri(_root), ThrowOnError = true};

			var revisions = GetSvnRevisions(arg, String.Empty);

			var item = revisions[0].ChangedPaths.FirstOrDefault(itemCollection => itemCollection.Path == path);

			return item != null && item.Action == SvnChangeAction.Delete;
		}
예제 #21
0
 public ICompareRevisionSecondArg Does(RevisionId firstArg)
 {
     _firstArg = firstArg;
     return(this);
 }