示例#1
0
        public void TestHasBinaryProp()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

            SvnWorkingCopyState     state;
            SvnWorkingCopyStateArgs a = new SvnWorkingCopyStateArgs();

            a.RetrieveFileData = true;

            SvnWorkingCopyClient wcc = new SvnWorkingCopyClient();

            wcc.GetState(Path.Combine(WcPath, "Form.cs"), out state);

            // first on a file
            Assert.That(state.IsTextFile);

            wcc.GetState(Path.Combine(WcPath, "App.ico"), out state);

            Assert.That(state.IsTextFile, Is.False);


            wcc.GetState(WcPath, out state);

            // check what happens for a dir
            //Assert.IsFalse(state.IsTextFile);
        }
        public void ListEntries_WalkEntries()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string tmpDir = sbox.Wc;

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnWorkingCopyEntriesArgs a = new SvnWorkingCopyEntriesArgs();
                a.RetrieveHidden = true;
                //a.Depth = SvnDepth.Infinity;

                bool touched = false;
                Assert.That(wcc.ListEntries(tmpDir, a,
                                            delegate(object sender, SvnWorkingCopyEntryEventArgs e)
                {
                    touched = true;
                }), Is.True);


                Assert.That(touched);
            }
        }
示例#3
0
        public void WcDirMissing()
        {
            SvnSandBox      sbox           = new SvnSandBox(this);
            Uri             CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario);
            string          dir            = sbox.Wc;
            SvnUpdateResult r;

            Assert.That(Client.CheckOut(CollabReposUri, dir, out r));

            Directory.Move(Path.Combine(dir, "trunk"), Path.Combine(dir, "banaan"));

            SvnInfoEventArgs iaParent;
            SvnInfoEventArgs iaTrunk;

            Client.GetInfo(dir, out iaParent);
            Client.GetInfo(Path.Combine(dir, "trunk"), out iaTrunk);

            Assert.That(iaParent.FullPath, Is.EqualTo(dir));
            Assert.That(iaTrunk.FullPath, Is.Not.EqualTo(dir));
            //Assert.That(iaParent.Uri, Is.EqualTo(iaTrunk.Uri));

            SvnWorkingCopyVersion ver;
            SvnWorkingCopyClient  wcC = new SvnWorkingCopyClient();

            Assert.That(wcC.GetVersion(dir, out ver));
            Assert.That(ver, Is.Not.Null);

            Assert.That(ver.Modified, Is.True);
            Assert.That(ver.Switched, Is.False);
            Assert.That(ver.Start, Is.EqualTo(17));
            Assert.That(ver.End, Is.EqualTo(17));
            Assert.That(ver.IncompleteWorkingCopy, Is.False);
        }
        /// <exception cref="InvalidOperationException" />
        public override string[] GetCommitMessages()
        {
            SvnWorkingCopyVersion svnWorkingCopyVersion;

            using (var svnWorkingCopyClient = new SvnWorkingCopyClient())
            {
                if (!svnWorkingCopyClient.GetVersion(this.Path,
                                                     out svnWorkingCopyVersion))
                {
                    throw new InvalidOperationException($"Could not get version for {this.Path}.");
                }
            }

            if (svnWorkingCopyVersion.Modified)
            {
                throw new InvalidOperationException($"{this.Path} has uncommitted changes.");
            }

            Collection <SvnLogEventArgs> logItems;

            using (var svnClient = new SvnClient())
            {
                SvnRevision start;
                if (this.BaseRevision == null)
                {
                    start = SvnRevision.Zero;
                }
                else
                {
                    if (!int.TryParse(this.BaseRevision,
                                      out var startRevision))
                    {
                        throw new InvalidOperationException($"Could not parse {nameof(this.BaseRevision)}: {this.BaseRevision}");
                    }
                    start = startRevision;
                }

                var svnLogArgs = new SvnLogArgs
                {
                    StrictNodeHistory = false,
                    Range             = new SvnRevisionRange(start,
                                                             SvnRevision.Head)
                };
                if (!svnClient.GetLog(this.Path,
                                      svnLogArgs,
                                      out logItems))
                {
                    throw new InvalidOperationException($"Could not get log for {this.Path}.");
                }
            }

            var commitMessages = logItems.OrderBy(arg => arg.Revision)
                                 .Select(arg => arg.LogMessage)
                                 .ToArray();

            return(commitMessages);
        }
 public void SvnVersionRoot()
 {
     using (SvnWorkingCopyClient wcC = new SvnWorkingCopyClient())
     {
         SvnGetWorkingCopyVersionArgs sa = new SvnGetWorkingCopyVersionArgs();
         sa.ThrowOnError = false;
         SvnWorkingCopyVersion wcv;
         wcC.GetVersion("C:\\", sa, out wcv); // Used to throw an assertion error
     }
 }
