Exemplo n.º 1
0
        private static void CounterfeitRevProps(SvnClient svnClient, SvnTarget target, IVSSVersion vssVersion)
        {
            SvnInfoEventArgs infoEventArgs;

            svnClient.GetInfo(target, out infoEventArgs);

            var props = new SvnRevProps(svnREVPROPSPATH, infoEventArgs.Revision);

            if (vssVersion != null)
            {
                props.SetAuthor(vssVersion.Username);
                props.SetDate(vssVersion.Date);
            }
        }
Exemplo n.º 2
0
        private static bool ImportDirectories()
        {
            var    uri = new Uri(string.Format("{0}{1}", svnURL, svnPROJ));
            string dir = Path.Combine(repoDIR, vssPROJ.Substring(2).Replace("/", "\\"));

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            using (SvnClient svnClient = GetSvnClient())
            {
                var importArgs = new SvnImportArgs
                {
                    LogMessage = string.Format("Initial import from VSS on {0}", DateTime.Now)
                };

                SvnInfoEventArgs infoEventArgs;
                try
                {
                    trunkexists = svnClient.GetInfo(SvnTarget.FromUri(uri), out infoEventArgs);
                    migrateLog.DebugFormat(svnClient.GetInfo(SvnTarget.FromUri(uri), out infoEventArgs) ?
                                           "Getting trunk revision was successful." :
                                           "Getting trunk revision was NOT successful!");

                    migrateLog.DebugFormat("Base Revision: " + infoEventArgs.Revision);

                    if (infoEventArgs.Revision == 0)
                    {
                        if (!svnClient.Import(dir, uri, importArgs))
                        {
                            return(false);
                        }
                    }
                }
                catch (Exception)
                {
                    if (!svnClient.Import(dir, uri, importArgs))
                    {
                        return(false);
                    }
                }

                var tagurl    = new Uri(String.Format("{1}/{0}", svnTAG, svnURL));
                var branchurl = new Uri(String.Format("{1}/{0}", svnBRANCH, svnURL));

                try
                {
                    svnClient.GetInfo(tagurl, out infoEventArgs);
                    svnClient.GetInfo(branchurl, out infoEventArgs);
                    migrateLog.DebugFormat(svnClient.GetInfo(tagurl, out infoEventArgs)?
                                           "Getting tag dir revision was successful." :
                                           "Getting tag dir revision was NOT successful!");

                    migrateLog.DebugFormat(svnClient.GetInfo(branchurl, out infoEventArgs)?
                                           "Getting branch dir revision was successful." :
                                           "Getting branch dir revision was NOT successful!");
                }
                catch (SvnRepositoryIOException)
                {
                    var tagdircreated = svnClient.RemoteCreateDirectory((tagurl), new SvnCreateDirectoryArgs
                    {
                        LogMessage = "Initial creation of tag directory", CreateParents = true
                    });
                    var branchdircreated = svnClient.RemoteCreateDirectory((branchurl),
                                                                           new SvnCreateDirectoryArgs
                    {
                        LogMessage = "Initial creation of branch directory", CreateParents = true
                    });
                }

                try
                {
                    svnClient.GetInfo(uri, out infoEventArgs);
                }
                catch (SvnRepositoryIOException)
                {
                    svnClient.RemoteCreateDirectory((uri),
                                                    new SvnCreateDirectoryArgs
                    {
                        LogMessage = "Initial import", CreateParents = true
                    });
                }


                migrateLog.DebugFormat(dir);
                //Update the author and time of the first import revision to correspond to the first file revision
                //minus a minute in time for proper ordering of the revisions in time);
                if (!string.IsNullOrEmpty(svnREVPROPSPATH))
                {
                    svnClient.GetInfo(trunkexists
                                          ? SvnTarget.FromUri(uri)
                                          : SvnTarget.FromString(dir),
                                      out infoEventArgs);

                    var props = new SvnRevProps(svnREVPROPSPATH, infoEventArgs.Revision);

                    //This helps to make sure the revisions are imported in chronological order
                    props.SetDate(revisions.Keys[0].Time.AddMinutes(-1));
                }

                Cleanup();

                var checkOutArgs = new SvnCheckOutArgs {
                    Depth = SvnDepth.Infinity
                };
                return(svnClient.CheckOut(uri, dir, checkOutArgs));
            }
        }