Exemplo n.º 1
1
        public override void OnExecute(CommandEventArgs e)
        {
            List<SvnItem> items = new List<SvnItem>(e.Selection.GetSelectedSvnItems(true));

            e.GetService<IProgressRunner>().RunModal("Running Cleanup",
                delegate(object sender, ProgressWorkerArgs a)
                {
                    HybridCollection<string> wcs = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);

                    foreach (SvnItem item in items)
                    {
                        if (!item.IsVersioned)
                            continue;

                        SvnWorkingCopy wc = item.WorkingCopy;

                        if (wc != null && !wcs.Contains(wc.FullPath))
                            wcs.Add(wc.FullPath);
                    }

                    SvnCleanUpArgs args = new SvnCleanUpArgs();
                    args.ThrowOnError = false;
                    foreach (string path in wcs)
                        a.Client.CleanUp(path, args);
                });
        }
Exemplo n.º 2
0
        public override void OnExecute(CommandEventArgs e)
        {
            List <SvnItem> items = new List <SvnItem>(e.Selection.GetSelectedSvnItems(true));

            e.GetService <IProgressRunner>().RunModal(CommandStrings.CleaningWorkingCopy,
                                                      delegate(object sender, ProgressWorkerArgs a)
            {
                HybridCollection <string> wcs = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

                foreach (SvnItem item in items)
                {
                    if (!item.IsVersioned)
                    {
                        continue;
                    }

                    SvnWorkingCopy wc = item.WorkingCopy;

                    if (wc != null && !wcs.Contains(wc.FullPath))
                    {
                        wcs.Add(wc.FullPath);
                    }
                }

                SvnCleanUpArgs args = new SvnCleanUpArgs();
                args.ThrowOnError   = false;
                foreach (string path in wcs)
                {
                    a.Client.CleanUp(path, args);
                }
            });
        }
