public static SvnRevision SafeParse(string expression)
        {
            SvnRevision revision = new SvnRevision(SvnRevisionType.Head);
            // check revision number
            long revNumber;
            if (long.TryParse(expression, out revNumber))
            {
                revision = new SvnRevision(revNumber);
            }
            else
            {
                // check revision date
                DateTime revDate;
                if (DateTime.TryParse(expression, out revDate))
                {
                    revision = new SvnRevision(revDate);
                }
                else
                {
                    // check for revision type
                    SvnRevisionType revisionType;
                    if (SvnRevisionType.TryParse(expression, true, out revisionType))
                    {
                        revision = new SvnRevision(revisionType);
                    }
                }
            }

            return revision;
        }
        private PropertiesCollection GetProperties(string target, SvnRevision asOfRevision, bool recurse)
        {
            try
            {
                PropertiesCollection result = new PropertiesCollection();
                Collection <SvnPropertyListEventArgs> output;
                SvnPropertyListArgs args = new SvnPropertyListArgs();
                args.Revision = asOfRevision;
                args.Depth    = recurse ? SvnDepth.Infinity : SvnDepth.Children;

                client.GetPropertyList(new Uri(target), args, out output);

                foreach (SvnPropertyListEventArgs eventArgs in output)
                {
                    Dictionary <string, string> properties = new Dictionary <string, string>(eventArgs.Properties.Count);
                    foreach (SvnPropertyValue value in eventArgs.Properties)
                    {
                        properties.Add(value.Key, value.StringValue);
                    }
                    result.Add(eventArgs.Path, properties);
                }

                return(result);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }

            return(null);
        }
Esempio n. 3
0
 /// <summary>
 /// 获取提交日志记录
 /// </summary>
 /// <param name="url"></param>
 /// <param name="startRevision"></param>
 /// <param name="endRevision"></param>
 public static string GetCommitLog(string url, SvnRevision startRevision, SvnRevision endRevision)
 {
     using (SvnClient client = GetSvnClient())
     {
         Collection <SvnLogEventArgs> logs;
         var totalLog = new StringBuilder();
         if (client.GetLog(new Uri(url), new SvnLogArgs(new SvnRevisionRange(startRevision, endRevision)), out logs))
         {
             //后续操作,可以获取作者,版本号,提交时间,提交的message和提交文件列表等信息
             foreach (var log in logs.OrderByDescending(x => x.Time))
             {
                 var stringBuilder = new StringBuilder();
                 foreach (var item in log.ChangedPaths.Distinct())
                 {
                     var operateMes = item.Action + "  " + item.RepositoryPath.ToString().Replace("branch/BiHu.BaoXian.ArtificialSubmit/BiHu.BaoXian.ArtificialSubmit.RB-08/", "");
                     stringBuilder.AppendLine(operateMes);
                 }
                 totalLog.AppendLine(string.Format("{0}  {1}  {2} {3}\r\n{4}",
                                                   log.Author,
                                                   log.Revision.ToString(),
                                                   log.Time,
                                                   log.LogMessage,
                                                   stringBuilder
                                                   ));
             }
         }
         return(totalLog.ToString());
     }
 }
        public void Revision_ToString()
        {
            SvnRevision revision = SvnRevision.Base;

            Assert.That(revision.ToString(), Is.EqualTo("BASE"));

            revision = SvnRevision.Committed;
            Assert.That(revision.ToString(), Is.EqualTo("COMMITTED"));

            revision = SvnRevision.Head;
            Assert.That(revision.ToString(), Is.EqualTo("HEAD"));

            revision = SvnRevision.Previous;
            Assert.That(revision.ToString(), Is.EqualTo("PREVIOUS"));

            revision = SvnRevision.None;
            Assert.That(revision.ToString(), Is.EqualTo(""));

            revision = SvnRevision.Working;
            Assert.That(revision.ToString(), Is.EqualTo("WORKING"));

            DateTime t = DateTime.UtcNow;

            revision = new SvnRevision(t);
            Assert.That(revision.ToString(), Is.EqualTo("{" + t.ToString("s", CultureInfo.InvariantCulture) + "}"));

            revision = new SvnRevision(42);
            Assert.That(revision.ToString(), Is.EqualTo("42"));
        }
Esempio n. 5
0
        static string GetTitle(string fileName, SvnRevision revision)
        {
            string strRev = revision.RevisionType == SvnRevisionType.Time ?
                            revision.Time.ToLocalTime().ToString("g") : revision.ToString();

            return(fileName + " - " + strRev);
        }
        private static SvnUriTarget CreateSvnUriTarget(string uriString, SvnRevision revision)
        {
            Uri          uri    = new Uri(uriString);
            SvnUriTarget target = new SvnUriTarget(uri, revision);

            return(target);
        }
Esempio n. 7
0
        private void ExportDirectoryListItem(SvnListEventArgs e, SvnRevision revision, string destinationPath)
        {
            if (_g.StopRequested)
            {
                e.Cancel = true;
                return;
            }
            destinationPath = Path.Combine(destinationPath, e.Path);
            var  source = new SvnUriTarget(e.Uri, revision);
            bool exists;

            if (e.Entry.NodeKind == SvnNodeKind.Directory)
            {
                exists = Directory.Exists(destinationPath);
                if (!exists)
                {
                    Directory.CreateDirectory(destinationPath);
                }
            }
            else
            {
                exists = File.Exists(destinationPath);
                _g.Svn.Export(source, destinationPath, _infiniteOverwriteExport);
            }
            if (destinationPath != _g.WorkingDir)
            {
                _g.Svn.Add(destinationPath, _forceAdd);
                _g.Interaction.Trace((exists ? ActionModified : ActionCreated) + destinationPath);
            }
            CopyProperties(source, destinationPath);
        }
Esempio n. 8
0
 static string PathSafeRevision(SvnRevision revision)
 {
     if (revision.RevisionType == SvnRevisionType.Time)
     {
         return(revision.Time.ToLocalTime().ToString("yyyyMMdd_hhmmss"));
     }
     return(revision.ToString());
 }
Esempio n. 9
0
        /// <summary>
        /// Update a file to a revision
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="revision"></param>
        /// <returns></returns>
        public bool UpdateToRevision(string filePath, long revision)
        {
            var svnUpdateArgs = new SvnUpdateArgs();
            var svnRevision   = new SvnRevision(revision);

            svnUpdateArgs.Revision = svnRevision;
            return(_svnClient.Update(filePath, svnUpdateArgs));
        }
