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);
        }
Ejemplo n.º 2
0
        public IDictionary <string, string> GetPathProperties(string path, int revision)
        {
            SvnClient client = AllocSvnClient();

            try
            {
                Collection <SvnPropertyListEventArgs> pc;
                client.GetPropertyList(MakeTarget(path, revision), out pc);
                Dictionary <string, string> properties = new Dictionary <string, string>();
                foreach (var proplist in pc)
                {
                    foreach (var property in proplist.Properties)
                    {
                        properties.Add(property.Key, property.StringValue.ToLowerInvariant());
                    }
                }
                return(properties);
            }
            finally
            {
                FreeSvnClient(client);
            }
        }
Ejemplo n.º 3
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);

        }
Ejemplo n.º 4
0
    void Main2(String[] args)
    {
        //  from where                                      to where
        urls    = new[] { "https://svn.code.sf.net/p/syncproj/code/", "https://github.com/tapika/syncProj.git/trunk" };
        workDir = new[] { @"d:\Prototyping\svnSource", @"d:\Prototyping\svnTarget" };
        Uri[] uris = new Uri[2];

        for (int i = 0; i < urls.Length; i++)
        {
            uris[i] = new Uri(urls[i]);

            if (!Directory.Exists(workDir[i]))
            {
                if (i == 0)
                {
                    svn.CheckOut(uris[i], workDir[i], new SvnCheckOutArgs()
                    {
                        Revision = new SvnRevision(i)
                    });
                }
                else
                {
                    svn.CheckOut(uris[i], workDir[i]);
                }
            }
        }

        SvnInfoEventArgs info;

        svn.GetInfo(uris[0], out info);

        SvnLogArgs svnArgs = new SvnLogArgs {
            Start = 1 /*change next svn revision number*/, End = info.Revision, RetrieveAllProperties = true
        };
        Collection <SvnLogEventArgs> list;

        svn.GetLog(uris[0], svnArgs, out list);


        foreach (SvnLogEventArgs log in list)
        {
            long   rev = log.Revision;
            String msg = log.LogMessage;
            Console.WriteLine("Commit " + rev + ": " + msg);

            svn.Update(workDir[0], new SvnUpdateArgs()
            {
                Revision = new SvnRevision(rev)
            });

            foreach (SvnChangeItem chItem in log.ChangedPaths)
            {
                String path = chItem.Path;

                switch (chItem.Action)
                {
                case SvnChangeAction.Add:
                    if (chItem.NodeKind == SvnNodeKind.Directory)
                    {
                        try { svn.CreateDirectory(workDir[1] + path); } catch { }
                    }
                    else
                    {
                        File.Copy(workDir[0] + path, workDir[1] + path, true);
                        try { svn.Add(workDir[1] + path); } catch { }
                    }
                    break;

                case SvnChangeAction.Replace:
                case SvnChangeAction.Delete:
                    if (chItem.NodeKind == SvnNodeKind.Directory)
                    {
                        svn.Delete(workDir[1] + path);
                    }
                    else
                    {
                        File.Delete(workDir[1] + path);
                        svn.Delete(workDir[1] + path);
                    }
                    break;

                case SvnChangeAction.Modify:
                    if (chItem.NodeKind == SvnNodeKind.Directory)
                    {
                        Collection <SvnPropertyListEventArgs> propList = null;
                        svn.GetPropertyList(new SvnPathTarget(workDir[0] + path), out propList);

                        foreach (SvnPropertyListEventArgs p in propList)
                        {
                            foreach (SvnPropertyValue pv in p.Properties)
                            {
                                svn.SetProperty(workDir[1] + path, pv.Key, pv.StringValue);
                            }
                        }
                    }
                    else
                    {
                        File.Copy(workDir[0] + path, workDir[1] + path, true);
                    }
                    break;
                }
            }
            svn.Commit(workDir[1], new SvnCommitArgs()
            {
                LogMessage = msg
            });
        }
    }
Ejemplo n.º 5
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);
        }