示例#6
0
        /// <summary>
        /// Obtiene el número de la última revisión de la copia de trabajo.
        /// </summary>
        /// <returns></returns>
        public static long ObtenerUltimaRevision()
        {
            SvnWorkingCopyVersion version;

            using (var copiaDeTrabajo = new SvnWorkingCopyClient())
            {
                copiaDeTrabajo.GetVersion(ObtenerRutaCopiaTrabajo(), out version);
            }

            return(version.End);
        }
示例#7
0
    static void CreateRevisionFile()
    {
        Console.Write("Writing revision to file: ");

        long   rev      = 0;
        string filename = Path.GetFullPath(".");
        SvnWorkingCopyClient  client = new SvnWorkingCopyClient();
        SvnWorkingCopyVersion version;

        if (client.GetVersion(filename, out version))
        {
            rev = version.Start;
        }
        Console.WriteLine(rev);
        using (StreamWriter writer = new StreamWriter("../REVISION")) {
            writer.Write(rev.ToString());
        }
    }
示例#8
0
        void UpdateTextFile()
        {
            SvnItemState value = SvnItemState.IsDiskFile | SvnItemState.Versioned;
            SvnItemState v;

            bool isTextFile;

            if (TryGetState(SvnItemState.Versioned, out v) && (v == 0))
            {
                isTextFile = false;
            }
            else if (GetState(value) != value)
            {
                isTextFile = false;
            }
            else
            {
                using (SvnWorkingCopyClient client = _context.GetService <ISvnClientPool>().GetWcClient())
                {
                    SvnWorkingCopyStateArgs a = new SvnWorkingCopyStateArgs();
                    a.ThrowOnError     = false;
                    a.RetrieveFileData = true;
                    SvnWorkingCopyState state;
                    if (client.GetState(FullPath, out state))
                    {
                        isTextFile = state.IsTextFile;
                    }
                    else
                    {
                        isTextFile = false;
                    }
                }
            }

            if (isTextFile)
            {
                SetState(SvnItemState.IsTextFile, SvnItemState.None);
            }
            else
            {
                SetState(SvnItemState.None, SvnItemState.IsTextFile);
            }
        }
示例#9
0
        public void Conflict_InstallTreeConflict()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string index = Path.Combine(sbox.Wc, "README.txt");

            SvnInfoEventArgs before;

            Client.GetInfo(index, out before);

            Assert.That(before, Is.Not.Null);
            Assert.That(before.ConflictWork, Is.Null);
            Assert.That(before.TreeConflict, Is.Null);

            Uri reposRoot = Client.GetRepositoryRoot(index);

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnUriOrigin conflictOrigin          = new SvnUriOrigin(new SvnUriTarget(before.Uri, before.Revision), reposRoot);
                SvnWorkingCopyInstallConflictArgs ia = new SvnWorkingCopyInstallConflictArgs();

                ia.TreeConflict = true; // Only supported conflict at this time

                wcc.InstallConflict(index, conflictOrigin, conflictOrigin, ia);
            }

            Client.Update(sbox.Wc);

            SvnInfoEventArgs after;

            Client.GetInfo(index, out after);

            Assert.That(after, Is.Not.Null);
            Assert.That(after.ConflictWork, Is.Null);
            Assert.That(after.TreeConflict, Is.Not.Null);
            Assert.That(after.Revision, Is.EqualTo(before.Revision));

            Client.Resolve(index, SvnAccept.Working);
        }