Esempio n. 10
0
        /// <summary>
        /// Shows the log viewer and sets the revision cell value to the selected revision
        /// </summary>
        /// <param name="row"></param>
        private void SelectRevision(DataGridViewRow row)
        {
            IAnkhServiceProvider context = Context;

            if (context != null)
            {
                string selectedUriString = row.Cells[0].Value as string;

                Uri selectedUri;
                if (!string.IsNullOrEmpty(selectedUriString) &&
                    Uri.TryCreate(selectedUriString, UriKind.Absolute, out selectedUri)
                    )
                {
                    Uri repoRoot = string.Equals(_lastUsedUriString, selectedUriString) ? _lastRepositoryRoot : null;
                    if (repoRoot == null)
                    {
                        if (context.GetService <IProgressRunner>().RunModal(
                                PropertyEditStrings.RetrievingRepositoryRoot,
                                delegate(object sender, ProgressWorkerArgs a)
                        {
                            repoRoot = a.Client.GetRepositoryRoot(selectedUri);
                        }).Succeeded)
                        {
                            //cache the last used repo uri string and the fetched repository root uri
                            _lastRepositoryRoot = repoRoot;
                            _lastUsedUriString  = selectedUriString;
                        }
                    }
                    if (repoRoot != null)
                    {
                        try
                        {
                            // set the current revision value as the initial selection
                            string             rev       = row.Cells[2].Value as string;
                            SvnRevision        rr        = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev);
                            SvnUriTarget       svnTarget = new SvnUriTarget(selectedUri, rr);
                            Ankh.Scc.SvnOrigin origin    = new Ankh.Scc.SvnOrigin(svnTarget, repoRoot);
                            using (Ankh.UI.SvnLog.LogViewerDialog dlg = new Ankh.UI.SvnLog.LogViewerDialog(origin))
                            {
                                if (dlg.ShowDialog(Context) == DialogResult.OK)
                                {
                                    Ankh.Scc.ISvnLogItem li = EnumTools.GetSingle(dlg.SelectedItems);
                                    rev = li == null ? null : li.Revision.ToString();
                                    //set the revision cell value to the selection revision
                                    row.Cells[2].Value = rev ?? string.Empty;
                                }
                            }
                        }
                        catch
                        {
                            // clear cache in case of error
                            _lastUsedUriString  = null;
                            _lastRepositoryRoot = null;
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        public void StartLog(SvnOrigin target, SvnRevision start, SvnRevision end)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            StartLog(new SvnOrigin[] { target }, start, end);
        }
Esempio n. 12
0
        public override string[] RetrieveAuthors(DateRange dateRange)
        {
            var startRevision = new SvnRevision(dateRange.StartDate.GetValueOrDefault());
            var endRevision   = new SvnRevision(dateRange.EndDate.GetValueOrDefault());

            var range  = new SvnRevisionRange(startRevision, endRevision);
            var result = GetSvnRevisions(new SvnLogArgs(range));

            return(result.Select(x => x.Author).Where(y => !string.IsNullOrEmpty(y)).Distinct().ToArray());
        }
Esempio n. 13
0
        private static void PerformUpdate(CommandEventArgs e, ProgressWorkerArgs wa, SvnRevision rev, bool allowUnversionedObstructions, bool updateExternals, bool setDepthInfinity, IEnumerable <UpdateGroup> groups, out SvnUpdateResult updateResult)
        {
            SvnUpdateArgs ua = new SvnUpdateArgs();

            ua.Revision          = rev;
            ua.AllowObstructions = allowUnversionedObstructions;
            ua.IgnoreExternals   = !updateExternals;
            ua.KeepDepth         = setDepthInfinity;
            updateResult         = null;

            HybridCollection <string> handledExternals = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

            ua.Notify += delegate(object ss, SvnNotifyEventArgs ee)
            {
                if (ee.Action == SvnNotifyAction.UpdateExternal)
                {
                    if (!handledExternals.Contains(ee.FullPath))
                    {
                        handledExternals.Add(ee.FullPath);
                    }
                }
            };
            e.Context.GetService <IConflictHandler>().RegisterConflictHandler(ua, wa.Synchronizer);

            foreach (UpdateGroup group in groups)
            {
                if (handledExternals.Contains(group.WorkingCopyRoot))
                {
                    continue;
                }

                group.Nodes.Sort(StringComparer.OrdinalIgnoreCase);

                // Currently Subversion runs update per item passed and in
                // Subversion 1.6 passing each item separately is actually
                // a tiny bit faster than passing them all at once.
                // (sleep_for_timestamp fails its fast route)
                foreach (string path in group.Nodes)
                {
                    if (handledExternals.Contains(path))
                    {
                        continue;
                    }

                    SvnUpdateResult result;
                    wa.Client.Update(path, ua, out result);

                    if (updateResult == null)
                    {
                        updateResult = result; // Return the primary update as version for output
                    }
                }
            }
        }
Esempio n. 14
0
        string GetName(string filename, SvnRevision rev)
        {
            if (string.IsNullOrEmpty(filename))
            {
                throw new ArgumentNullException("filename");
            }
            else if (rev == null)
            {
                throw new ArgumentNullException("rev");
            }

            return((Path.GetFileNameWithoutExtension(filename) + "." + PathSafeRevision(rev) + Path.GetExtension(filename)).Trim('.'));
        }
Esempio n. 15
0
        public string GetTitle(SvnTarget target, SvnRevision revision)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            return(GetTitle(target.FileName, revision));
        }
Esempio n. 16
0
                public SimpleRevisionType(SvnRevision rev, string title)
                {
                    if (rev == null)
                    {
                        throw new ArgumentNullException("rev");
                    }
                    else if (string.IsNullOrEmpty(title))
                    {
                        throw new ArgumentNullException("title");
                    }

                    _rev   = rev;
                    _title = title;
                }
        public void RevisionProperty_SetLog()
        {
            SvnSandBox sbox      = new SvnSandBox(this);
            Uri        reposUri  = sbox.CreateRepository(SandBoxRepository.DefaultBranched);
            string     reposPath = reposUri.AbsolutePath;

            InstallRevpropHook(reposPath);

            SvnRevision rev = 2;

            Client.SetRevisionProperty(reposUri, rev, SvnPropertyNames.SvnDate, DateTime.UtcNow.ToString("o"));

            Client.SetRevisionProperty(new Uri(reposUri, "trunk"), rev, SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(DateTime.UtcNow));
        }
Esempio n. 18
0
        string GetTempPath(string filename, SvnRevision rev)
        {
            string name = GetName(filename, rev);
            string file;

            if (_lastDir == null || !Directory.Exists(_lastDir) || File.Exists(file = Path.Combine(_lastDir, name)))
            {
                _lastDir = GetService <IAnkhTempDirManager>().GetTempDir();

                file = Path.Combine(_lastDir, name);
            }

            return(file);
        }
Esempio n. 19
0
        public void StartLog(ICollection <SvnOrigin> targets, SvnRevision start, SvnRevision end)
        {
            if (targets == null)
            {
                throw new ArgumentNullException("targets");
            }

            LogSource.Targets = targets;
            LogSource.Start   = start;
            LogSource.End     = end;

            Reset();
            revisionBox.Start(LogMode.Log);
        }
Esempio n. 20
0
        private static string GetPath(IAnkhServiceProvider context, SvnRevision revision, SvnItem item, string tempDir)
        {
            if (revision == SvnRevision.Working)
            {
                return(item.FullPath);
            }

            string strRevision;

            if (revision.RevisionType == SvnRevisionType.Time)
            {
                strRevision = revision.Time.ToLocalTime().ToString("yyyyMMdd_hhmmss");
            }
            else
            {
                strRevision = revision.ToString();
            }
            string tempFile = Path.GetFileNameWithoutExtension(item.Name) + "." + strRevision + Path.GetExtension(item.Name);

            tempFile = Path.Combine(tempDir, tempFile);
            // we need to get it from the repos
            context.GetService <IProgressRunner>().RunModal(CommandStrings.RetrievingFileForComparison, delegate(object o, ProgressWorkerArgs ee)
            {
                SvnTarget target;

                switch (revision.RevisionType)
                {
                case SvnRevisionType.Head:
                case SvnRevisionType.Number:
                case SvnRevisionType.Time:
                    target = item.Uri;
                    break;

                default:
                    target = item.FullPath;
                    break;
                }
                SvnWriteArgs args = new SvnWriteArgs();
                args.Revision     = revision;
                args.AddExpectedError(SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES);

                using (FileStream stream = File.Create(tempFile))
                {
                    ee.Client.Write(target, stream, args);
                }
            });

            return(tempFile);
        }
Esempio n. 21
0
        public void StartLog(ICollection <SvnOrigin> targets, SvnRevision start, SvnRevision end)
        {
            if (targets == null)
            {
                throw new ArgumentNullException("targets");
            }

            _origins = new List <SvnOrigin>(targets);
            _baseUri = null;
            _rqStart = start;
            _rqEnd   = end;

            UpdateTitle();

            logControl.StartLog(_origins, start, end);
        }
Esempio n. 22
0
        private Collection <SvnLogEventArgs> getLog(int limit, SvnRevision rev)
        {
            var arg = new SvnLogArgs()
            {
                Limit = limit
                ,
                Start = rev
            };
            Collection <SvnLogEventArgs> results;

            if (!_svncl.GetLog(_uri, arg, out results))
            {
                return(null);
            }
            return(results);
        }
Esempio n. 23
0
        public void Revision_SvnRevisionTypes()
        {
            SvnRevision r = new SvnRevision(DateTime.Now);
            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Time));

            r = new SvnRevision(42);
            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Number));

            r = 42;
            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Number));

            Assert.That(SvnRevision.Base.RevisionType, Is.EqualTo(SvnRevisionType.Base));
            Assert.That(SvnRevision.Committed.RevisionType, Is.EqualTo(SvnRevisionType.Committed));
            Assert.That(SvnRevision.Head.RevisionType, Is.EqualTo(SvnRevisionType.Head));
            Assert.That(SvnRevision.Previous.RevisionType, Is.EqualTo(SvnRevisionType.Previous));
            Assert.That(SvnRevision.None.RevisionType, Is.EqualTo(SvnRevisionType.None));
            Assert.That(SvnRevision.Working.RevisionType, Is.EqualTo(SvnRevisionType.Working));
        }
