예제 #1
0
        public void ChangeInfo_GetInfoCompare()
        {
            SvnSandBox sbox      = new SvnSandBox(this);
            Uri        reposUri  = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string     reposPath = reposUri.LocalPath;

            using (SvnClient cl = new SvnClient())
            {
                SvnSetPropertyArgs sa = new SvnSetPropertyArgs();
                sa.BaseRevision = 17;
                sa.LogMessage   = "Message";
                cl.RemoteSetProperty(reposUri, "MyProp", "Value", sa);
            }

            for (long ii = 1; ii < 19; ii++)
            {
                using (SvnLookClient lcl = new SvnLookClient())
                    using (SvnClient cl = new SvnClient())
                    {
                        SvnChangeInfoEventArgs r;
                        SvnChangeInfoArgs      ia     = new SvnChangeInfoArgs();
                        SvnLookOrigin          origin = new SvnLookOrigin(reposPath, ii);

                        SvnLogArgs la = new SvnLogArgs();
                        la.Start = la.End = ii;

                        Collection <SvnLogEventArgs> lrc;
                        //ia.RetrieveChangedPaths = false; // Will fail if true
                        Assert.That(lcl.GetChangeInfo(origin, ia, out r));
                        Assert.That(cl.GetLog(reposUri, la, out lrc));

                        Assert.That(r, Is.Not.Null);
                        Assert.That(lrc.Count, Is.EqualTo(1));

                        SvnLogEventArgs lr = lrc[0];

                        Assert.That(r.Author, Is.EqualTo(lr.Author));
                        Assert.That(r.Revision, Is.EqualTo(lr.Revision));
                        Assert.That(r.BaseRevision, Is.EqualTo(lr.Revision - 1));
                        Assert.That(r.LogMessage, Is.EqualTo(lr.LogMessage));
                        Assert.That(r.Time, Is.EqualTo(lr.Time));

                        Assert.That(r.ChangedPaths, Is.Not.Null, "r.ChangedPaths({0})", ii);
                        Assert.That(lr.ChangedPaths, Is.Not.Null, "lr.ChangedPaths({0})", ii);

                        Assert.That(r.ChangedPaths.Count, Is.EqualTo(lr.ChangedPaths.Count));

                        for (int i = 0; i < r.ChangedPaths.Count; i++)
                        {
                            SvnChangeItem c  = r.ChangedPaths[i];
                            SvnChangeItem lc = lr.ChangedPaths[c.Path];

                            Assert.That(c.Path, Is.EqualTo(lc.Path));
                            Assert.That(c.Action, Is.EqualTo(lc.Action));
                            Assert.That(c.CopyFromPath, Is.EqualTo(lc.CopyFromPath));
                            Assert.That(c.CopyFromRevision, Is.EqualTo(lc.CopyFromRevision));
                        }
                    }
            }
        }
예제 #2
0
        public PathListViewItem(LogChangedPathsView view, ISvnLogItem logItem, SvnChangeItem change, Uri reposRoot, bool isInSelection, Color[] colorInfo)
            : base(view)
        {
            if (logItem == null)
            {
                throw new ArgumentNullException("logItem");
            }
            if (change == null)
            {
                throw new ArgumentNullException("change");
            }
            _logItem       = logItem;
            _change        = change;
            _isInSelection = isInSelection;
            Uri uri;

            string path = change.Path.TrimStart('/');

            if (string.IsNullOrEmpty(path))
            {
                uri = reposRoot;
            }
            else
            {
                uri = SvnTools.AppendPathSuffix(reposRoot, path);
            }

            _origin = new SvnOrigin(new SvnUriTarget(uri, logItem.Revision), reposRoot);

            RefreshText();
            UpdateColors(colorInfo);
        }
예제 #3
0
 public void Delete(SvnChangeItem node, SvnLogEventArgs e, string destinationPath)
 {
     if (File.Exists(destinationPath) || Directory.Exists(destinationPath))
     {
         _g.Svn.Delete(destinationPath);
         _g.Interaction.Trace("\tDeleted " + destinationPath);
     }
 }
예제 #4
0
 public SvnChangeItemWrapper(SvnChangeItem svnChangeItem)
 {
     this.Action = SvnAction2ItemAction(svnChangeItem.Action);
       this.CopyFromPath = svnChangeItem.CopyFromPath;
       this.CopyFromRevision = svnChangeItem.CopyFromRevision;
       this.NodeKind = SvnNodeKind2ItemNodeKind(svnChangeItem.NodeKind);
       this.Path = svnChangeItem.Path;
       this.RepositoryPath = svnChangeItem.RepositoryPath;
 }