Exemplo n.º 3
0
        static int Main(string[] args)
        {
            try
            {
                Console.WriteLine("Svn2: {0}", Assembly.GetExecutingAssembly().GetName().Version);

                if (args.Length < 1)
                {
                    Usage();
                    return(-2);
                }

                string command = args[0];
                if (command == "/?" || command == "-?" || command == "--help")
                {
                    Usage();
                    return(-2);
                }

                string path = (args.Length == 2)
                    ? Path.GetFullPath(args[1])
                    : Path.GetFullPath(Environment.CurrentDirectory);

                SvnClient client = new SvnClient();

                switch (command)
                {
                case "sync":
                {
                    SvnStatusArgs statusArgs = new SvnStatusArgs();
                    statusArgs.Depth        = SvnDepth.Infinity;
                    statusArgs.ThrowOnError = true;
                    client.Status(path, statusArgs, new EventHandler <SvnStatusEventArgs>(delegate(object sender, SvnStatusEventArgs e)
                        {
                            switch (e.LocalContentStatus)
                            {
                            case SvnStatus.NotVersioned:
                                Console.WriteLine(" {0} {1}", StatusToChar(e.LocalContentStatus), e.FullPath);
                                if (File.Exists(e.FullPath))
                                {
                                    FileSystem.DeleteFile(e.FullPath, UIOption.OnlyErrorDialogs,
                                                          RecycleOption.SendToRecycleBin);
                                }
                                else if (Directory.Exists(e.FullPath))
                                {
                                    FileSystem.DeleteDirectory(e.FullPath, UIOption.OnlyErrorDialogs,
                                                               RecycleOption.SendToRecycleBin);
                                }
                                break;
                            }
                        }));
                }
                break;

                case "cleanup":
                {
                    Console.WriteLine("Cleaning up {0}", path);
                    SvnCleanUpArgs cleanupArgs = new SvnCleanUpArgs();
                    cleanupArgs.ThrowOnError = true;
                    cleanupArgs.Notify      += new EventHandler <SvnNotifyEventArgs>(delegate(object sender, SvnNotifyEventArgs e)
                        {
                            Console.WriteLine(" L {0}", e.FullPath);
                        });
                    client.CleanUp(path, cleanupArgs);
                }
                break;

                case "revert":
                {
                    Console.WriteLine("Reverting {0}", path);
                    SvnRevertArgs revertArgs = new SvnRevertArgs();
                    revertArgs.Depth        = SvnDepth.Infinity;
                    revertArgs.ThrowOnError = true;
                    revertArgs.Notify      += new EventHandler <SvnNotifyEventArgs>(delegate(object sender, SvnNotifyEventArgs e)
                        {
                            Console.WriteLine(" R {0}", e.FullPath);
                        });
                    client.Revert(path, revertArgs);
                }
                break;

                case "status":
                {
                    SvnStatusArgs statusArgs = new SvnStatusArgs();
                    statusArgs.Depth        = SvnDepth.Infinity;
                    statusArgs.ThrowOnError = true;
                    client.Status(path, statusArgs, new EventHandler <SvnStatusEventArgs>(delegate(object sender, SvnStatusEventArgs e)
                        {
                            Console.WriteLine(" {0} {1}", StatusToChar(e.LocalContentStatus), e.FullPath);
                        }));
                }
                break;

                default:
                    throw new Exception(string.Format("Unsupported '{0}' command", command));
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
#if DEBUG
                Console.Error.WriteLine(ex.StackTrace);
#endif
                return(-1);
            }
        }
Exemplo n.º 4
0
        static int Main(string[] args)
        {
            try
            {
                Console.WriteLine("Svn2: {0}", Assembly.GetExecutingAssembly().GetName().Version);

                if (args.Length < 1)
                {
                    Usage();
                    return -2;
                }

                string command = args[0];
                if (command == "/?" || command == "-?" || command == "--help")
                {
                    Usage();
                    return -2;
                }

                string path = (args.Length == 2) 
                    ? Path.GetFullPath(args[1])
                    : Path.GetFullPath(Environment.CurrentDirectory);

                SvnClient client = new SvnClient();

                switch (command)
                {
                    case "sync":
                        {
                            SvnStatusArgs statusArgs = new SvnStatusArgs();
                            statusArgs.Depth = SvnDepth.Infinity;
                            statusArgs.ThrowOnError = true;
                            client.Status(path, statusArgs, new EventHandler<SvnStatusEventArgs>(delegate(object sender, SvnStatusEventArgs e)
                            {
                                switch (e.LocalContentStatus)
                                {
                                    case SvnStatus.NotVersioned:
                                        Console.WriteLine(" {0} {1}", StatusToChar(e.LocalContentStatus), e.FullPath);
                                        if (File.Exists(e.FullPath))
                                        {
                                            FileSystem.DeleteFile(e.FullPath, UIOption.OnlyErrorDialogs,
                                                RecycleOption.SendToRecycleBin);
                                        }
                                        else if (Directory.Exists(e.FullPath))
                                        {
                                            FileSystem.DeleteDirectory(e.FullPath, UIOption.OnlyErrorDialogs,
                                                RecycleOption.SendToRecycleBin);
                                        }
                                        break;
                                }
                            }));
                        }
                        break;
                    case "cleanup":
                        {
                            Console.WriteLine("Cleaning up {0}", path);
                            SvnCleanUpArgs cleanupArgs = new SvnCleanUpArgs();
                            cleanupArgs.ThrowOnError = true;
                            cleanupArgs.Notify += new EventHandler<SvnNotifyEventArgs>(delegate(object sender, SvnNotifyEventArgs e)
                                {
                                    Console.WriteLine(" L {0}", e.FullPath);
                                });
                            client.CleanUp(path, cleanupArgs);
                        }
                        break;
                    case "revert":
                        {
                            Console.WriteLine("Reverting {0}", path);
                            SvnRevertArgs revertArgs = new SvnRevertArgs();
                            revertArgs.Depth = SvnDepth.Infinity;
                            revertArgs.ThrowOnError = true;
                            revertArgs.Notify += new EventHandler<SvnNotifyEventArgs>(delegate(object sender, SvnNotifyEventArgs e)
                                {
                                    Console.WriteLine(" R {0}", e.FullPath);
                                });
                            client.Revert(path, revertArgs);
                        }
                        break;
                    case "status":
                        {
                            SvnStatusArgs statusArgs = new SvnStatusArgs();
                            statusArgs.Depth = SvnDepth.Infinity;
                            statusArgs.ThrowOnError = true;
                            client.Status(path, statusArgs, new EventHandler<SvnStatusEventArgs>(delegate(object sender, SvnStatusEventArgs e)
                                {
                                    Console.WriteLine(" {0} {1}", StatusToChar(e.LocalContentStatus), e.FullPath);
                                }));
                        }
                        break;
                    default:
                        throw new Exception(string.Format("Unsupported '{0}' command", command));
                }

                return 0;
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
#if DEBUG
                Console.Error.WriteLine(ex.StackTrace);
#endif
                return -1;
            }
        }