Esempio n. 24
0
    /// <summary>
    /// 将SVN中某文件的某个版本保存到本地指定路径
    /// </summary>
    public static bool ExportSvnFileToLocal(string svnFilePath, string savePath, SvnRevision svnRevision, out Exception exception)
    {
        SvnExportArgs exportArgs = new SvnExportArgs();

        exportArgs.Overwrite = true;
        exportArgs.Revision  = svnRevision;
        try
        {
            bool result = _svnClient.Export(svnFilePath, savePath, exportArgs);
            exception = null;
            return(result);
        }
        catch (Exception e)
        {
            exception = e;
            return(false);
        }
    }
 private int Checkout(string repoUrl, string workingPath, SvnRevision revision, bool recurse, bool ignoreExternals)
 {
     try
     {
         SvnCheckOutArgs args = new SvnCheckOutArgs();
         args.Revision        = revision;
         args.IgnoreExternals = ignoreExternals;
         args.Depth           = recurse ? SvnDepth.Infinity : SvnDepth.Children;
         SvnUpdateResult result;
         client.CheckOut(new Uri(repoUrl), workingPath, args, out result);
         return((int)result.Revision);
     }
     catch (Exception ex)
     {
         OnError(ex);
     }
     return(int.MinValue);
 }
        public void Revision_SvnRevisionTypes()
        {
            SvnRevision r = new SvnRevision(DateTime.Now);

            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Time));

            r = new SvnRevision(42);
            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Number));

            r = 42;
            Assert.That(r.RevisionType, Is.EqualTo(SvnRevisionType.Number));

            Assert.That(SvnRevision.Base.RevisionType, Is.EqualTo(SvnRevisionType.Base));
            Assert.That(SvnRevision.Committed.RevisionType, Is.EqualTo(SvnRevisionType.Committed));
            Assert.That(SvnRevision.Head.RevisionType, Is.EqualTo(SvnRevisionType.Head));
            Assert.That(SvnRevision.Previous.RevisionType, Is.EqualTo(SvnRevisionType.Previous));
            Assert.That(SvnRevision.None.RevisionType, Is.EqualTo(SvnRevisionType.None));
            Assert.That(SvnRevision.Working.RevisionType, Is.EqualTo(SvnRevisionType.Working));
        }
        private RevisionPropertyCollection GetRevisionProperties(string url, SvnRevision revision)
        {
            try
            {
                SvnPropertyCollection propertyCollection;

                //client.GetRevisionPropertyList(CreateSvnUriTarget(url, revision), out propertyCollection);
                client.GetRevisionPropertyList(CreateSvnUriTarget(url, revision), out propertyCollection);

                RevisionPropertyCollection revisionPropertyCollection = new RevisionPropertyCollection((int)revision.Revision);
                foreach (SvnPropertyValue value in propertyCollection)
                {
                    revisionPropertyCollection.Add(value.Key, value.StringValue);
                }
                return(revisionPropertyCollection);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }

            return(null);
        }
        internal static SvnCheckOutArgs ToSharpSvn(this SvnCheckoutSettings settings)
        {
            settings.NotNull(nameof(settings));

            SvnRevision revision;

            if (settings.Revision == null)
            {
                revision = SvnRevision.Head;
            }
            else
            {
                revision = new SvnRevision((long)settings.Revision);
            }

            return((new SvnCheckOutArgs
            {
                Depth = settings.Depth.ToSharpSvn(),
                IgnoreExternals = settings.IgnoreExternals,
                AllowObstructions = settings.AllowObstructions,
                Revision = revision
            }).SetBaseSettings(settings));
        }
Esempio n. 29
0
        private static bool TryCreateItemFromRow(DataGridViewRow r, out SvnExternalItem item)
        {
            if (r == null)
            {
                throw new ArgumentNullException("r");
            }

            string      url    = r.Cells[0].Value as string;
            string      target = r.Cells[4].Value as string;
            string      rev    = r.Cells[2].Value as string;
            SvnRevision rr     = string.IsNullOrEmpty(rev) ? SvnRevision.None : long.Parse(rev);

            if (url.Contains("://"))
            {
                Uri uri;

                if (!Uri.TryCreate(url, UriKind.Absolute, out uri))
                {
                    item = null;
                    return(false);
                }

                url = uri.AbsoluteUri;
            }

            SvnExternalItem ei = new SvnExternalItem(target, url, rr, rr);
            SvnExternalItem p;

            if (!SvnExternalItem.TryParse(ei.ToString(), out p) || !p.Equals(ei))
            {
                item = null;
                return(false);
            }
            item = ei;
            return(true);
        }