예제 #5
0
파일: TagsHook.cs 프로젝트: takiru/SvnHook
        /// <summary>
        /// 操作がADDかどうかを取得する。
        /// </summary>
        /// <param name="item">SvnChangeItem オブジェクト。</param>
        /// <returns>True:ADD, False:ADD以外。</returns>
        private static bool IsAddAction(SvnChangeItem item)
        {
            if (item.Action == SvnChangeAction.Add)
            {
                return(true);
            }

            return(false);
        }
예제 #6
0
        public void Modify(SvnChangeItem node, SvnLogEventArgs e, string destinationPath)
        {
            var source = _g.Source.GetSourceTarget(node, e.Revision);

            if (node.NodeKind == SvnNodeKind.File)
            {
                _g.Svn.Export(source, destinationPath);
            }
            _g.Interaction.Trace(ActionModified + destinationPath);
            CopyProperties(source, destinationPath);
        }
예제 #7
0
파일: TagsHook.cs 프로젝트: takiru/SvnHook
        /// <summary>
        /// tags ノードかどうかを取得する。
        /// </summary>
        /// <param name="item">SvnChangeItem オブジェクト。</param>
        /// <returns>True:tags ノード, False:tags ノードでない。</returns>
        private static bool IsTagsNode(SvnChangeItem item)
        {
            var tagsPos = item.Path.IndexOf(NodeName);

            // tags の位置よりtrunk, branchesが上位ディレクトリにある場合
            var paths = item.Path.Substring(0, tagsPos).Split('/');

            if (paths.Contains(TrunkHook.NodeName) || paths.Contains(BranchesHook.NodeName))
            {
                return(false);
            }

            return(true);
        }
예제 #8
0
        private bool TryCopy(SvnChangeItem node, string destinationPath)
        {
            var relativePath = _g.Source.GetRelativePath(node.CopyFromPath);

            if (relativePath == null)
            {
                return(false);
            }
            var revision = _g.RevisionMap.FindDestinationRevision(node.CopyFromRevision);

            if (revision < 0)
            {
                return(false);
            }
            // must use server uri as working copy may have been delete when copy from old revision.
            var copyFromUri = new Uri(_g.Destination, relativePath);

            _g.Svn.Copy(new SvnUriTarget(copyFromUri, revision), destinationPath, _ignoreExternalCopyArgs);
            return(true);
        }
예제 #9
0
        public void Add(SvnChangeItem node, SvnLogEventArgs e, string destinationPath)
        {
            if (destinationPath == _g.WorkingDir)
            {
                return;
            }
            var  source    = _g.Source.GetSourceTarget(node, e.Revision);
            bool processed = false;

            if (node.CopyFromPath != null)
            {
                processed = TryCopy(node, destinationPath);
                if (!processed && node.NodeKind == SvnNodeKind.Directory)
                {
                    ExportDirectory(source, destinationPath);
                    return;
                }
            }
            else if (node.NodeKind == SvnNodeKind.Directory)
            {
                _g.Svn.CreateDirectory(destinationPath);
                processed = true;
            }

            if (node.NodeKind != SvnNodeKind.Directory)
            {
                _g.Svn.Export(source, destinationPath, _infiniteOverwriteExport);
            }

            if (!processed)
            {
                _g.Svn.Add(destinationPath, _infiniteForceAdd);
            }

            _g.Interaction.Trace(ActionCreated + destinationPath);
            CopyProperties(source, destinationPath);
        }
예제 #10
0
파일: TagsHook.cs 프로젝트: takiru/SvnHook
        /// <summary>
        /// tags 作成先の最大パスを取得する。
        /// </summary>
        /// <param name="item">SvnChangeItem オブジェクト。</param>
        /// <param name="currentMaxPath">現在の最大パス。</param>
        /// <returns>最大パス。</returns>
        private static string GetCopyFromPathMaxPath(SvnChangeItem item, string currentMaxPath)
        {
            var result = currentMaxPath;

            // 新規作成される中間ディレクトリの場合は何もしない
            if (string.IsNullOrEmpty(item.CopyFromPath))
            {
                return(result);
            }

            if (item.NodeKind == SvnNodeKind.Directory && result.Length < item.Path.Length)
            {
                result = item.Path;
            }
            if (item.NodeKind == SvnNodeKind.File)
            {
                var directory = item.Path.Substring(0, item.Path.LastIndexOf('/'));
                if (result.Length < directory.Length)
                {
                    result = directory;
                }
            }
            return(result);
        }
 public ChangedPathInfo(SvnChangeItem item)
 {
     changeItem = item;
 }
 static bool IsPossibleMergeRevision(SvnChangeItem c)
 {
     return c.NodeKind == SvnNodeKind.Directory && c.Action == SvnChangeAction.Modify;
 }