示例#10
0
        public void Conflict_InstallTreeConflict()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);

            string index = Path.Combine(sbox.Wc, "README.txt");

            SvnInfoEventArgs before;
            Client.GetInfo(index, out before);

            Assert.That(before, Is.Not.Null);
            Assert.That(before.ConflictWork, Is.Null);
            Assert.That(before.TreeConflict, Is.Null);

            Uri reposRoot = Client.GetRepositoryRoot(index);

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnUriOrigin conflictOrigin = new SvnUriOrigin(new SvnUriTarget(before.Uri, before.Revision), reposRoot);
                SvnWorkingCopyInstallConflictArgs ia = new SvnWorkingCopyInstallConflictArgs();

                ia.TreeConflict = true; // Only supported conflict at this time

                wcc.InstallConflict(index, conflictOrigin, conflictOrigin, ia);
            }

            Client.Update(sbox.Wc);

            SvnInfoEventArgs after;
            Client.GetInfo(index, out after);

            Assert.That(after, Is.Not.Null);
            Assert.That(after.ConflictWork, Is.Null);
            Assert.That(after.TreeConflict, Is.Not.Null);
            Assert.That(after.Revision, Is.EqualTo(before.Revision));

            Client.Resolve(index, SvnAccept.Working);
        }
示例#11
0
        static string GetSvnCasing(SvnItem item)
        {
            string name = null;

            // Find the correct casing
            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnWorkingCopyEntriesArgs ea = new SvnWorkingCopyEntriesArgs();
                ea.ThrowOnCancel = false;
                ea.ThrowOnError  = false;

                wcc.ListEntries(item.Directory, ea,
                                delegate(object sender, SvnWorkingCopyEntryEventArgs e)
                {
                    if (string.Equals(e.FullPath, item.FullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        name = e.FullPath;
                    }
                });
            }

            return(name);
        }
示例#12
0
        public void ListEntries_WalkEntries()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);

            string tmpDir = sbox.Wc;

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnWorkingCopyEntriesArgs a = new SvnWorkingCopyEntriesArgs();
                a.RetrieveHidden = true;
                //a.Depth = SvnDepth.Infinity;

                bool touched = false;
                Assert.That(wcc.ListEntries(tmpDir, a,
                    delegate(object sender, SvnWorkingCopyEntryEventArgs e)
                    {
                        touched = true;
                    }), Is.True);

                Assert.That(touched);
            }
        }
示例#13
0
        public void Commit_NonRecursiveDepthEmpty()
        {
            SvnSandBox sbox = new SvnSandBox(this);

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

            string name = Path.Combine(dir, "sd");
            string f    = Path.Combine(name, "f");

            Client.CreateDirectory(name);
            File.WriteAllText(f, "qq");
            Client.Add(f);

            Client.Commit(name);

            Collection <SvnStatusEventArgs> st;

            Client.CropWorkingCopy(name, SvnDepth.Empty);
            Client.Delete(name);

            Client.GetStatus(name, out st);
            Assert.That(st.Count, Is.EqualTo(1));

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                Collection <SvnWorkingCopyEntryEventArgs> lst;
                wcc.GetEntries(name, out lst);

                Assert.That(lst.Count, Is.EqualTo(1));
            }

            SvnCommitArgs ca = new SvnCommitArgs();

            ca.Depth = SvnDepth.Empty;
            Client.Commit(name, ca);
        }