Esempio n. 30
0
        public string[] GetTempFiles(SvnTarget target, SvnRevision from, SvnRevision to, bool withProgress)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            else if (from == null)
            {
                throw new ArgumentNullException("from");
            }
            else if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            string f1;
            string f2;

            if (from.RevisionType == SvnRevisionType.Number && to.RevisionType == SvnRevisionType.Number && from.Revision + 1 == to.Revision)
            {
                f1 = GetTempPath(target.FileName, from);
                f2 = GetTempPath(target.FileName, to);

                int n = 0;
                ProgressRunnerResult r = Context.GetService <IProgressRunner>().RunModal(ServiceStrings.RetrievingMultipleVersionsOfFile,
                                                                                         delegate(object sender, ProgressWorkerArgs e)
                {
                    SvnFileVersionsArgs ea = new SvnFileVersionsArgs();
                    ea.Start = from;
                    ea.End   = to;
                    ea.AddExpectedError(SvnErrorCode.SVN_ERR_UNSUPPORTED_FEATURE);     // Github

                    e.Client.FileVersions(target, ea,
                                          delegate(object sender2, SvnFileVersionEventArgs e2)
                    {
                        if (n++ == 0)
                        {
                            e2.WriteTo(f1);
                        }
                        else
                        {
                            e2.WriteTo(f2);
                        }
                    });
                });

                if (!r.Succeeded)
                {
                    return(null);
                }

                if (n != 2)
                {
                    // Sloooooow workaround for SvnBridge / Codeplex

                    f1 = GetTempFile(target, from, withProgress);
                    if (f1 == null)
                    {
                        return(null); // Canceled
                    }
                    f2 = GetTempFile(target, to, withProgress);
                }
            }
            else
            {
                f1 = GetTempFile(target, from, withProgress);
                if (f1 == null)
                {
                    return(null); // Canceled
                }
                f2 = GetTempFile(target, to, withProgress);
            }

            if (string.IsNullOrEmpty(f1) || string.IsNullOrEmpty(f2))
            {
                return(null);
            }

            string[] files = new string[] { f1, f2 };

            foreach (string f in files)
            {
                if (File.Exists(f))
                {
                    File.SetAttributes(f, FileAttributes.ReadOnly);
                }
            }

            return(files);
        }
Esempio n. 31
0
		public override Annotation[] GetAnnotations (Repository repo, FilePath file, SvnRevision revStart, SvnRevision revEnd)
		{
			if (file == FilePath.Null)
				throw new ArgumentNullException ();
				
			LibSvnClient.Rev revisionStart = (LibSvnClient.Rev) revStart;
			LibSvnClient.Rev revisionEnd = (LibSvnClient.Rev) revEnd;
			
			int numAnnotations = File.ReadAllLines (((SubversionRepository)repo).GetPathToBaseText(file)).Length;
			Annotation[] annotations = new Annotation [numAnnotations];
			
			AnnotationCollector collector = new AnnotationCollector (annotations);
			
			IntPtr localpool = newpool (pool);
			
			try {
				string path = NormalizePath (file.FullPath, localpool);
				CheckError (svn.client_blame (path, ref revisionStart, ref revisionEnd, new LibSvnClient.svn_client_blame_receiver_t (collector.Func), IntPtr.Zero, ctx, localpool));
			} finally {
				apr.pool_destroy (localpool);
			}
			
			return annotations;
		}
Esempio n. 32
0
		public override void Move (FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, ProgressMonitor monitor)
		{
			if (srcPath == FilePath.Null || destPath == FilePath.Null || monitor == null)
				throw new ArgumentNullException ();
			
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;

			nb = new notify_baton ();
			IntPtr commit_info = IntPtr.Zero;
			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (monitor);
				string nsrcPath = NormalizePath (srcPath, localpool);
				string ndestPath = NormalizePath (destPath, localpool);
				CheckError (svn.client_move (ref commit_info, nsrcPath, ref revision,
				                             ndestPath, force, ctx, localpool));
			} finally {
				TryEndOperation (localpool);
			}
		}
Esempio n. 33
0
		public override Annotation[] GetAnnotations (Repository repo, FilePath file, SvnRevision revStart, SvnRevision revEnd)
		{
			if (file == FilePath.Null)
				throw new ArgumentNullException ();
				
			LibSvnClient.Rev revisionStart = (LibSvnClient.Rev) revStart;
			LibSvnClient.Rev revisionEnd = (LibSvnClient.Rev) revEnd;

			MemoryStream data = new MemoryStream ();
			int numAnnotations = 0;
			Cat (file, SvnRevision.Base, data);

			using (StreamReader reader = new StreamReader (data)) {
				reader.BaseStream.Seek (0, SeekOrigin.Begin);
				while (reader.ReadLine () != null)
					numAnnotations++;
			}

			Annotation[] annotations = new Annotation [numAnnotations];
			AnnotationCollector collector = new AnnotationCollector (annotations, repo);

			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (null);
				string path = NormalizePath (file.FullPath, localpool);
				CheckError (svn.client_blame (path, ref revisionStart, ref revisionEnd, collector.Func, IntPtr.Zero, ctx, localpool));
			} finally {
				TryEndOperation (localpool);
			}
			
			return annotations;
		}
Esempio n. 34
0
		public override IEnumerable<VersionInfo> Status (Repository repo, FilePath path, SvnRevision rev, bool descendDirs, bool changedItemsOnly, bool remoteStatus)
		{
			if (path == FilePath.Null)
				throw new ArgumentNullException ();
		
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			ArrayList ret = new ArrayList ();
			
			StatusCollector collector = new StatusCollector (ret);
			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (null);
				string pathorurl = NormalizePath (path, localpool);
				CheckError (svn.client_status (IntPtr.Zero, pathorurl, ref revision,
				                               collector.Func,
				                               IntPtr.Zero, descendDirs, 
				                               !changedItemsOnly, 
				                               remoteStatus,
				                               false,
				                               false,
				                               ctx, localpool));
			} catch (SubversionException e) {
				// SVN_ERR_WC_NOT_WORKING_COPY and SVN_ERR_WC_NOT_FILE.
				if (e.ErrorCode != 155007 && e.ErrorCode != 155008)
					throw;
			} finally {
				TryEndOperation (localpool);
			}

			List<VersionInfo> nodes = new List<VersionInfo>();
			foreach (LibSvnClient.StatusEnt ent in ret)
				nodes.Add (CreateNode (ent, repo));
			return nodes;
		}
Esempio n. 35
0
		public override IEnumerable<DirectoryEntry> List (FilePath path, bool recurse, SvnRevision rev)
		{
			return ListUrl (path, recurse, rev);
		}
Esempio n. 36
0
		static VersionInfo CreateNode (LibSvnClient.StatusEnt ent, Repository repo) 
		{
			VersionStatus rs = VersionStatus.Unversioned;
			Revision rr = null;
			
			if (ent.RemoteTextStatus != LibSvnClient.svn_wc_status_kind.EMPTY) {
				rs = ConvertStatus (LibSvnClient.NodeSchedule.Normal, ent.RemoteTextStatus);
				rr = new SvnRevision (repo, ent.LastCommitRevision, ent.LastCommitDate,
				                      ent.LastCommitAuthor, GettextCatalog.GetString ("(unavailable)"), null);
			}

			VersionStatus status = ConvertStatus (ent.Schedule, ent.TextStatus);
			
			bool readOnly = File.Exists (ent.LocalFilePath) && (File.GetAttributes (ent.LocalFilePath) & FileAttributes.ReadOnly) != 0;
			
			if (ent.RepoLocked) {
				status |= VersionStatus.LockRequired;
				if (ent.LockOwned)
					status |= VersionStatus.LockOwned;
				else
					status |= VersionStatus.Locked;
			} else if (readOnly)
				status |= VersionStatus.LockRequired;

			VersionInfo ret = new VersionInfo (ent.LocalFilePath, ent.Url, ent.IsDirectory,
			                                   status, new SvnRevision (repo, ent.Revision),
			                                   rs, rr);
			return ret;
		}