예제 #13
0
 public SvnUriTarget GetSourceTarget(SvnChangeItem node, SvnRevision revision)
 {
     return(new SvnUriTarget(new Uri(_sourceRoot, node.Path.Substring(1)), revision));
 }
예제 #14
0
        private void OnViewChangeDetails(SvnRevision latestRevision, Uri repoPath, SvnChangeItem p, int secondsToTimeout)
        {
            Task.Factory.StartNew(() =>
            {
                _mediator.NotifyColleaguesAsync <BeginBusyEvent>("Downloading change details...");
                Task.Factory.StartNew(() =>
                {
                    using (var client = new SvnClient())
                    {
                        try
                        {
                            SvnInfoEventArgs info;
                            var absolutePath = Path.Combine(repoPath.ToString(), p.RepositoryPath.ToString());
                            client.GetInfo(absolutePath, out info);
                            using (MemoryStream latest = new MemoryStream(), previous = new MemoryStream())
                            {
                                client.Write(new SvnUriTarget(absolutePath, latestRevision), latest);
                                client.Write(new SvnUriTarget(absolutePath, new SvnRevision(latestRevision.Revision - 1)), previous);
                                latest.Seek(0, SeekOrigin.Begin);
                                previous.Seek(0, SeekOrigin.Begin);

                                var ext = Path.HasExtension(p.Path) ? Path.GetExtension(p.Path) : ".txt";
                                string latFileOnDisk = Path.Combine(ApplicationSettings.Instance.DiffDirectory, string.Format("{0}_{1}.{2}", Path.GetFileNameWithoutExtension(p.Path), latestRevision.Revision, ext));
                                using (var latestFile = File.OpenWrite(latFileOnDisk))
                                {
                                    latest.WriteTo(latestFile);
                                    latestFile.Flush();
                                }

                                string prevFileOnDisk = Path.Combine(ApplicationSettings.Instance.DiffDirectory, string.Format("{0}_{1}.{2}", Path.GetFileNameWithoutExtension(p.Path), (latestRevision.Revision - 1), ext));
                                using (var previousFile = File.OpenWrite(prevFileOnDisk))
                                {
                                    previous.WriteTo(previousFile);
                                    previousFile.Flush();
                                }

                                _mediator.NotifyColleaguesAsync <EndBusyEvent>(null);

                                // background this so that our callbacks are not waiting on this complete (unnecessary)
                                Task.Factory.StartNew(() =>
                                {
                                    var process = _diffService.ShowDiff(prevFileOnDisk, latFileOnDisk);

                                    if (process != null)
                                    {
                                        process.WaitForExit();
                                    }
                                    File.Delete(prevFileOnDisk);
                                    File.Delete(latFileOnDisk);
                                });
                            }
                        }
                        catch (Exception)
                        {
                            // log it?
                        }
                    }
                });

                // TODO: either cleanly handle a cancel or just let it go forever...
                //if(!task.Wait(new TimeSpan(0, 0, 0, secondsToTimeout)))
                //{
                //    token.Cancel();
                //    _messageBoxService.ShowError("Diff download timed out. Please increase the timeout if you continue to receive this error.");
                //    _mediator.NotifyColleaguesAsync<EndBusyEvent>(null);
                //}
            });
        }
예제 #15
0
 static bool IsFileModified(SvnChangeItem c)
 {
     return c.NodeKind == SvnNodeKind.File;
 }
예제 #16
0
 public ChangedPath(SvnChangeItem e)
 {
     action = e.Action;
     path   = e.Path;
 }
예제 #17
0
        public void ProcessNode(SvnLogEventArgs e, Action <SvnChangeItem, SvnLogEventArgs, string> action, SvnChangeItem node)
        {
            var destinationPath = _g.Source.GetDestinationPath(_g.WorkingDir, node.Path);

            if (destinationPath == null)
            {
                return;
            }
            _g.Interaction.DoInteractively(
                ref _ignoreItemError,
                TitleErrorProcessingNode,
                () => action(node, e, destinationPath));
        }