Ejemplo n.º 1
0
 public static IEnumerable<FileChanged> GetChangedFiles(SvnLogEventArgs logEvent)
 {
     foreach (var p in logEvent.ChangedPaths)
     {
         yield return new FileChanged(logEvent.Time, p.Path);
     }
 }
Ejemplo n.º 2
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));
                        }
                    }
            }
        }
 public SvnLogEventArgsWrapper(SvnLogEventArgs args)
 {
     Author = args.Author;
     LogMessage = args.LogMessage;
     Revision = args.Revision;
     Time = args.Time;
 }
        private void RaiseWorkflow(SVNServerRecord hostRecord, SvnLogEventArgs log)
        {
            var contentManager    = this.orchardServices.ContentManager;
            var svnLogContentItem = contentManager.New(SVNLogPart.ContentItemTypeName);
            var svnLogPart        = svnLogContentItem.As <SVNLogPart>();


            svnLogPart.LogMessage = log.LogMessage;
            svnLogPart.Author     = log.Author;
            svnLogPart.Revision   = log.Revision;
            svnLogPart.Time       = log.Time;
            svnLogPart.LogOrigin  = log.LogOrigin.AbsolutePath;

            contentManager.Create(svnLogContentItem);
            contentManager.Publish(svnLogContentItem);

            workflowManager.TriggerEvent(
                SVNLogReceivedActivity.ActivityName,
                svnLogContentItem,
                () => new Dictionary <string, object> {
                { "Content", svnLogContentItem }
            });

            hostRecord.LastRevision = log.Revision;
            this.svnServerRepository.Flush();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Does it match the LogMessage object
 /// </summary>
 /// <param name="msg"></param>
 public void CheckMatch(SvnLogEventArgs e)
 {
     Assert.That(e.Author, Is.EqualTo(this.author), "Author differs");
     Assert.That(e.LogMessage, Is.EqualTo(this.message), "Message differs");
     Assert.That(e.Revision, Is.EqualTo(this.revision), "Revision differs");
     Assert.That(e.Time, Is.EqualTo(this.date), "Date differs");
 }
Ejemplo n.º 6
0
        private void CommitToDestination(SvnLogEventArgs e, bool allowCopySourceRevision)
        {
            SvnCommitResult result;

            _g.Svn.Commit(_g.WorkingDir, new SvnCommitArgs {
                LogMessage = e.LogMessage
            }, out result);
            if (result == null)
            {
                return;
            }
            var sourceRevision      = e.Revision;
            var destinationReivison = result.Revision;

            _g.RevisionMap.TrackRevision(sourceRevision, destinationReivison);
            if (CopyAuthor)
            {
                _g.Svn.SetRevisionProperty(_g.Destination, destinationReivison, PropertyKeyAuthor, e.Author);
            }
            if (CopyDateTime)
            {
                _g.Svn.SetRevisionProperty(_g.Destination, destinationReivison, PropertyKeyDateTime, e.Time.ToString("O") + "Z");
            }
            if (CopySourceRevision && allowCopySourceRevision)
            {
                _g.Svn.SetRevisionProperty(_g.Destination, destinationReivison, PropertyKeySourceRevision,
                                           sourceRevision.ToString("#0"));
            }
            _g.Svn.Update(_g.WorkingDir, _ignoreExternalUpdate);
            _g.Interaction.UpdateProgress(sourceRevision, destinationReivison);
        }
        private void LogHandler(object sender, SvnLogEventArgs e)
        {
            try
            {
                List <string>       filesChanged = new List <string>();
                ChangeSetDictionary changedItems = new ChangeSetDictionary();

                if (e.ChangedPaths == null)
                {
                    return;
                }

                foreach (SvnChangeItem item in e.ChangedPaths)
                {
                    filesChanged.Add(item.Path);
                    changedItems.Add(item.Path, new ChangedPathInfo(item));
                }

                int revision = Convert.ToInt32(e.Revision);
                OnChangeSet(revision, e.Author, e.Time, e.LogMessage, filesChanged, changedItems);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
        }
Ejemplo n.º 8
0
 private void OnLogResult2(object sender, SvnLogEventArgs args)
 {
     foreach (var item in args.ChangedPaths)
     {
         Console.WriteLine(item.Action + " " + item.NodeKind + " " + item.RepositoryPath + " " + item.CopyFromPath);
     }
 }
Ejemplo n.º 9
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);
     }
 }