Esempio n. 37
0
                public SimpleRevisionType(SvnRevision rev, string title)
                {
                    if (rev == null)
                        throw new ArgumentNullException("rev");
                    else if (string.IsNullOrEmpty(title))
                        throw new ArgumentNullException("title");

                    _rev = rev;
                    _title = title;
                }
Esempio n. 38
0
		public override IEnumerable<DirectoryEntry> ListUrl (string url, bool recurse, SvnRevision rev)
		{
			if (url == null)
				throw new ArgumentNullException ();

			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			IntPtr localpool = TryStartOperation (null);
			List<DirectoryEntry> items = new List<DirectoryEntry> ();

			try {
				IntPtr hash;
				
				url = NormalizePath (url, localpool);
				
				CheckError (svn.client_ls (out hash, url, ref revision,
				                           recurse, ctx, localpool));
				
				IntPtr item = apr.hash_first (localpool, hash);
				while (item != IntPtr.Zero) {
					IntPtr nameptr, val;
					int namelen;
					apr.hash_this (item, out nameptr, out namelen, out val);
					
					string name = Marshal.PtrToStringAnsi (nameptr);
					LibSvnClient.svn_dirent_t ent = (LibSvnClient.svn_dirent_t) Marshal.PtrToStructure (val, typeof (LibSvnClient.svn_dirent_t));				
					item = apr.hash_next (item);
					
					DirectoryEntry dent = new DirectoryEntry ();
					dent.Name = name;
					dent.IsDirectory = ent.kind == LibSvnClient.svn_node_kind_t.Dir;
					dent.Size = ent.size;
					dent.HasProps = ent.has_props;
					dent.CreatedRevision = (int) ent.created_rev;
					dent.Time = new DateTime (1970, 1, 1).AddTicks(ent.time * 10);
					dent.LastAuthor = ent.last_author;
					items.Add (dent);
				}
			} finally {
				apr.pool_destroy (localpool);
				TryEndOperation ();
			}
			
			return items;
		}
Esempio n. 39
0
		public override IEnumerable<SvnRevision> Log (Repository repo, FilePath path, SvnRevision revStart, SvnRevision revEnd)
		{
			if (path == FilePath.Null)
				throw new ArgumentNullException ();
			
			LibSvnClient.Rev revisionStart = (LibSvnClient.Rev) revStart;
			LibSvnClient.Rev revisionEnd = (LibSvnClient.Rev) revEnd;
			
			List<SvnRevision> ret = new List<SvnRevision> ();
			IntPtr localpool = newpool (pool);
			IntPtr strptr = IntPtr.Zero;
			try {
				IntPtr array = apr.array_make (localpool, 0, IntPtr.Size);
				IntPtr first = apr.array_push (array);
				string pathorurl = NormalizePath (path, localpool);
				strptr = Marshal.StringToHGlobalAnsi (pathorurl);
				Marshal.WriteIntPtr (first, strptr);
				
				LogCollector collector = new LogCollector (ret);
				
				CheckError (svn.client_log (array, ref revisionStart, ref revisionEnd, 1, 0,
				                            new LibSvnClient.svn_log_message_receiver_t (collector.Func),
				                            IntPtr.Zero, ctx, localpool));
			} finally {
				if (strptr != IntPtr.Zero)
					Marshal.FreeHGlobal (strptr);
				apr.pool_destroy (localpool);
			}
			
			return ret;
		}
        private RevisionPropertyCollection GetRevisionProperties(string url, SvnRevision revision)
        {
            try
            {
                SvnPropertyCollection propertyCollection;
                client.GetRevisionPropertyList(CreateSvnUriTarget(url, revision), out propertyCollection);
                RevisionPropertyCollection revisionPropertyCollection = new RevisionPropertyCollection((int)revision.Revision);
                foreach (SvnPropertyValue value in propertyCollection) {
                    revisionPropertyCollection.Add(value.Key, value.StringValue);
                }
                return revisionPropertyCollection;
            }
            catch(Exception ex)
            {
                OnError(ex);
            }

            return null;
        }
        private PropertiesCollection GetProperties(string target, SvnRevision asOfRevision, bool recurse)
        {
            try
            {
                PropertiesCollection result = new PropertiesCollection();
                Collection<SvnPropertyListEventArgs> output;
                SvnPropertyListArgs args = new SvnPropertyListArgs();
                args.Revision = asOfRevision;
                args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children;

                client.GetPropertyList(new Uri(target), args, out output);

                foreach (SvnPropertyListEventArgs eventArgs in output) {
                    Dictionary<string, string> properties = new Dictionary<string, string>(eventArgs.Properties.Count);
                    foreach (SvnPropertyValue value in eventArgs.Properties) {
                        properties.Add(value.Key, value.StringValue);
                    }
                    result.Add(eventArgs.Path, properties);
                }

                return result;
            }
            catch(Exception ex)
            {
                OnError(ex);
            }

            return null;
        }
 private int Checkout(string repoUrl, string workingPath, SvnRevision revision, bool recurse, bool ignoreExternals)
 {
     try
     {
         SvnCheckOutArgs args = new SvnCheckOutArgs();
         args.Revision = revision;
         args.IgnoreExternals = ignoreExternals;
         args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children;
         SvnUpdateResult result;
         client.CheckOut(new Uri(repoUrl), workingPath, args, out result);
         return (int) result.Revision;
     }
     catch (Exception ex)
     {
         OnError(ex);
     }
     return int.MinValue;
 }