示例#14
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lbInfo.Content = "一切正常";

            String curDir = Directory.GetCurrentDirectory();
            String curExe = System.Reflection.Assembly.GetExecutingAssembly().Location;


            SvnClient = new SvnClient();

            SvnTarget svnTargetCurDir = SvnTarget.FromString(curDir);
            SvnTarget snvTargetCurExe = SvnTarget.FromString(curExe);

            // 未使用 - 获取目录下的文件状态
            Collection<SvnStatusEventArgs> svnStatusEventArgsCollection;
            SvnClient.GetStatus(Directory.GetCurrentDirectory(), out svnStatusEventArgsCollection);

            // 未使用 - 空的
            Collection<SvnPropertyListEventArgs> svnPropertyListEventArgsCollection;
            SvnClient.GetPropertyList(Directory.GetCurrentDirectory(), out svnPropertyListEventArgsCollection);

            // 未使用 - 获取一个文件的状态
            Collection<SvnFileVersionEventArgs> svnFileVersionEventArgsCollection;
            try
            {
                SvnClient.GetFileVersions(snvTargetCurExe, out svnFileVersionEventArgsCollection);
            }
            catch(SvnWorkingCopyPathNotFoundException ex)
            {
                // 如果查询的文件未加入Repo,会抛此异常
            }

            // 未使用 - 一个好像没什么用的信息列表,目录是第一个项,没有版本号
            Collection<SvnListEventArgs> svnListEventArgsCollection;
            SvnClient.GetList(svnTargetCurDir, out svnListEventArgsCollection);

            // 未使用 - 工作目录全路径
            String workingCopyRoot = SvnClient.GetWorkingCopyRoot(Directory.GetCurrentDirectory());
            
            // 未使用 - 整个仓库的最新版本
            long revision = 0;
            SvnClient.Youngest(Directory.GetCurrentDirectory(), out revision);

            // 此目录的相关变更 和 GUI中的ShowLog一样 是此目录的相关变更           
            Collection<SvnLogEventArgs> logList;
            try
            {
                SvnClient.GetLog(Directory.GetCurrentDirectory(), out logList);
            }
            catch(SvnInvalidNodeKindException ex)
            {
                lbInfo.Content = "当前目录不是SVN目录,停用更新检查功能";
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                return;
            }

            // 获取本地目录信息,当前版本和修改版本都是本地的
            SvnInfoEventArgs svnInfoEventArgs;
            SvnClient.GetInfo(svnTargetCurDir, out svnInfoEventArgs);

            long curRevision = svnInfoEventArgs.Revision;       // 当前的SVN版本
            long changeRevision = logList[0].Revision;          // 当前目录的最新远程变更版本

            lbVersionChange.Content = changeRevision;
            lbVersionCur.Content = svnInfoEventArgs.Revision;

            if (curRevision < changeRevision)
            {
                btnUpdateAndLaunch.Visibility = Visibility.Visible;
                lbInfo.Content = "发现新版本";
            }
            else
            {
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                lbInfo.Content = "已经是最新版";
            }

            // --------------------------------------------------------
            // SvnWorkingCopyClient
            // --------------------------------------------------------
            SvnWorkingCopyClient svnWorkingCopyClient = new SvnWorkingCopyClient();

            // 未使用 只有一个值IsText 没看出有什么用处
            SvnWorkingCopyState svnWorkingCopyState;
            svnWorkingCopyClient.GetState(Directory.GetCurrentDirectory(), out svnWorkingCopyState);

            // 未使用 返回仅本地存在的所有修改版本 
            SvnWorkingCopyVersion svnWorkingCopyVersion;
            svnWorkingCopyClient.GetVersion(curDir, out svnWorkingCopyVersion);

            // --------------------------------------------------------
            // SvnTools
            // --------------------------------------------------------
            // 未使用 传入正确的目录却返回false????
            bool isCurDirInWorkingCopy = SvnTools.IsManagedPath(curDir);

        }
示例#15
0
 private void GetFileVersions(string rootPath, string path, Dictionary<string, string[]> oldfilevers, ref Dictionary<string, string[]> filevers)
 {
     if (path.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1) != ".svn")
     {
         long num = 0x295L;
         long num2 = 0x2d3L;
         using (SvnWorkingCopyClient client = new SvnWorkingCopyClient())
         {
             if (SvnTools.IsManagedPath(path))
             {
                 Collection<SvnWorkingCopyEntryEventArgs> collection;
                 if (client.GetEntries(path, out collection))
                 {
                     foreach (SvnWorkingCopyEntryEventArgs args in collection)
                     {
                         if (!(args.FullPath != path))
                         {
                             continue;
                         }
                         string key = args.FullPath.Replace(rootPath, "");
                         if (!key.EndsWith("component.xml") && (args.LastChangeRevision > 0L))
                         {
                             string str2 = "1.50.00";
                             if ((oldfilevers != null) && !oldfilevers.ContainsKey(key))
                             {
                                 str2 = "1.00.00";
                             }
                             else if (string.IsNullOrEmpty(oldfilevers[key][1]))
                             {
                                 if ((args.LastChangeRevision > num) && (args.LastChangeRevision <= num2))
                                 {
                                     str2 = "1.60.00";
                                 }
                                 else if (args.LastChangeRevision > num2)
                                 {
                                     str2 = ((0x3e80L + args.LastChangeRevision) - num2).ToString();
                                     str2 = str2.Insert(str2.Length - 4, ".");
                                     str2 = str2.Insert(str2.Length - 2, ".");
                                 }
                             }
                             else
                             {
                                 str2 = oldfilevers[key][0];
                                 if (oldfilevers[key][1] != args.Checksum)
                                 {
                                     str2 = (Convert.ToInt32(str2.Replace(".", string.Empty)) + 1).ToString();
                                     str2 = str2.Insert(str2.Length - 4, ".");
                                     str2 = str2.Insert(str2.Length - 2, ".");
                                 }
                             }
                             filevers.Add(key, new string[] { str2, args.Checksum });
                         }
                     }
                 }
                 foreach (string str3 in Directory.GetDirectories(path))
                 {
                     this.GetFileVersions(rootPath, str3, oldfilevers, ref filevers);
                 }
             }
             else
             {
                 this.WriteLog(string.Format("目录:{0} 不受SVN管理", path));
             }
         }
     }
 }