Ejemplo n.º 10
0
        private void OnLogResult(object sender, SvnLogEventArgs args)
        {
            Console.WriteLine(args.Revision + " -> " + args.LogMessage + " by " + args.Author);

            foreach (var item in args.ChangedPaths)
            {
                Console.WriteLine(item.Path);
            }
        }
Ejemplo n.º 11
0
        public bool exportFileFromLog(SvnLogEventArgs log, string expdir, bool excDel)
        {
            Console.WriteLine(string.Format(@"リビジョン:{0} を抽出します。", log.Revision));
            var revname   = retPadLeftZero(log.Revision);
            var toRevPath = expdir + @"\" + @"r" + revname;

            this._exlStm.addRevSht(@"r" + revname, log.LogMessage);
            var trgtFlLst = this.filterLogFiles(log.ChangedPaths, this._filterList, revname, excDel);

            if (trgtFlLst.Count == 0)
            {
                Directory.CreateDirectory(toRevPath + @"_対象なし");
                return(false);
            }

            var root = this._reporoot;
            var args = new SvnExportArgs()
            {
                Depth = SvnDepth.Files
            };
            var addCmd = @"echo F | xcopy /v /y ""{0}"" ""{1}"" " + Environment.NewLine +
                         @"svn add              ""{1}"" ";
            var delCmd = @"if exist             ""{0}"" ( " + Environment.NewLine +
                         @"  svn delete         ""{0}"" " + Environment.NewLine +
                         @")";

            Directory.CreateDirectory(toRevPath);
            var sw = createCopyBatStrm(expdir, revname);

            foreach (var i in trgtFlLst)
            {
                var flPth  = getFilePath(i.Path);
                var topath = toRevPath + flPth;
                if (i.Action != SvnChangeAction.Delete)
                {
                    var srcp = Path.Combine(root.ToString()
                                            , i.RepositoryPath.ToString());
                    var todir = Path.GetDirectoryName(topath);
                    if (!Directory.Exists(todir))
                    {
                        Directory.CreateDirectory(todir);
                    }
                    _svncl.Export(new SvnUriTarget(srcp, log.Revision), topath, args);
                    sw.WriteLine(string.Format(addCmd, topath, @"%dstRoot%" + flPth));
                }
                else
                {
                    sw.WriteLine(string.Format(delCmd, @"%dstRoot" + flPth));
                }
            }
            this.setCommitComment(expdir, sw, log, revname);
            sw.Close();

            return(true);
        }