Esempio n. 43
0
			IntPtr CollectorFunc (IntPtr baton, IntPtr apr_hash_changed_paths, svn_revnum_t revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
			{
				long time;
				svn.time_from_cstring (out time, Marshal.PtrToStringAnsi (date), pool);
				string smessage = "";
				
				if (message != IntPtr.Zero)
					smessage = Marshal.PtrToStringAnsi (message);
				
				if (smessage != null)
					smessage = smessage.Trim ();
				
				List<RevisionPath> items = new List<RevisionPath>();
				
				IntPtr item = apr.hash_first (pool, apr_hash_changed_paths);
				while (item != IntPtr.Zero) {
					IntPtr nameptr, val;
					int namelen;
					apr.hash_this (item, out nameptr, out namelen, out val);
					
					string name = Marshal.PtrToStringAnsi (nameptr);
					LibSvnClient.svn_log_changed_path_t ch = (LibSvnClient.svn_log_changed_path_t) Marshal.PtrToStructure (val, typeof(LibSvnClient.svn_log_changed_path_t));
					item = apr.hash_next (item);
					
					RevisionAction ac;
					switch (ch.action) {
						case 'A': ac = RevisionAction.Add; break;
						case 'D': ac = RevisionAction.Delete; break;
						case 'R': ac = RevisionAction.Replace; break;
						default: ac = RevisionAction.Modify; break; // should be an 'M'
					}
					
					IntPtr result = IntPtr.Zero;

					SvnClient.CheckError (svn.client_root_url_from_path (ref result, repo.RootPath, ctx, pool));
					if (result == IntPtr.Zero) // Should never happen
						items.Add (new RevisionPath (name, ac, ""));
					else
						items.Add (new RevisionPath (Marshal.PtrToStringAnsi (result) + "/" + name, ac, ""));
				}
				
				SvnRevision ent = new SvnRevision (null, (int) revision, Epoch.AddTicks (time * 10), Marshal.PtrToStringAnsi (author), smessage, items.ToArray ());
				logs.Add (ent);
				
				return IntPtr.Zero;
			}
Esempio n. 44
0
        static void PerformLog(IAnkhServiceProvider context, ICollection<SvnOrigin> targets, SvnRevision start, SvnRevision end)
        {
            IAnkhPackage package = context.GetService<IAnkhPackage>();

            package.ShowToolWindow(AnkhToolWindow.Log);

            LogToolWindowControl logToolControl = context.GetService<ISelectionContext>().ActiveFrameControl as LogToolWindowControl;
            if (logToolControl != null)
                logToolControl.StartLog(targets, start, end);
        }
Esempio n. 45
0
			IntPtr CollectorFunc (IntPtr baton, IntPtr apr_hash_changed_paths, svn_revnum_t revision, IntPtr author, IntPtr date, IntPtr message, IntPtr pool)
			{
				// Taken from https://subversion.apache.org/docs/api/1.8/group__Log.html#ga43d8607236ca1bd5c2d9b41acfb62b7e
				// Don't hash it when it's null. 
				if (apr_hash_changed_paths == IntPtr.Zero)
					return IntPtr.Zero;

				long time;
				svn.time_from_cstring (out time, Marshal.PtrToStringAnsi (date), pool);
				string smessage = "";

				if (message != IntPtr.Zero)
					smessage = Marshal.PtrToStringAnsi (message);
				
				if (smessage != null)
					smessage = smessage.Trim ();
				
				List<RevisionPath> items = new List<RevisionPath>();
				IntPtr item = apr.hash_first (pool, apr_hash_changed_paths);
				LibSvnClient.svn_log_changed_path_t ch;
				string name;

				while (apr.hash_iterate(ref item, out ch, out name)) {
					RevisionAction ac;
					switch (ch.action) {
						case 'A': ac = RevisionAction.Add; break;
						case 'D': ac = RevisionAction.Delete; break;
						case 'R': ac = RevisionAction.Replace; break;
						default: ac = RevisionAction.Modify; break; // should be an 'M'
					}
					
					IntPtr result = IntPtr.Zero;

					SvnClient.CheckError (svn.client_root_url_from_path (ref result, repo.RootPath, ctx, pool));
					if (result == IntPtr.Zero) // Should never happen
						items.Add (new RevisionPath (name, ac, ""));
					else
						items.Add (new RevisionPath (Marshal.PtrToStringAnsi (result) + "/" + name, ac, ""));
				}
				
				SvnRevision ent = new SvnRevision (null, (int) revision, Epoch.AddTicks (time * 10), Marshal.PtrToStringAnsi (author), smessage, items.ToArray ());
				logs.Add (ent);
				
				return IntPtr.Zero;
			}
		public override string[] RetrieveAuthors(DateRange dateRange)
		{
			var startRevision = new SvnRevision(dateRange.StartDate.GetValueOrDefault());
			var endRevision = new SvnRevision(dateRange.EndDate.GetValueOrDefault());

			var range = new SvnRevisionRange(startRevision, endRevision);
			var result = GetSvnRevisions(new SvnLogArgs(range));
			return result.Select(x => x.Author).Where(y => !string.IsNullOrEmpty(y)).Distinct().ToArray();
		}
Esempio n. 47
0
		public override IEnumerable<DirectoryEntry> ListUrl (string url, bool recurse, SvnRevision rev)
		{
			if (url == null)
				throw new ArgumentNullException ();

			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			IntPtr localpool = IntPtr.Zero;
			List<DirectoryEntry> items = new List<DirectoryEntry> ();

			try {
				IntPtr hash;

				localpool = TryStartOperation (null);
				url = NormalizePath (url, localpool);
				
				CheckError (svn.client_ls (out hash, url, ref revision,
				                           recurse, ctx, localpool));
				
				IntPtr item = apr.hash_first (localpool, hash);
				LibSvnClient.svn_dirent_t ent;
				string name;
				while (apr.hash_iterate<LibSvnClient.svn_dirent_t>(ref item, out ent, out name)) {
					var dent = new DirectoryEntry {
						Name = name,
						IsDirectory = ent.kind == LibSvnClient.svn_node_kind_t.Dir,
						Size = ent.size,
						HasProps = ent.has_props,
						CreatedRevision = (int) ent.created_rev,
						Time = new DateTime (1970, 1, 1).AddTicks(ent.time * 10),
						LastAuthor = ent.last_author,
					};
					items.Add (dent);
				}
			} finally {
				TryEndOperation (localpool);
			}
			
			return items;
		}
Esempio n. 48
0
        private static void CheckOutAndOpenSolution(CommandEventArgs e, SvnUriTarget checkoutLocation, SvnRevision revision, Uri projectTop, string localDir, Uri projectUri)
        {
            IProgressRunner runner = e.GetService<IProgressRunner>();

            runner.RunModal("Checking Out Solution",
                delegate(object sender, ProgressWorkerArgs ee)
                    {
                        PerformCheckout(ee, checkoutLocation, revision, localDir);
                    });

            Uri file = projectTop.MakeRelativeUri(projectUri);

            string projectFile = SvnTools.GetNormalizedFullPath(Path.Combine(localDir, SvnTools.UriPartToPath(file.ToString())));

            OpenProject(e, projectFile);
        }
Esempio n. 49
0
		public override IEnumerable<SvnRevision> Log (Repository repo, FilePath path, SvnRevision revStart, SvnRevision revEnd)
		{
			if (path == FilePath.Null)
				throw new ArgumentNullException ();
			
			LibSvnClient.Rev revisionStart = (LibSvnClient.Rev) revStart;
			LibSvnClient.Rev revisionEnd = (LibSvnClient.Rev) revEnd;

			List<SvnRevision> ret = new List<SvnRevision> ();
			IntPtr strptr = IntPtr.Zero;

			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (null);
				IntPtr array = apr.array_make (localpool, 0, IntPtr.Size);
				IntPtr first = apr.array_push (array);
				string pathorurl = NormalizePath (path, localpool);
				strptr = Marshal.StringToHGlobalAnsi (pathorurl);
				Marshal.WriteIntPtr (first, strptr);
				
				LogCollector collector = new LogCollector ((SubversionRepository)repo, ret, ctx);
				
				CheckError (svn.client_log (array, ref revisionStart, ref revisionEnd, true, false,
				                            collector.Func,
				                            IntPtr.Zero, ctx, localpool));
			} finally {
				if (strptr != IntPtr.Zero)
					Marshal.FreeHGlobal (strptr);
				TryEndOperation (localpool);
			}
			
			return ret;
		}
