예제 #1
0
        private static void OnSvnFileExported(SvnFileExportedEventArgs args)
        {
            var handler = SvnFileExported;

            if (handler != null)
            {
                handler(null, args);
            }
        }
예제 #2
0
        public static void Export(string targetDiretory, Uri svnRoot, Dictionary <string, SvnFileInfo> files)
        {
            foreach (var item in files)
            {
                if (item.Value.Action != LogCmdResultItem.ItemAction.Delete &&
                    item.Value.NodeKind == LogCmdResultItem.ItemNodeKind.File)
                {
                    var altPath = item.Key.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
                    altPath = altPath.TrimStart('\\');
                    var localFile = Path.Combine(targetDiretory, altPath);

                    var svnFile = new Uri(svnRoot, svnRoot.LocalPath.TrimEnd('/') + item.Key);

                    Directory.CreateDirectory(Path.GetDirectoryName(localFile));
                    //ExportCmdWrapper.Export(Uri.EscapeUriString(svnFile.ToString()), item.Value.Revision, localFile);

                    string cmd       = Path.Combine(Environment.CurrentDirectory, SvnExecutableName);
                    string exportCmd = String.Format(SvnExportCmd, svnFile.ToString(), item.Value.Revision, localFile);

                    Process process = new Process();
                    process.StartInfo.FileName        = cmd;
                    process.StartInfo.Arguments       = exportCmd;
                    process.StartInfo.CreateNoWindow  = true;
                    process.StartInfo.UseShellExecute = false;
                    process.Start();
                    process.WaitForExit();
                    if (process.ExitCode != 0)
                    {
                        throw new Exception(String.Format("File {0} export failed.", svnFile));
                    }
                }

                var e = new SvnFileExportedEventArgs
                {
                    SvnFile  = item.Key,
                    Revision = item.Value.Revision,
                    Action   = item.Value.Action
                };
                OnSvnFileExported(e);
            }
        }