Ejemplo n.º 12
0
        private void OnLogDelegate(object sender, SvnLogEventArgs args)
        {
            var largs = sender as Svn2SvnLogArgs;

            if (largs != null)
            {
                largs.revisions.Add(args.Revision, args);
            }

            args.Detach();
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        private void OnLogDelegate(object sender, SvnLogEventArgs args)
        {
            var largs = sender as Svn2SvnLogArgs;

            if (largs != null)
            {
                largs.revisions.Add(args.Revision, args);
            }

            args.Detach();            
        }
Ejemplo n.º 15
0
 void ReceiveItem(object sender, SvnLogEventArgs e)
 {
     if (!_cancel)
     {
         OnReceivedItem(e);
     }
     else
     {
         e.Cancel = true;
     }
 }
Ejemplo n.º 16
0
            public void Handler(object sender, SvnLogEventArgs args)
            {
                Commit commit = new Commit()
                {
                    Author    = args.Author,
                    Message   = args.LogMessage,
                    Timestamp = args.Time,
                    Revision  = args.Revision,
                };

                Logs.Add(commit);
            }
Ejemplo n.º 17
0
 /// <summary>
 /// Return false if _g._stopRequested, otherwise true.
 /// </summary>
 private bool ProcessNodes(IEnumerable <SvnChangeItem> nodes, SvnLogEventArgs e, Action <SvnChangeItem, SvnLogEventArgs, string> action)
 {
     foreach (var node in nodes)
     {
         if (_g.StopRequested)
         {
             return(false);                  // canceled
         }
         _nodeProcessor.ProcessNode(e, action, node);
     }
     return(true); // finished
 }
Ejemplo n.º 18
0
        public void getChangeItem(SvnLogEventArgs log)
        {
            var tmp = new Collection <SvnChangeItem>();

            foreach (var i in log.ChangedPaths)
            {
                if (i.NodeKind == SvnNodeKind.File)
                {
                    tmp.Add(i);
                }
            }
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
            public void Handler(object sender, SvnLogEventArgs args)
            {
                foreach (var changedPath in args.ChangedPaths)
                {
                    FileDiff fileInfo = new FileDiff(
                        ConvertFrom(changedPath.Action),
                        ConvertFrom(changedPath.NodeKind),
                        changedPath.Path,
                        changedPath.CopyFromPath);

                    FileChanges.Add(fileInfo.Name, fileInfo);
                }
            }
Ejemplo n.º 21
0
        public static IEnumerable <long> GetIssueIds(this SvnLogEventArgs svnLogEventArgs)
        {
            var result = Regex.Matches(svnLogEventArgs.LogMessage,
                                       @"#(\d+)",
                                       RegexOptions.Compiled)
                         .Cast <Match>()
                         .Select(match => long.Parse(match.Groups.Cast <System.Text.RegularExpressions.Group>()
                                                     .ElementAt(1)
                                                     .Value))
                         .ToArray();

            return(result);
        }
Ejemplo n.º 22
0
        private void setCommitComment(string workDir, StreamWriter btFlSw, SvnLogEventArgs log, string revname)
        {
            var cmmtFlNm = revname + @"_cmmnt.txt";
            var cmmt     = @"以下のリポジトリよりコピー" + Environment.NewLine +
                           string.Format(@"repo:{0}", this._uri) + Environment.NewLine +
                           string.Format(@"rev :{0}", log.Revision.ToString());

            using (var st = new StreamWriter(Path.Combine(workDir, cmmtFlNm), false, Encoding.GetEncoding(932)))
                st.WriteLine(cmmt);

            var cmd = @"" + Environment.NewLine +
                      string.Format(@"svn commit --file    ""{0}"" ""%dstRoot%""", Path.Combine(workDir, cmmtFlNm)) + Environment.NewLine +
                      string.Format(@"svn update           ""%dstRoot%""");

            btFlSw.WriteLine(cmd);
        }
Ejemplo n.º 23
0
 public Log(SvnLogEventArgs e)
 {
     revision = e.Revision;
     author   = e.Author;
     time     = e.Time.AddHours(8);
     message  = e.LogMessage;
     paths    = e.ChangedPaths;
     if (message != null && message.Contains("\n"))
     {
         short_message = message.Split('\n')[0];
     }
     else
     {
         short_message = message;
     }
 }
Ejemplo n.º 24
0
        private static void GetRevision(Collection <SvnLogEventArgs> logs, long revision)
        {
            Console.Write("#### 检测SVNlog数据 ####\n\n");
            int count = logs.Count;

            for (int i = 0; i < count; i++)
            {
                SvnLogEventArgs args = logs[i];
                if (revision != 0 && args.Revision == revision)
                {
                    if (i == 0)
                    {
                        Console.Write("#### SVNRevision Num未发生改变 ####\n\n");
                        ConsoleTool.Close();
                        return;
                    }
                    break;
                }
                if (i == 0)
                {
                    Patch = args.Revision;
                }
                SvnChangeItemCollection itemCollection = args.ChangedPaths;
                foreach (SvnChangeItem item in itemCollection)
                {
                    string path = item.Path;
                    if (CheckChangePath(path) && CheckSuffix(path))
                    {
                        if (Changes.Contains(path) == true)
                        {
                            continue;
                        }
                        Changes.Add(Path.GetFileName(path));
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            Console.Write(string.Format("#### 最新Revision Num : {0} ####\n\n", Patch));
            foreach (string path in Changes)
            {
                Console.Write(string.Format("====>更新文件:{0}\n", path));
            }
            Console.Write("########################################\n");
        }
Ejemplo n.º 25
0
        private WorkItem ToWorkItem(SvnLogEventArgs logEntry)
        {
            var item = new WorkItem(
                logEntry.Revision.ToString(CultureInfo.InvariantCulture),
                logEntry.Author,
                logEntry.LogMessage,
                logEntry.Time);

            if (logEntry.ChangedPaths != null)
            {
                foreach (SvnChangeItem ci in logEntry.ChangedPaths)
                {
                    item.ChangedFilePaths.Add(ci.Path);
                }
            }
            return(item);
        }
Ejemplo n.º 26
0
        public void Commit_SetCustomProps()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            string fp = Path.Combine(WcPath, "NewFile.cs");

            Touch2(fp);
            Client.Add(fp);

            SvnCommitArgs ca = new SvnCommitArgs();

            ca.LogMessage = "Committed extra";
            ca.LogProperties.Add("my:prop", "PropValue");
            ca.RunTortoiseHooks = true;

            SvnCommitResult cr;

            Client.Commit(WcPath, ca, out cr);

            string value;

            Client.GetRevisionProperty(sbox.RepositoryUri, cr.Revision, "my:prop", out value);

            Assert.That(value, Is.EqualTo("PropValue"));


            SvnLogArgs la = new SvnLogArgs();

            la.RetrieveProperties.Add("my:prop");
            la.Start = la.End = cr.Revision;

            Collection <SvnLogEventArgs> lc;

            Client.GetLog(WcPath, la, out lc);

            Assert.That(lc.Count, Is.EqualTo(1));
            Assert.That(lc[0].RevisionProperties.Contains("my:prop"));
            SvnLogEventArgs l = lc[0];

            Assert.That(l.RevisionProperties["my:prop"].StringValue, Is.EqualTo("PropValue"));
            Assert.That(l.Author, Is.EqualTo(Environment.UserName));
        }
Ejemplo n.º 27
0
        public void ProcessRevisionLog(SvnLogEventArgs e)
        {
            var sourceRevision = e.Revision;

            _g.Interaction.Info("{0} {1} {2} {3}", sourceRevision, e.Author, e.Time.ToLocalTime(), e.LogMessage);
            if (sourceRevision <= _resyncToRevision)
            {
                _firstLoad = false;
                if (!_ignoreResyncMismatch)
                {
                    _g.Interaction.DoInteractively(
                        ref _ignoreResyncMismatch,
                        TitleErrorResyncRevision,
                        () => CheckResyncRevision(sourceRevision));
                }
                return;
            }
            _g.Interaction.DoInteractively(
                ref _ignoreRevisionError,
                TitleProcessRevision,
                () =>
            {
                var sourceTarget = new SvnUriTarget(_g.Source.Uri, e.Revision);
                bool success     = _firstLoad
                                      ? _nodeProcessor.ExportDirectory(sourceTarget, _g.WorkingDir)
                                      : ChangeWorkingCopy(e);

                if (success)
                {
                    CommitToDestination(e, true);
                    _firstLoad = false;
                }
                else
                {
                    e.Cancel = true;
                }
            });
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Return false we didn't finish because _g._stopRequested, otherwise true.
        /// </summary>
        private bool ChangeWorkingCopy(SvnLogEventArgs e)
        {
            var changes    = e.ChangedPaths;
            var itemsAdded = from x in changes
                             where x.Action == SvnChangeAction.Add
                             orderby x.Path
                             select x;

            var itemsModified = from x in changes
                                where x.Action == SvnChangeAction.Modify
                                select x;

            var itemsDeleted = from x in changes
                               where x.Action == SvnChangeAction.Delete
                               orderby x.Path descending
                               select x;

            if (!DetectNameChangeByCaseOnly(changes))
            {
                return(ProcessNodes(itemsAdded, e, _nodeProcessor.Add) &&
                       ProcessNodes(itemsModified, e, _nodeProcessor.Modify) &&
                       ProcessNodes(itemsDeleted, e, _nodeProcessor.Delete));
            }

            var success = ProcessNodes(itemsDeleted, e, _nodeProcessor.Delete) &&
                          ProcessNodes(itemsModified, e, _nodeProcessor.Modify);

            if (!success)
            {
                return(false);
            }

            CommitToDestination(e, false);

            return(ProcessNodes(itemsAdded, e, _nodeProcessor.Add));
        }
Ejemplo n.º 30
0
 private void OnLog(object sender, SvnLogEventArgs args)
 {
     _revisions.Add(args.Revision, args);
     args.Detach();
     Console.Write(".");
 }
Ejemplo n.º 31
0
 private void OnLog(object sender, SvnLogEventArgs args)
 {
     _revisions.Add(args.Revision, args);
     args.Detach();
     Console.Write(".");
 }
Ejemplo n.º 32
0
 private void LogCallback(object sender, SvnLogEventArgs e)
 {
     e.Detach();
     this.logMessages.Add(e);
 }
Ejemplo n.º 33
0
        void LoadRevisions()
        {
            int limit;

            Int32.TryParse(textBoxLoadBunch.Text, out limit);

            var cts = new CancellationTokenSource();

            Task.Factory
                .StartNew(() => {
                    using (var client = new SvnClient())
                    {
                        client.Authentication.SslServerTrustHandlers += (sender, e) => { e.AcceptedFailures = SvnCertificateTrustFailures.MaskAllFailures; };
                        client.Authentication.DefaultCredentials = CredentialCache.DefaultNetworkCredentials;

                        SvnInfoEventArgs info;
                        client.GetInfo(_url != null ? (SvnTarget)new SvnUriTarget(_url) : new SvnPathTarget(_path), out info);
                        _repoUri = info.RepositoryRoot;

                        var args = new SvnLogArgs { Limit = limit };

                        var url = _url;

                        if (_lastLoaded != null)
                        {
                            args.OperationalRevision = _lastLoaded.Revision - 1;
                        }

                        Collection<SvnLogEventArgs> entries;
                        if (url != null)
                            client.GetLog(url, args, out entries);
                        else
                            client.GetLog(_path, args, out entries);

                        return entries;
                    }
                }, cts.Token)
                .TrackProgress(loadingOperation, cts)
                .LockControls(textBoxUrl, buttonLoad, buttonLoadNext, textBoxLoadBunch)
                .ContinueWith(t => {

                    if (t.IsFaulted || t.IsCanceled)
                    {
                        // if error occured - strat from scratch: can be load first N entries, can't continue
                        _lastLoaded = null;
                        buttonLoad.Enabled = true;
                        buttonLoadNext.Enabled = false;
                    }

                    cts.Token.ThrowIfCancellationRequested();

                    var entries = t.Result;

                    if (entries.Count < limit)
                    {
                        // nothing to load next - all revisions loaded
                        buttonLoadNext.Enabled = false;
                        _lastLoaded = null;
                    }
                    else
                    {
                        _lastLoaded = entries.Last();
                    }

                    try
                    {
                        listViewLog.BeginUpdate();

                        foreach (var entry in entries)
                        {
                            var lvi = new ListViewItem(new[] { entry.Revision.ToString(CultureInfo.InvariantCulture), entry.Author, entry.LogMessage })
                            {
                                Tag = entry
                            };
                            listViewLog.Items.Add(lvi);
                        }
                    }
                    finally
                    {
                        listViewLog.EndUpdate();
                    }

                }, TaskScheduler.FromCurrentSynchronizationContext())
                //.TrackProgress(loadingOperation)
                .WithDisposeWeak(cts)
            ;
        }
Ejemplo n.º 34
0
        void buttonLoad_Click(object sender, EventArgs e)
        {
            UsageMetrics.IncrementUsage(UsageMetrics.UsageKind.SvnLogLoad);

            _lastLoaded = null;
            buttonLoadNext.Enabled = true;
            listViewLog.Items.Clear();

            _path = null;
            _url = null;

            Settings.Default.LastSvnLogUrl = textBoxUrl.Text;
            Settings.Default.Save();

            if (UrlScheme.IsMatch(textBoxUrl.Text))
                _url = new Uri(textBoxUrl.Text);
            else if(Directory.Exists(textBoxUrl.Text) || File.Exists(textBoxUrl.Text))
                _path = textBoxUrl.Text;

            LoadRevisions();
        }
Ejemplo n.º 35
0
 private static RevisionInfo MapToRevisionInfo(SvnLogEventArgs svnLogEventArgs)
 {
     if (svnLogEventArgs == null)
         return null;
     return new RevisionInfo
         {
             Author = svnLogEventArgs.Author,
             Created = svnLogEventArgs.Time,
             Revision = svnLogEventArgs.Revision
         };
 }
Ejemplo n.º 36
0
 private void LogCallback(object sender, SvnLogEventArgs e)
 {
     e.Detach();
     this.logMessages.Add(e);
 }
        /// <summary>
        /// Creates a Qvx data entry from an Svn log entry.
        /// </summary>
        /// <param name="item">The Svn log entry to be used as a source</param>
        /// <param name="table">The destination Qvx table</param>
        /// <returns>The resulting row</returns>
        private QvxDataRow MakeEntry(SvnLogEventArgs entry, QvxTable table)
        {
            QvxDataRow row = new QvxDataRow();

            row[table.Fields[0]] = entry.Author;
            row[table.Fields[1]] = entry.LogMessage;
            row[table.Fields[2]] = entry.Revision;
            row[table.Fields[3]] = entry.Time.ToOADate();

            return row;
        }
Ejemplo n.º 38
0
 public static string WriteString(SvnLogEventArgs log)
 {
     return "Date={0}\nPaths={1}".FormatWith(log.Time, WriteString(log.ChangedPaths));
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Does it match the LogMessage object
 /// </summary>
 /// <param name="msg"></param>
 public void CheckMatch(SvnLogEventArgs e)
 {
     Assert.That(e.Author, Is.EqualTo(this.author), "Author differs");
     Assert.That(e.LogMessage, Is.EqualTo(this.message), "Message differs");
     Assert.That(e.Revision, Is.EqualTo(this.revision), "Revision differs");
     Assert.That(e.Time, Is.EqualTo(this.date), "Date differs");
 }
        private void LogHandler(object sender, SvnLogEventArgs e)
        {
            try
            {
                List<string> filesChanged = new List<string>();
                ChangeSetDictionary changedItems = new ChangeSetDictionary();

                if(e.ChangedPaths == null)
                {
                    return;
                }

                foreach (SvnChangeItem item in e.ChangedPaths) {
                    filesChanged.Add(item.Path);
                    changedItems.Add(item.Path, new ChangedPathInfo(item));
                }

                int revision = Convert.ToInt32(e.Revision);
                OnChangeSet(revision, e.Author, e.Time, e.LogMessage, filesChanged, changedItems);
            }
            catch(Exception ex)
            {
                OnError(ex);
            }
        }
Ejemplo n.º 41
0
 void HandleLog(object sender, SvnLogEventArgs e)
 {
     WriteObject(e);
 }
Ejemplo n.º 42
0
        public void Copy()
        {
            long lastSyncRevision = 0;

            if (_args.Incremental)
            {
                SvnLogParser logParser = new SvnLogParser(_args.Destination);
                lastSyncRevision = logParser.GetLastSyncedRevisionFromDestination();
                Console.WriteLine("Last revision synched: {0}", lastSyncRevision);
            }

            Console.Write("Collecting svn log: ");

            if (_args.RevisionRange != null)
            {
                Console.Write("{0}:{1} ",
                              _args.RevisionRange.StartRevision,
                              _args.RevisionRange.EndRevision);
            }

            // fetch the source svn respository and
            SvnInfo sourceInfo = new SvnInfo(_args.Source);

            Console.WriteLine("Source SVN root: {0}", sourceInfo.Info.RepositoryRoot);
            Console.WriteLine("Source SVN uri: {0}", sourceInfo.Info.Uri);

            string sourceRelativePath = sourceInfo.Info.Uri.ToString().Remove(
                0, sourceInfo.Info.RepositoryRoot.ToString().Length - 1);

            Console.WriteLine("Relative path: {0}", sourceRelativePath);

            if (!string.IsNullOrEmpty(_args.Root))
            {
                sourceRelativePath = _args.Root;
                Console.WriteLine("Substituting relative path: {0}", sourceRelativePath);
            }

            SvnLogArgs logArgs = new SvnLogArgs();

            logArgs.StrictNodeHistory = _args.StopOnCopy;
            logArgs.ThrowOnError      = true;
            logArgs.Range             = _args.RevisionRange;

            logArgs.RetrieveChangedPaths = true;

            _client.Log(_args.Source, logArgs, new EventHandler <SvnLogEventArgs>(OnLog));
            Console.WriteLine();
            Console.WriteLine("Collected {0} revisions.", _revisions.Count);

            SvnTarget fromSvnTarget = SvnTarget.FromString(_args.Source);

            foreach (KeyValuePair <long, SvnLogEventArgs> revisionPair in _revisions)
            {
                SvnLogEventArgs revision = revisionPair.Value;

                if (_args.Incremental && lastSyncRevision != 0 && lastSyncRevision >= revision.Revision)
                {
                    Console.WriteLine("Skipping revision {0} ({1})", revision.Revision, revision.Time);
                    continue;
                }

                Console.WriteLine("Revision {0} ({1})", revision.Revision, revision.Time);

                if (_args.SimulationOnly)
                {
                    continue;
                }

                SvnExportArgs exportArgs = new SvnExportArgs();
                exportArgs.Overwrite    = true;
                exportArgs.ThrowOnError = true;
                exportArgs.Revision     = revision.Revision;

                SvnUpdateResult exportResult = null;
                _client.Export(fromSvnTarget, _args.Destination, exportArgs, out exportResult);

                if (revision.ChangedPaths == null)
                {
                    throw new Exception(string.Format("No changed paths in rev. {0}",
                                                      revision.Revision));
                }

                SortedList <string, SvnChangeItem> changeItems = new SortedList <string, SvnChangeItem>();

                foreach (SvnChangeItem changeItem in revision.ChangedPaths)
                {
                    changeItems.Add(changeItem.Path, changeItem);
                }

                List <string> filesAdd    = new List <string>();
                List <string> filesDelete = new List <string>();
                List <string> filesModify = new List <string>();

                // add files in forward order (add directories first)
                // delete files in reverse order (delete files first)
                foreach (SvnChangeItem changeItem in changeItems.Values)
                {
                    // anything above (outside) of the source path is ignored, we didn't export that
                    if (!changeItem.Path.StartsWith(sourceRelativePath))
                    {
                        Console.WriteLine("Skipping {0}. Did you need to specify /root:<path>?)", changeItem.Path);
                        continue;
                    }

                    string targetSvnPath = changeItem.Path.Remove(0, sourceRelativePath.Length);
                    string targetOSPath  = targetSvnPath.Replace("/", @"\");
                    string targetPath    = Path.Combine(_args.Destination, targetOSPath);
                    Console.WriteLine(" {0} {1}", changeItem.Action, changeItem.Path);
                    switch (changeItem.Action)
                    {
                    case SvnChangeAction.Add:
                    case SvnChangeAction.Replace:
                        filesAdd.Add(targetPath);
                        break;

                    case SvnChangeAction.Delete:
                        filesDelete.Insert(0, targetPath);
                        break;

                    case SvnChangeAction.Modify:
                        filesModify.Add(targetPath);
                        break;
                    }
                }

                Console.WriteLine("Applying changes @ rev. {0} ...", revision.Revision);

                foreach (string targetPath in filesModify)
                {
                    Console.WriteLine(" M {0}", targetPath);
                }

                foreach (string targetPath in filesAdd)
                {
                    if (!File.Exists(targetPath))
                    {
                        throw new Exception(string.Format("Added file '{0}' doesn't exist. Did you need to specify /root:<path>?",
                                                          targetPath));
                    }

                    Console.WriteLine(" A {0}", targetPath);
                    SvnAddArgs svnAddArgs = new SvnAddArgs();
                    svnAddArgs.ThrowOnError = true;
                    svnAddArgs.Depth        = SvnDepth.Empty;
                    _client.Add(targetPath, svnAddArgs);
                }

                foreach (string targetPath in filesDelete)
                {
                    Console.WriteLine(" D {0}", targetPath);
                    SvnDeleteArgs svnDeleteArgs = new SvnDeleteArgs();
                    svnDeleteArgs.ThrowOnError = true;
                    svnDeleteArgs.Force        = true;
                    _client.Delete(targetPath, svnDeleteArgs);
                }


                SvnCommitArgs commitArgs = new SvnCommitArgs();
                commitArgs.LogMessage  = revision.LogMessage;
                commitArgs.LogMessage += string.Format("\nCopied from {0}, rev. {1} by {2} @ {3} {4}",
                                                       sourceInfo.Info.Uri, revision.Revision, revision.Author, revision.Time.ToShortDateString(), revision.Time.ToShortTimeString());
                commitArgs.ThrowOnError = true;

                Console.WriteLine("Committing changes @ rev. {0} in {1}", revision.Revision, _args.Destination);
                Console.WriteLine("----------------------------------------------------------------------------");
                Console.WriteLine(commitArgs.LogMessage);
                Console.WriteLine("----------------------------------------------------------------------------");

                if (_args.Prompt)
                {
                    while (true)
                    {
                        Console.Write("Commit? [Y/N] ");
                        char k = Char.ToLower(Console.ReadKey().KeyChar);
                        Console.WriteLine();
                        if (k == 'y')
                        {
                            break;
                        }
                        if (k == 'n')
                        {
                            throw new Exception("Aborted by user.");
                        }
                    }
                }

                SvnCommitResult commitResult = null;
                _client.Commit(_args.Destination, commitArgs, out commitResult);
                if (commitResult != null)
                {
                    Console.WriteLine("Commited revision {0}.", commitResult.Revision);
                }
                else
                {
                    Console.WriteLine("There were no committable changes.");
                    Console.WriteLine("Subversion property changes are not supported.");
                }
            }
        }