Esempio n. 50
0
        private static void PerformCheckout(ProgressWorkerArgs e, SvnUriTarget projectTop, SvnRevision revision, string localDir)
        {
            SvnCheckOutArgs a = new SvnCheckOutArgs();
            a.Revision = revision;

            e.Client.CheckOut(projectTop, localDir, a);
        }
Esempio n. 51
0
		public void Cat (string pathorurl, SvnRevision rev, Stream stream)
		{
			if (pathorurl == null || stream == null)
				throw new ArgumentNullException ();
		
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			
			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (null);
				pathorurl = NormalizePath (pathorurl, localpool);
				StreamCollector collector = new StreamCollector (stream);
				IntPtr svnstream = svn.stream_create (IntPtr.Zero, localpool);
				svn.stream_set_write (svnstream, collector.Func);
				// Setting peg_revision to revision.
				// Otherwise, it will use Head as peg and it will throw exceptions.
				CheckError (svn.client_cat2 (svnstream, pathorurl, ref revision, ref revision, ctx, localpool), 195007);
			} finally {
				TryEndOperation (localpool);
			}
		}
Esempio n. 52
0
		public override void Move (FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, IProgressMonitor monitor)
		{
			if (srcPath == FilePath.Null || destPath == FilePath.Null || monitor == null)
				throw new ArgumentNullException ();
			
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			
			lock (sync) {
				if (inProgress)
					throw new SubversionException ("Another Subversion operation is already in progress.");
				inProgress = true;
			}
			
			nb = new notify_baton ();
			updatemonitor = monitor;
			IntPtr commit_info = IntPtr.Zero;
			IntPtr localpool = newpool (pool);
			try {
				string nsrcPath = NormalizePath (srcPath, localpool);
				string ndestPath = NormalizePath (destPath, localpool);
				CheckError (svn.client_move (ref commit_info, nsrcPath, ref revision,
				                             ndestPath, (force ? 1 : 0), ctx, localpool));
			} finally {
				apr.pool_destroy (localpool);
				updatemonitor = null;
				inProgress = false;
			}
		}
Esempio n. 53
0
		public override string GetUnifiedDiff (FilePath path1, SvnRevision rev1, FilePath path2, SvnRevision rev2, bool recursive)
		{
			IntPtr outfile = IntPtr.Zero;
			IntPtr errfile = IntPtr.Zero;
			string fout = null;
			string ferr = null;
			
			LibSvnClient.Rev revision1 = (LibSvnClient.Rev) rev1;
			LibSvnClient.Rev revision2 = (LibSvnClient.Rev) rev2;
			
			IntPtr localpool = IntPtr.Zero;
			try {
				localpool = TryStartOperation (null);
				IntPtr options = apr.array_make (localpool, 0, IntPtr.Size);
				
				fout = Path.GetTempFileName ();
				ferr = Path.GetTempFileName ();
				int res1 = apr.file_open (ref outfile, fout, LibApr.APR_WRITE | LibApr.APR_CREATE | LibApr.APR_TRUNCATE, LibApr.APR_OS_DEFAULT, localpool);
				int res2 = apr.file_open (ref errfile, ferr, LibApr.APR_WRITE | LibApr.APR_CREATE | LibApr.APR_TRUNCATE, LibApr.APR_OS_DEFAULT, localpool);
				
				if (res1 == 0 && res2 == 0) {
					string npath1 = NormalizePath (path1, localpool);
					string npath2 = NormalizePath (path2, localpool);
					CheckError (svn.client_diff (options, npath1, ref revision1, npath2, ref revision2, recursive, false, true, outfile, errfile, ctx, localpool));
					return TextFile.ReadFile (fout).Text;
				} else {
					throw new Exception ("Could not get diff information");
				}
			} catch {
				try {
					if (outfile != IntPtr.Zero)
						apr.file_close (outfile);
					outfile = IntPtr.Zero;
				} catch {}
				throw;
			} finally {
				try {
					// Cleanup
					if (outfile != IntPtr.Zero)
						apr.file_close (outfile); 
					if (errfile != IntPtr.Zero)
						apr.file_close (errfile);
					if (ferr != null)
						FileService.DeleteFile (ferr);
					if (fout != null)
						FileService.DeleteFile (fout);
				} catch {
				} finally {
					TryEndOperation (localpool);
				}
			}
		}
Esempio n. 54
0
 public PropertyEditorDialog(Uri target, SvnRevision revision, bool revisionProps)
     : this(revisionProps ? string.Format(PropertyEditStrings.RevisionXPropertiesFromY, revision, target) : target.ToString())
 {
     _currentNodeKind = SvnNodeKind.None;
     _revisionProps   = revisionProps;
 }
Esempio n. 55
0
 public PropertyEditorDialog(Uri target, SvnRevision revision, bool revisionProps)
     : this(revisionProps ? string.Format(PropertyEditStrings.RevisionXPropertiesFromY, revision, target) : target.ToString())
 {
     _currentNodeKind = SvnNodeKind.None;
     _revisionProps = revisionProps;
 }
Esempio n. 56
0
 private void CheckoutSvn(SvnRevision revision)
 {
     m_svnClient.Checkout2(m_svnurl, m_svndir, revision, revision, true, false);
 }
Esempio n. 57
0
		public void Cat (string pathorurl, SvnRevision rev, Stream stream)
		{
			if (pathorurl == null || stream == null)
				throw new ArgumentNullException ();
		
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			
			IntPtr localpool = newpool (pool);
			try {
				pathorurl = NormalizePath (pathorurl, localpool);
				StreamCollector collector = new StreamCollector (stream);
				IntPtr svnstream = svn.stream_create (IntPtr.Zero, localpool);
				svn.stream_set_write (svnstream, new LibSvnClient.svn_readwrite_fn_t (collector.Func));
				LibSvnClient.Rev peg_revision = LibSvnClient.Rev.Blank;
				CheckError (svn.client_cat2 (svnstream, pathorurl, ref peg_revision, ref revision, ctx, localpool));
			} finally {
				apr.pool_destroy (localpool);
			}
		}
 private static SvnUriTarget CreateSvnUriTarget(string uriString, SvnRevision revision)
 {
     Uri uri = new Uri(uriString);
     SvnUriTarget target = new SvnUriTarget(uri, revision);
     return target;
 }
Esempio n. 59
0
		public override IEnumerable<VersionInfo> Status (Repository repo, FilePath path, SvnRevision rev, bool descendDirs, bool changedItemsOnly, bool remoteStatus)
		{
			if (path == FilePath.Null)
				throw new ArgumentNullException ();
		
			LibSvnClient.Rev revision = (LibSvnClient.Rev) rev;
			ArrayList ret = new ArrayList ();
			
			StatusCollector collector = new StatusCollector (ret);
			var localpool = TryStartOperation (null);
			try {
				string pathorurl = NormalizePath (path, localpool);
				CheckError (svn.client_status (IntPtr.Zero, pathorurl, ref revision,
				                               collector.Func,
				                               IntPtr.Zero, descendDirs, 
				                               !changedItemsOnly, 
				                               remoteStatus,
				                               false,
				                               false,
				                               ctx, localpool));
			} finally {
				apr.pool_destroy (localpool);
				TryEndOperation ();
			}

			List<VersionInfo> nodes = new List<VersionInfo>();
			foreach (LibSvnClient.StatusEnt ent in ret)
				nodes.Add (CreateNode (ent, repo));
			return nodes;
		}