示例#16
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lbInfo.Content = "一切正常";

            String curDir = Directory.GetCurrentDirectory();
            String curExe = System.Reflection.Assembly.GetExecutingAssembly().Location;


            SvnClient = new SvnClient();

            SvnTarget svnTargetCurDir = SvnTarget.FromString(curDir);
            SvnTarget snvTargetCurExe = SvnTarget.FromString(curExe);

            // 未使用 - 获取目录下的文件状态
            Collection <SvnStatusEventArgs> svnStatusEventArgsCollection;

            SvnClient.GetStatus(Directory.GetCurrentDirectory(), out svnStatusEventArgsCollection);

            // 未使用 - 空的
            Collection <SvnPropertyListEventArgs> svnPropertyListEventArgsCollection;

            SvnClient.GetPropertyList(Directory.GetCurrentDirectory(), out svnPropertyListEventArgsCollection);

            // 未使用 - 获取一个文件的状态
            Collection <SvnFileVersionEventArgs> svnFileVersionEventArgsCollection;

            try
            {
                SvnClient.GetFileVersions(snvTargetCurExe, out svnFileVersionEventArgsCollection);
            }
            catch (SvnWorkingCopyPathNotFoundException ex)
            {
                // 如果查询的文件未加入Repo,会抛此异常
            }

            // 未使用 - 一个好像没什么用的信息列表,目录是第一个项,没有版本号
            Collection <SvnListEventArgs> svnListEventArgsCollection;

            SvnClient.GetList(svnTargetCurDir, out svnListEventArgsCollection);

            // 未使用 - 工作目录全路径
            String workingCopyRoot = SvnClient.GetWorkingCopyRoot(Directory.GetCurrentDirectory());

            // 未使用 - 整个仓库的最新版本
            long revision = 0;

            SvnClient.Youngest(Directory.GetCurrentDirectory(), out revision);

            // 此目录的相关变更 和 GUI中的ShowLog一样 是此目录的相关变更
            Collection <SvnLogEventArgs> logList;

            try
            {
                SvnClient.GetLog(Directory.GetCurrentDirectory(), out logList);
            }
            catch (SvnInvalidNodeKindException ex)
            {
                lbInfo.Content = "当前目录不是SVN目录,停用更新检查功能";
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                return;
            }

            // 获取本地目录信息,当前版本和修改版本都是本地的
            SvnInfoEventArgs svnInfoEventArgs;

            SvnClient.GetInfo(svnTargetCurDir, out svnInfoEventArgs);

            long curRevision    = svnInfoEventArgs.Revision;    // 当前的SVN版本
            long changeRevision = logList[0].Revision;          // 当前目录的最新远程变更版本

            lbVersionChange.Content = changeRevision;
            lbVersionCur.Content    = svnInfoEventArgs.Revision;

            if (curRevision < changeRevision)
            {
                btnUpdateAndLaunch.Visibility = Visibility.Visible;
                lbInfo.Content = "发现新版本";
            }
            else
            {
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                lbInfo.Content = "已经是最新版";
            }

            // --------------------------------------------------------
            // SvnWorkingCopyClient
            // --------------------------------------------------------
            SvnWorkingCopyClient svnWorkingCopyClient = new SvnWorkingCopyClient();

            // 未使用 只有一个值IsText 没看出有什么用处
            SvnWorkingCopyState svnWorkingCopyState;

            svnWorkingCopyClient.GetState(Directory.GetCurrentDirectory(), out svnWorkingCopyState);

            // 未使用 返回仅本地存在的所有修改版本
            SvnWorkingCopyVersion svnWorkingCopyVersion;

            svnWorkingCopyClient.GetVersion(curDir, out svnWorkingCopyVersion);

            // --------------------------------------------------------
            // SvnTools
            // --------------------------------------------------------
            // 未使用 传入正确的目录却返回false????
            bool isCurDirInWorkingCopy = SvnTools.IsManagedPath(curDir);
        }
