/// <summary>
        /// Resolves the specified revision.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="revision">The revision.</param>
        /// <returns></returns>
        public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
        {
            if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            foreach (IAnkhRevisionProvider p in _providers)
            {
                AnkhRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                {
                    return(r);
                }
            }

            switch (revision.RevisionType)
            {
            case SvnRevisionType.Number:
                ExplicitRevisionType ert = new ExplicitRevisionType(Context, origin);
                ert.CurrentValue = revision;
                return(ert);
            }

            return(null);
        }
            public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
            {
                if (revision == null)
                {
                    throw new ArgumentNullException("revision");
                }

                switch (revision.RevisionType)
                {
                case SvnRevisionType.Head:
                    return(_head);

                case SvnRevisionType.Base:
                    return(_base);

                case SvnRevisionType.Committed:
                    return(_committed);

                case SvnRevisionType.Previous:
                    return(_previous);

                case SvnRevisionType.Working:
                    return(_working);
                }

                return(null);
            }
Example #3
0
        public string GetTempFile(SharpSvn.SvnTarget target, SharpSvn.SvnRevision revision, bool withProgress)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            else if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            string file      = GetTempPath(target.FileName, revision);
            bool   unrelated = false;

            ProgressRunnerResult r = GetService <IProgressRunner>().RunModal(ServiceStrings.RetrievingFileForComparison,
                                                                             delegate(object sender, ProgressWorkerArgs aa)
            {
                SvnWriteArgs wa = new SvnWriteArgs();
                wa.Revision     = revision;
                wa.AddExpectedError(SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES);

                using (Stream s = File.Create(file))
                    if (!aa.Client.Write(target, s, wa))
                    {
                        if (wa.LastException.SvnErrorCode == SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES)
                        {
                            unrelated = true;
                        }
                    }
            });

            if (!r.Succeeded || unrelated)
            {
                return(null); // User canceled
            }
            if (File.Exists(file))
            {
                File.SetAttributes(file, FileAttributes.ReadOnly); // A readonly file does not allow editting from many diff tools
            }
            return(file);
        }
Example #4
0
        public string GetTempFile(SvnItem target, SharpSvn.SvnRevision revision, bool withProgress)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            else if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            string file = GetTempPath(target.Name, revision);

            if (target.NodeKind != SvnNodeKind.File)
            {
                throw new InvalidOperationException("Can't create a tempfile from a directory");
            }

            ProgressRunnerResult r = GetService <IProgressRunner>().RunModal(ServiceStrings.RetrievingFileForComparison,
                                                                             delegate(object sender, ProgressWorkerArgs aa)
            {
                SvnWriteArgs wa = new SvnWriteArgs();
                wa.Revision     = revision;

                using (Stream s = File.Create(file))
                    aa.Client.Write(target.FullPath, s, wa);
            });

            if (!r.Succeeded)
            {
                return(null); // User canceled
            }
            if (File.Exists(file))
            {
                File.SetAttributes(file, FileAttributes.ReadOnly); // A readonly file does not allow editting from many diff tools
            }
            return(file);
        }