Esempio n. 60
0
        public override void OnExecute(CommandEventArgs e)
        {
            SvnItem theItem = null;
            string  path;
            bool    allowObstructions = false;

            string projectRoot = e.GetService <IAnkhSolutionSettings>().ProjectRoot;

            if (e.Command == AnkhCommand.SolutionSwitchDialog)
            {
                path = projectRoot;
            }
            else if (e.Command == AnkhCommand.SwitchProject)
            {
                IProjectFileMapper mapper = e.GetService <IProjectFileMapper>();
                path = null;

                foreach (SccProject item in e.Selection.GetSelectedProjects(true))
                {
                    ISccProjectInfo pi = mapper.GetProjectInfo(item);

                    if (pi == null)
                    {
                        continue;
                    }

                    path = pi.ProjectDirectory;
                    break;
                }

                if (string.IsNullOrEmpty(path))
                {
                    return;
                }
            }
            else
            {
                foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false))
                {
                    if (item.IsVersioned)
                    {
                        theItem = item;
                        break;
                    }
                    return;
                }
                path = theItem.FullPath;
            }

            ISvnStatusCache statusCache = e.GetService <ISvnStatusCache>();

            SvnItem pathItem = statusCache[path];
            Uri     uri      = pathItem.Uri;

            if (uri == null)
            {
                return; // Should never happen on a real workingcopy
            }
            SvnUriTarget target;
            SvnRevision  revision = SvnRevision.None;

            if (e.Argument is string)
            {
                target   = SvnUriTarget.FromString((string)e.Argument, true);
                revision = (target.Revision != SvnRevision.None) ? target.Revision : SvnRevision.Head;
            }
            else if (e.Argument is Uri)
            {
                target = (Uri)e.Argument;
            }
            else
            {
                using (SwitchDialog dlg = new SwitchDialog())
                {
                    dlg.Context = e.Context;

                    dlg.LocalPath      = path;
                    dlg.RepositoryRoot = e.GetService <ISvnStatusCache>()[path].WorkingCopy.RepositoryRoot;
                    dlg.SwitchToUri    = uri;
                    dlg.Revision       = SvnRevision.Head;

                    if (dlg.ShowDialog(e.Context) != DialogResult.OK)
                    {
                        return;
                    }

                    target            = dlg.SwitchToUri;
                    revision          = dlg.Revision;
                    allowObstructions = dlg.AllowUnversionedObstructions;
                }
            }

            // Get a list of all documents below the specified paths that are open in editors inside VS
            HybridCollection <string> lockPaths       = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
            IAnkhOpenDocumentTracker  documentTracker = e.GetService <IAnkhOpenDocumentTracker>();

            foreach (string file in documentTracker.GetDocumentsBelow(path))
            {
                if (!lockPaths.Contains(file))
                {
                    lockPaths.Add(file);
                }
            }

            documentTracker.SaveDocuments(lockPaths); // Make sure all files are saved before merging!

            using (DocumentLock lck = documentTracker.LockDocuments(lockPaths, DocumentLockType.NoReload))
                using (lck.MonitorChangesForReload())
                {
                    Uri newRepositoryRoot = null;
                    e.GetService <IProgressRunner>().RunModal(CommandStrings.SwitchingTitle,
                                                              delegate(object sender, ProgressWorkerArgs a)
                    {
                        SvnSwitchArgs args     = new SvnSwitchArgs();
                        args.AllowObstructions = allowObstructions;
                        args.AddExpectedError(SvnErrorCode.SVN_ERR_WC_INVALID_SWITCH);

                        if (revision != SvnRevision.None)
                        {
                            args.Revision = revision;
                        }

                        e.GetService <IConflictHandler>().RegisterConflictHandler(args, a.Synchronizer);
                        if (!a.Client.Switch(path, target, args))
                        {
                            if (args.LastException.SvnErrorCode != SvnErrorCode.SVN_ERR_WC_INVALID_SWITCH)
                            {
                                return;
                            }

                            // source/target repository is different, check if we can fix this by relocating
                            SvnInfoEventArgs iea;
                            if (a.Client.GetInfo(target, out iea))
                            {
                                if (pathItem.WorkingCopy.RepositoryId != iea.RepositoryId)
                                {
                                    e.Context.GetService <IAnkhDialogOwner>()
                                    .MessageBox.Show("Cannot switch to different repository because the repository UUIDs are different",
                                                     "Cannot switch", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                                else if (pathItem.WorkingCopy.RepositoryRoot != iea.RepositoryRoot)
                                {
                                    newRepositoryRoot = iea.RepositoryRoot;
                                }
                                else if (pathItem.WorkingCopy.RepositoryId == Guid.Empty)
                                {
                                    // No UUIDs and RepositoryRoot equal. Throw/show error?

                                    throw args.LastException;
                                }
                            }
                        }
                    });

                    if (newRepositoryRoot != null && DialogResult.Yes == e.Context.GetService <IAnkhDialogOwner>()
                        .MessageBox.Show(string.Format("The repository root specified is different from the one in your " +
                                                       "working copy. Would you like to relocate '{0}' from '{1}' to '{2}'?",
                                                       pathItem.WorkingCopy.FullPath,
                                                       pathItem.WorkingCopy.RepositoryRoot, newRepositoryRoot),
                                         "Relocate", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        // We can fix this by relocating
                        string wcRoot = pathItem.WorkingCopy.FullPath;
                        try
                        {
                            e.GetService <IProgressRunner>().RunModal(
                                CommandStrings.RelocatingTitle,
                                delegate(object sender, ProgressWorkerArgs a)
                            {
                                a.Client.Relocate(wcRoot, pathItem.WorkingCopy.RepositoryRoot, newRepositoryRoot);
                            });
                        }
                        finally
                        {
                            statusCache.MarkDirtyRecursive(wcRoot);
                            e.GetService <IFileStatusMonitor>().ScheduleGlyphUpdate(statusCache.GetCachedBelow(wcRoot));
                        }


                        if (DialogResult.Yes == e.Context.GetService <IAnkhDialogOwner>()
                            .MessageBox.Show(string.Format("Would you like to try to switch '{0}' to '{1}' again?",
                                                           path, target),
                                             "Switch", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                        {
                            // Try to switch again
                            e.GetService <IProgressRunner>().RunModal(
                                CommandStrings.SwitchingTitle,
                                delegate(object sender, ProgressWorkerArgs a)
                            {
                                SvnSwitchArgs args = new SvnSwitchArgs();

                                if (revision != SvnRevision.None)
                                {
                                    args.Revision = revision;
                                }

                                args.AllowObstructions = allowObstructions;

                                e.GetService <IConflictHandler>().RegisterConflictHandler(args, a.Synchronizer);
                                a.Client.Switch(path, target, args);
                            });
                        }
                    }
                }
        }