示例#17
0
        public void Commit_NonRecursiveDepthEmpty()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Empty);
            string dir = sbox.Wc;

            string name = Path.Combine(dir, "sd");
            string f = Path.Combine(name, "f");

            Client.CreateDirectory(name);
            File.WriteAllText(f, "qq");
            Client.Add(f);

            Client.Commit(name);

            Collection<SvnStatusEventArgs> st;

            Client.CropWorkingCopy(name, SvnDepth.Empty);
            Client.Delete(name);

            Client.GetStatus(name, out st);
            Assert.That(st.Count, Is.EqualTo(1));

            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                Collection<SvnWorkingCopyEntryEventArgs> lst;
                wcc.GetEntries(name, out lst);

                Assert.That(lst.Count, Is.EqualTo(1));
            }

            SvnCommitArgs ca = new SvnCommitArgs();
            ca.Depth = SvnDepth.Empty;
            Client.Commit(name, ca);
        }
示例#18
0
        public void List_ListDetails()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Default);

            string WcPath = sbox.Wc;
            Uri    WcUri  = sbox.Uri;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string oneFile = Path.Combine(WcPath, "LocalFileForTestList");
                TouchFile(oneFile);
                client.Add(oneFile);

                SvnCommitResult ci;
                client.Commit(WcPath, out ci);
                SvnUpdateResult r;
                client.Update(WcPath, out r);

                Assert.That(r, Is.Not.Null);
                Assert.That(r.HasRevision);
                Assert.That(r.HasResultMap);
                Assert.That(r.Revision, Is.EqualTo(ci.Revision));

                bool        visited = false;
                SvnListArgs a       = new SvnListArgs();
                a.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

                client.List(new SvnPathTarget(WcPath), a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");
                    Assert.That(e.RepositoryRoot, Is.Null, "Only valid when listing a Uri");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");


                visited = false;
                client.List(WcUri, a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");

                SvnWorkingCopyClient wcC = new SvnWorkingCopyClient();
                SvnWorkingCopyState  state;
                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.True);

                client.SetProperty(oneFile, "svn:mime-type", "application/binary");

                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.False);
            }
        }
示例#19
0
        static string GetSvnCasing(SvnItem item)
        {
            string name = null;
            // Find the correct casing
            using (SvnWorkingCopyClient wcc = new SvnWorkingCopyClient())
            {
                SvnWorkingCopyEntriesArgs ea = new SvnWorkingCopyEntriesArgs();
                ea.ThrowOnCancel = false;
                ea.ThrowOnError = false;

                wcc.ListEntries(item.Directory, ea,
                    delegate(object sender, SvnWorkingCopyEntryEventArgs e)
                    {
                        if (string.Equals(e.FullPath, item.FullPath, StringComparison.OrdinalIgnoreCase))
                        {
                            name = e.FullPath;
                        }
                    });
            }

            return name;
        }
        private static long GetRevision(String path)
        {
            if (String.IsNullOrEmpty(path))
                return 0;

            if (!IsWorkingCopy(path))
                return 0;

            long remoteRevision = 0;
            long localRevision = 0;

            try
            {
                using (SvnClient client = new SvnClient())
                {
                    SvnStatusArgs statusargs = new SvnStatusArgs();
                    statusargs.Depth = SvnDepth.Empty; // Adjust this to check direct files, or (recursive) directories etc
                    statusargs.RetrieveAllEntries = true;
                    statusargs.RetrieveRemoteStatus = true;

                    Collection<SvnStatusEventArgs> statuses;
                    client.GetStatus(path, statusargs, out statuses);

                    remoteRevision = statuses[0].Revision;
                }
            }
            catch (Exception)
            {
                Logger.Write("Error while retrieving information from remote repo", LogLevel.Warning);
            }

            using (SvnWorkingCopyClient client = new SvnWorkingCopyClient())
            {
                SvnWorkingCopyVersion version;
                if (client.GetVersion(path, out version))
                {
                    if (version.End >= 0)
                        localRevision = version.End;
                }
            }

            if (remoteRevision > localRevision)
            {
                Logger.Write("Working copy seems to be out of date", LogLevel.Warning);
            }

            return localRevision;
        }
