Esempio n. 1
0
 private void Checkout(Uri svnUri, SvnChangeset set, string workPath)
 {
     using (SvnClient svn = new SvnClient())
     {
         if (Directory.Exists(workPath))
         {
             try
             {
                 svn.Switch(workPath, new SvnUriTarget(svnUri, set.Revision));
             }
             catch (SvnFileSystemException)
             {
                 // this seems to happen when you try to switch to a branch
                 // without any file changes - revision 814 in Cyotek triggers this
                 // in this case, we do a full checkout which seems to succeed fine
                 ShellHelpers.DeletePath(workPath);
                 this.FullCheckout(svn, svnUri, set, workPath);
             }
         }
         else
         {
             this.FullCheckout(svn, svnUri, set, workPath);
         }
     }
 }
Esempio n. 2
0
        private void MigrateBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            MigrationOptions options;
            Uri svnUri;
            SvnChangesetCollection sets;
            string           workPath;
            string           gitPath;
            StringCollection includes;
            StringCollection excludes;

            options  = (MigrationOptions)e.Argument;
            svnUri   = options.SvnUri;
            workPath = options.WorkingPath;
            gitPath  = options.RepositoryPath;
            includes = this.GetGlobs(includesTextBox);
            excludes = this.GetGlobs(excludesTextBox);

            sets = options.Revisions;

            this.CreateGitRepository(gitPath);

            for (int i = 0; i < sets.Count; i++)
            {
                SvnChangeset  set;
                int           progress;
                ProgressState args;

                set      = sets[i];
                progress = Convert.ToInt32((double)i / sets.Count * 100);

                args = new ProgressState
                {
                    Total     = sets.Count,
                    Current   = i + 1,
                    Changeset = set
                };

                if (string.IsNullOrEmpty(set.Author.EmailAddress))
                {
                    set.Author = options.Authors.GetMapping(set.Author.Name);
                }

                if (this.ShouldCheckout(set, includes, excludes))
                {
                    migrateBackgroundWorker.ReportProgress(progress, args);

                    this.Checkout(svnUri, set, workPath);
                    SimpleFolderSync.SyncFolders(workPath, gitPath, includes, excludes);

                    try
                    {
                        this.Commit(gitPath, set);
                    }
                    catch (EmptyCommitException)
                    {
                        // ignore, if we get this the user has
                        // disabled the option to allow empty commits
                    }
                }
                else
                {
                    args.Changeset = null;
                    migrateBackgroundWorker.ReportProgress(progress, args);
                }

                if (migrateBackgroundWorker.CancellationPending)
                {
                    throw new ApplicationException("User cancelled operation.");
                }
            }

            ShellHelpers.DeletePath(workPath);
        }