示例#21
0
        public void List_ListDetails()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Default);

            string WcPath = sbox.Wc;
            Uri WcUri = sbox.Uri;

            using (SvnClient client = NewSvnClient(true, false))
            {

                string oneFile = Path.Combine(WcPath, "LocalFileForTestList");
                TouchFile(oneFile);
                client.Add(oneFile);

                SvnCommitResult ci;
                client.Commit(WcPath, out ci);
                SvnUpdateResult r;
                client.Update(WcPath, out r);

                Assert.That(r, Is.Not.Null);
                Assert.That(r.HasRevision);
                Assert.That(r.HasResultMap);
                Assert.That(r.Revision, Is.EqualTo(ci.Revision));

                bool visited = false;
                SvnListArgs a = new SvnListArgs();
                a.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

                client.List(new SvnPathTarget(WcPath), a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");
                    Assert.That(e.RepositoryRoot, Is.Null, "Only valid when listing a Uri");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");

                visited = false;
                client.List(WcUri, a, delegate(object sender, SvnListEventArgs e)
                {
                    Assert.That(e.Entry, Is.Not.Null, "Entry set");

                    if (e.Path == "LocalFileForTestList")
                    {
                        Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath");
                        Assert.That(e.Lock, Is.Null);
                        Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName));
                        Assert.That(e.Entry.FileSize, Is.EqualTo(0));
                        Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File));
                        Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision));
                        Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0)));
                        visited = true;
                    }
                });
                Assert.That(visited, Is.True, "Visited is true");

                SvnWorkingCopyClient wcC = new SvnWorkingCopyClient();
                SvnWorkingCopyState state;
                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.True);

                client.SetProperty(oneFile, "svn:mime-type", "application/binary");

                Assert.That(wcC.GetState(oneFile, out state));

                Assert.That(state, Is.Not.Null);
                Assert.That(state.IsTextFile, Is.False);
            }
        }
        protected override IEnumerable <string> GetCommitMessages()
        {
            SvnWorkingCopyVersion svnWorkingCopyVersion;

            using (var svnWorkingCopyClient = new SvnWorkingCopyClient())
            {
                if (!svnWorkingCopyClient.GetVersion(this.RepositoryPath,
                                                     out svnWorkingCopyVersion) ||
                    svnWorkingCopyVersion == null)
                {
                    this.LogError?.Invoke($"Could not get working copy version for {this.RepositoryPath}");
                    return(Enumerable.Empty <string>());
                }
            }

            if (svnWorkingCopyVersion.Modified)
            {
                this.LogError?.Invoke($"Could not calculate version for {this.RepositoryPath} due to local uncomitted changes");
                return(Enumerable.Empty <string>());
            }

            Collection <SvnLogEventArgs> logItems;

            using (var svnClient = new SvnClient())
            {
                SvnRevision start;
                if (this.BaseRevision == null)
                {
                    start = SvnRevision.Zero;
                }
                else
                {
                    int startRevision;
                    if (!int.TryParse(this.BaseRevision,
                                      out startRevision))
                    {
                        this.LogError?.Invoke($"could not parse {nameof(this.BaseRevision)} to {typeof (int).FullName}: {this.BaseRevision}");
                        return(Enumerable.Empty <string>());
                    }
                    start = startRevision;
                }

                this.LogInfo?.Invoke($"retrieving commits from {this.RepositoryPath} since {start}");

                var svnLogArgs = new SvnLogArgs
                {
                    StrictNodeHistory = false,
                    Range             = new SvnRevisionRange(start,
                                                             SvnRevision.Head)
                };
                if (!svnClient.GetLog(this.RepositoryPath,
                                      svnLogArgs,
                                      out logItems) ||
                    logItems == null)
                {
                    this.LogError?.Invoke($"Could not get log for repository in {this.RepositoryPath}");
                    return(null);
                }
            }

            var commitMessages = logItems.OrderBy(arg => arg.Revision)
                                 .Select(arg => arg.LogMessage);

            return(commitMessages);
        }