private void checkout(string alias)
        {
            string projectUrl = Url.TrimEnd('/') + "/" + alias;
            string tempFolder = TempFolderPath(alias);

            bool workingCopy = false;

            if (Directory.Exists(Path.Combine(tempFolder, ".svn")))
            {
                workingCopy = true;
            }

            using (SvnClient client = new SvnClient())
            {
                client.LoadConfiguration("path");
                client.Authentication.DefaultCredentials = new NetworkCredential(Login, Password);

                if (!workingCopy)
                {
                    if (Directory.Exists(Path.Combine(TempFolderPath(string.Empty), ".svn")))
                    {
                        SvnUriTarget target = new SvnUriTarget(projectUrl);

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

                        Collection <SvnInfoEventArgs> info;
                        bool res = client.GetInfo(target, new SvnInfoArgs {
                            ThrowOnError = false
                        }, out info);
                        if (res)
                        {
                            client.CheckOut(target, tempFolder);
                        }
                    }
                    else
                    {
                        SvnUriTarget target = new SvnUriTarget(Url);
                        Collection <SvnInfoEventArgs> info;
                        bool res = client.GetInfo(target, new SvnInfoArgs {
                            ThrowOnError = false
                        }, out info);

                        if (res)
                        {
                            client.CheckOut(target, TempFolderPath(string.Empty));
                        }
                    }
                }
                else
                {
                    client.Update(tempFolder);
                }
            }
        }
Exemple #2
0
        internal void CheckOut(SvnClient client, SvnUriTarget url, string path, SvnCheckOutArgs args, bool cleanUpWhenLocked)
        {
            try
            {
                bool foundLockException = false;
                int  cleanupCount       = 0;
                do
                {
                    try
                    {
                        foundLockException = false;

                        if (args != null)
                        {
                            client.CheckOut(url, path, args);
                        }
                        else
                        {
                            client.CheckOut(url, path);
                        }
                    }
                    catch (SvnException ex)
                    {
                        foundLockException = true;

                        if ((ex.SvnErrorCode == SvnErrorCode.SVN_ERR_WC_CLEANUP_REQUIRED ||
                             ex.SvnErrorCode == SvnErrorCode.SVN_ERR_WC_LOCKED ||
                             ex.SvnErrorCode == SvnErrorCode.SVN_ERR_WC_DB_ERROR ||
                             ex.SvnErrorCode == SvnErrorCode.SVN_ERR_SQLITE_BUSY) && cleanUpWhenLocked)
                        {
                            client.CleanUp(path, new SvnCleanUpArgs()
                            {
                                ClearDavCache = true, BreakLocks = true, IncludeExternals = true,
                            });
                            cleanupCount++;
                        }
                        else
                        {
                            throw;
                        }

                        if (cleanupCount >= 5)
                        {
                            throw new Exception("Cleanup was done 5 time. So we decided to stop it. You can try Checking out again.");
                        }
                    }
                } while (foundLockException && cleanUpWhenLocked);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #3
0
        public void CreateDirectory_CreateTrunk()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty);

            using (SvnClient client = NewSvnClient(true, false))
            {
                Uri trunkUri = new Uri(ReposUrl, "trunk/");
                client.RemoteCreateDirectory(trunkUri);

                string trunkPath = sbox.Wc;

                client.CheckOut(trunkUri, trunkPath);

                TouchFile(Path.Combine(trunkPath, "test.txt"));

                Assert.That(SvnTools.IsManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(trunkPath));
                Assert.That(SvnTools.IsBelowManagedPath(Path.Combine(trunkPath, "q/r/s/t/u/v/test.txt")));

                client.Add(Path.Combine(trunkPath, "test.txt"));

                Directory.CreateDirectory(Path.Combine(trunkPath, "dir"));
                TouchFile(Path.Combine(trunkPath, "dir/test.txt"));

                SvnAddArgs aa = new SvnAddArgs();
                aa.AddParents = true;
                client.Add(Path.Combine(trunkPath, "dir/test.txt"), aa);

                client.Commit(trunkPath);

                client.RemoteDelete(trunkUri, new SvnDeleteArgs());
            }
        }
        public static void SyncLocalFolderWithO2XRulesDatabase()
        {
            try
            {
                "in SyncLocalFolderWithO2XRulesDatabase".debug();
                //var targetLocalDir = XRules_Config.PathTo_XRulesDatabase_fromO2;
                var targetLocalDir = PublicDI.config.LocalScriptsFolder;
                var o2XRulesSvn    = PublicDI.config.SvnO2DatabaseRulesFolder;

                "starting Sync with XRules Database to {0}".info(targetLocalDir);
                using (SvnClient client = new SvnClient())
                {
                    if (targetLocalDir.dirExists().isFalse() || targetLocalDir.pathCombine(".svn").dirExists().isFalse())
                    {
                        "First Sync, so doing an SVN Checkout to: {0}".info(targetLocalDir);
                        Files.deleteFolder(targetLocalDir, true);
                        client.CheckOut(new Uri(o2XRulesSvn), targetLocalDir);
                    }
                    else
                    {
                        "Local XRules folder exists, so doing an SVN Update".info();
                        client.Update(targetLocalDir);
                    }
                    "SVN Sync completed".debug();
                }
            }
            catch (Exception ex)
            {
                ex.log("in SvnApi.SyncLocalFolderWithO2XRulesDatabase");
            }
        }
Exemple #5
0
        public static void SyncLocalFolderWithO2XRulesDatabase()
        {
            try
            {
                "in SyncLocalFolderWithO2XRulesDatabase".debug();
                //var targetLocalDir = XRules_Config.PathTo_XRulesDatabase_fromO2;
                var targetLocalDir = PublicDI.config.LocalScriptsFolder;
                var o2XRulesSvn = PublicDI.config.SvnO2DatabaseRulesFolder;

                "starting Sync with XRules Database to {0}".info(targetLocalDir);
                using (SvnClient client = new SvnClient())
                {
                    if (targetLocalDir.dirExists().isFalse() || targetLocalDir.pathCombine(".svn").dirExists().isFalse())
                    {
                        "First Sync, so doing an SVN Checkout to: {0}".info(targetLocalDir);
                        Files.deleteFolder(targetLocalDir, true);
                        client.CheckOut(new Uri(o2XRulesSvn), targetLocalDir);
                    }
                    else
                    {
                        "Local XRules folder exists, so doing an SVN Update".info();
                        client.Update(targetLocalDir);
                    }
                    "SVN Sync completed".debug();
                }
            }
            catch (Exception ex)
            {
                ex.log("in SvnApi.SyncLocalFolderWithO2XRulesDatabase");
            }
        }
Exemple #6
0
        public void Log_LogFromFile()
        {
            SvnSandBox sbox  = new SvnSandBox(this);
            Uri        repos = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.CheckOut(new Uri(repos, "trunk/"), dir);

                int n = 0;
                client.Log(Path.Combine(dir, "index.html"),
                           delegate(object sender, SvnLogEventArgs e)
                {
                    switch (n++)
                    {
                    case 0:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch b - product roadmap and update about page"));
                        break;

                    case 1:
                        Assert.That(e.LogMessage, Is.EqualTo("Merge branch a.  Added medium product"));
                        break;

                    case 2:
                        Assert.That(e.LogMessage, Is.EqualTo("Create initial product structure"));
                        break;
                    }
                });
                Assert.That(n, Is.EqualTo(3));
            }
        }
Exemple #7
0
        public void Resolve_RepeatedEventHookUp_SOC_411()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri projectRoot = new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/scripts");

            using (var svnClient = new SvnClient())
            {
                for (int i = 0; i < 3; i++)
                {
                    string workingcopy = sbox.GetTempDir();
                    Directory.CreateDirectory(workingcopy);

                    svnClient.Authentication.UserNamePasswordHandlers += DoNowt;
                    try
                    {
                        SvnUpdateResult svnUpdateResult;
                        SvnCheckOutArgs ca = new SvnCheckOutArgs() { Depth = SvnDepth.Files };
                        Assert.IsTrue(svnClient.CheckOut(projectRoot, workingcopy, ca, out svnUpdateResult));
                        Assert.IsNotNull(svnUpdateResult);
                        Assert.IsTrue(svnUpdateResult.HasRevision);
                    }
                    finally
                    {
                        svnClient.Authentication.UserNamePasswordHandlers -= DoNowt;
                    }
                }
            }
        }
Exemple #8
0
             /// <summary>
             /// 初始化 如果没有被管理,则签出
             /// </summary>
             /// <returns></returns>
            public bool Init()
            
    {
                    ShowInfo("正在初始化....");

                    bool result = true;
                    HandEvents();

                    if(!SvnTools.IsManagedPath(GetAppLoc()))//查看某目录是否是受svn管理的状态, 即是否为工作副本
                    
        {
                            notiny = "正在检出文件.";
                            ShowInfo();

                            result = SC.CheckOut(new SvnUriTarget(svnurl), GetAppLoc());
                            ShowInfo("文件检出完成.");

                        
        }

                    ShowInfo("初始化完毕.");

                    return result;
                
    }
Exemple #9
0
        public void Create(SandBoxRepository type, bool useTrunk)
        {
            _repositoryUri = CreateRepository(type);

            _uri = _repositoryUri;

            if (useTrunk)
            {
                switch (type)
                {
                case SandBoxRepository.Default:
                case SandBoxRepository.DefaultBranched:
                case SandBoxRepository.MergeScenario:
                case SandBoxRepository.AnkhSvnCases:
                case SandBoxRepository.Greek:
                    _uri = new Uri(_repositoryUri, "trunk/");
                    break;
                }
            }

            using (SvnClient cl = new SvnClient())
            {
                cl.UseDefaultConfiguration(); // Don't load config

                cl.CheckOut(_uri, Wc);
            }
        }
Exemple #10
0
        public bool checkedOut(UsuarioSVN usuSVN)
        {
            SvnUpdateResult result;

            SvnCheckOutArgs args = new SvnCheckOutArgs();

            using (SvnClient client = new SvnClient())
            {
                try
                {
                    client.Authentication.ForceCredentials(usuSVN.Nombre, usuSVN.Contraseña);
                    //SvnUriTarget is a wrapper class for SVN repository URIs
                    SvnUriTarget target = new SvnUriTarget(usuSVN.URL);
                    client.Authentication.SslServerTrustHandlers += new EventHandler <SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);


                    if (client.CheckOut(target, usuSVN.RutaLocal, args, out result))
                    {
                        return(true);
                    }
                }
                catch (SvnException se)
                {
                    return(false);
                }
                catch (UriFormatException ufe)
                {
                    return(false);
                }
            }
            return(true);
        }
        public override string CheckOut(IPackageTree packageTree, FileSystemInfo destination)
        {
            SvnUpdateResult result = null;

            using (var client = new SvnClient())
            {
                try
                {
                    var svnOptions = new SvnCheckOutArgs();
                    if (UseRevision.HasValue)
                        svnOptions.Revision = new SvnRevision(UseRevision.Value);
                    client.CheckOut(new SvnUriTarget(new Uri(Url)), destination.FullName, svnOptions, out result);
                }
                catch (SvnRepositoryIOException sre)
                {
                    HandleExceptions(sre);
                }
                catch (SvnObstructedUpdateException sue)
                {
                    HandleExceptions(sue);
                }
            }

            return result.Revision.ToString();
        }
Exemple #12
0
        public void Resolve_RepeatedEventHookUp_SOC_411()
        {
            SvnSandBox sbox        = new SvnSandBox(this);
            Uri        projectRoot = new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk/scripts");

            using (var svnClient = new SvnClient())
            {
                for (int i = 0; i < 3; i++)
                {
                    string workingcopy = sbox.GetTempDir();
                    Directory.CreateDirectory(workingcopy);

                    svnClient.Authentication.UserNamePasswordHandlers += DoNowt;
                    try
                    {
                        SvnUpdateResult svnUpdateResult;
                        SvnCheckOutArgs ca = new SvnCheckOutArgs()
                        {
                            Depth = SvnDepth.Files
                        };
                        Assert.IsTrue(svnClient.CheckOut(projectRoot, workingcopy, ca, out svnUpdateResult));
                        Assert.IsNotNull(svnUpdateResult);
                        Assert.IsTrue(svnUpdateResult.HasRevision);
                    }
                    finally
                    {
                        svnClient.Authentication.UserNamePasswordHandlers -= DoNowt;
                    }
                }
            }
        }
Exemple #13
0
 public void Checkout(string repoUrl, string destinationFolderPath)
 {
     using (SvnClient client = new SvnClient()) {
         client.Authentication.ForceCredentials(SvnUserName, SvnUserPassword);
         client.CheckOut(new Uri(repoUrl), destinationFolderPath);
     }
 }
        private static void Checkout(SvnClient client, Uri svnuri)
        {
            Console.WriteLine("Checking out {0}", svnuri);
            string localPath = Path.Combine(Environment.CurrentDirectory, svnuri.LocalPath.TrimStart(new[] { '/' }));

            client.CheckOut(svnuri, localPath);
        }
Exemple #15
0
 private void FullCheckout(SvnClient svn, Uri svnUri, SvnChangeset set, string workPath)
 {
     svn.CheckOut(svnUri, workPath, new SvnCheckOutArgs
     {
         Revision = set.Revision
     });
 }
Exemple #16
0
        private void dlModWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            SvnClient client = new SvnClient();

            string[] args        = (string[])e.Argument;
            string   remLocation = args[0];
            string   locLocation = args[1];

            remLocation = remLocation.Replace(System.IO.Path.GetFileName(new Uri(remLocation).LocalPath), "");

            locLocation = Path.GetDirectoryName(locLocation);
            Debug.WriteLine(remLocation + "  &&  " + locLocation);

            BackgroundWorker worker = sender as BackgroundWorker;

            if (Directory.Exists(locLocation))
            {
                Directory.Delete(locLocation, true);
            }
            Directory.CreateDirectory(locLocation);
            if (Directory.Exists(Path.Combine(locLocation, ".svn")))
            {
                client.CleanUp(locLocation);
            }

            client.CheckOut(new Uri(remLocation), locLocation);

            fexeProcessDirectory(locLocation); // aka the "thanks a lot, flatgrass" function
        }
Exemple #17
0
        public bool commit(UsuarioSVN usuSVN, string Mensaje)
        {
            bool            EsCorrecto = true;
            SvnUpdateResult result;
            SvnCommitArgs   ca = new SvnCommitArgs();

            using (SvnClient client = new SvnClient())
            {
                try
                {
                    client.Authentication.ForceCredentials(usuSVN.Nombre, usuSVN.Contraseña);
                    //SvnUriTarget is a wrapper class for SVN repository URIs
                    SvnUriTarget target = new SvnUriTarget(usuSVN.URL);
                    client.Authentication.SslServerTrustHandlers += new EventHandler <SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers);

                    // Checkout the code to the specified directory
                    client.CheckOut(target, usuSVN.RutaLocal);

                    // Update the specified working copy path to the head revision
                    //client.Update("c:\\sharpsvn");

                    client.Update(usuSVN.RutaLocal, out result);



                    ca.LogMessage = "Mensaje";
                    client.Commit(usuSVN.RutaLocal, ca);
                }
                catch
                {
                    EsCorrecto = false;
                }
                return(EsCorrecto);
            }
        }
Exemple #18
0
 /// <summary>
 /// 执行检出操作
 /// </summary>
 /// <param name="repositoryPath">svn服务器路径</param>
 /// <param name="workDirectory">工程本地工作路径</param>
 /// <param name="svnPath">本地svn路径</param>
 /// <param name="checkResult">检出操作的结果</param>
 /// <returns>返回检出操作的日志</returns>
 public string CheckOut(string repositoryPath,string workDirectory,out string checkResult,string xmlConfigPath)
 {
     string err;
     string time;
     XmlDao xmlDao = new XmlDao();
     XmlNodeList xmlNodeList=xmlDao.XmlQuery("config/preferences/SvnPath", xmlConfigPath);
     string svnPath=xmlNodeList[0].InnerText;
     using (SvnClient client = new SvnClient())
     {
         Tools tools = new Tools();
         string checkOutLog = "";
         try
         {
             client.CheckOut(new Uri(repositoryPath), workDirectory);
             string args = "checkout " + repositoryPath + " " + workDirectory;
             checkOutLog = tools.BuildProject(svnPath, args, null, out err, out time);
             checkResult = "successful";
             return checkOutLog;
         }
         catch (Exception ex)
         {
             checkResult = " failed";
             checkOutLog = ex.Message;
             return checkOutLog;
         }
     }
 }
Exemple #19
0
        /// <summary>
        /// 执行检出操作
        /// </summary>
        /// <param name="repositoryPath">svn服务器路径</param>
        /// <param name="workDirectory">工程本地工作路径</param>
        /// <param name="svnPath">本地svn路径</param>
        /// <param name="checkResult">检出操作的结果</param>
        /// <returns>返回检出操作的日志</returns>
        public string CheckOut(string repositoryPath, string workDirectory, out string checkResult, string xmlConfigPath)
        {
            string      err;
            string      time;
            XmlDao      xmlDao      = new XmlDao();
            XmlNodeList xmlNodeList = xmlDao.XmlQuery("config/preferences/SvnPath", xmlConfigPath);
            string      svnPath     = xmlNodeList[0].InnerText;

            using (SvnClient client = new SvnClient())
            {
                Tools  tools       = new Tools();
                string checkOutLog = "";
                try
                {
                    client.CheckOut(new Uri(repositoryPath), workDirectory);
                    string args = "checkout " + repositoryPath + " " + workDirectory;
                    checkOutLog = tools.BuildProject(svnPath, args, null, out err, out time);
                    checkResult = "successful";
                    return(checkOutLog);
                }
                catch (Exception ex)
                {
                    checkResult = " failed";
                    checkOutLog = ex.Message;
                    return(checkOutLog);
                }
            }
        }
Exemple #20
0
        protected override void FetchRepository(Arguments arg)
        {
            Guard.AssertNotNullOrEmpty(arg.Url, "SVN URL must be set.");

            SvnUpdateResult result;

            SvnUriTarget target = new SvnUriTarget(arg.Url);

            SvnCheckOutArgs args = new SvnCheckOutArgs();

            if (arg.Revision.HasValue)
            {
                args.Revision = new SvnRevision(arg.Revision.Value);
            }

            args.AllowObstructions = true;
            args.IgnoreExternals   = true;

            using (SvnClient client = new SvnClient())
            {
                client.Progress += ClientOnProgress;
                client.Cancel   += ClientOnCancel;
                try
                {
                    client.CheckOut(target, RootPath, args, out result);
                }
                catch (Exception e)
                {
                }
            }
        }
Exemple #21
0
        public void GetLatestOfDay(DateTime dt, string checkOutDir)
        {
            GetHistory();

            var version = reversedFileversion.FirstOrDefault(x => x.Time.Date == dt.Date);

            if (version == null)
            {
                return;
            }

            using (SvnClient client = new SvnClient())
            {
                client.Update(_excelFilePath);
                Uri uri = new Uri("http://rsin-svnsr.india.rsystems.com/svn/Media-Valet/SDLC/Release/Status/");

                var svnCheckOutArgs = new SvnCheckOutArgs();
                svnCheckOutArgs.Revision = version.Revision;

                if (File.Exists(Path.Combine(checkOutDir, "Progress Tracking.xlsx")))
                {
                    File.Delete(Path.Combine(checkOutDir, "Progress Tracking.xlsx"));
                }
                client.CheckOut(uri, checkOutDir, svnCheckOutArgs);
            }
        }
Exemple #22
0
        /// <summary>
        /// Checks out the latest from the Server, and updates the local working copy.
        /// </summary>
        /// <returns></returns>
        public bool CheckOut(string localRepo)
        {
            var localUri     = _svnClient.GetUriFromWorkingCopy(localRepo);
            var svnUriTarget = new SvnUriTarget(localUri);   //TODO: why is this the only place URI is used?

            _repo = localRepo;
            return(_svnClient.CheckOut(svnUriTarget, _repo));
        }
Exemple #23
0
        public override void Checkout(string url, FilePath path, Revision rev, bool recurse, IProgressMonitor monitor)
        {
            SvnCheckOutArgs args = new SvnCheckOutArgs();

            BindMonitor(args, monitor);
            args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Empty;
            client.CheckOut(new SvnUriTarget(url, GetRevision(rev)), path);
        }
        private bool FullCheckout(int revision)
        {
            CleanFolder();
            var target = new SvnUriTarget(RepositoryUrl, revision);
            var result = _SvnClient.CheckOut(target, LocalPath);

            return(result);
        }
Exemple #25
0
 public void CheckOut(string repositoryURL, string localPath)
 {
     using (SvnClient client = new SvnClient())
     {
         SvnCheckOutArgs args   = new SvnCheckOutArgs();
         SvnUriTarget    target = new SvnUriTarget(repositoryURL);
         client.CheckOut(target, localPath, args);
     }
 }
        /// <summary>
        /// Cambiar de ubicacion la copia de trabajo.
        /// </summary>
        /// <param name="rutaRepositorio"></param>
        /// <param name="rutaCopiaTrabajo"></param>
        /// <param name="rutaRepoAntigua"></param>
        /// <param name="rutaCopiaAntigua"></param>
        /// <returns></returns>
        public static string ActualizarCopiaTrabajo(string rutaRepositorio, string rutaCopiaTrabajo, string rutaRepoAntigua, string rutaCopiaAntigua)
        {
            var msj = "";

            if (rutaRepositorio == rutaCopiaTrabajo)
            {
                return("Error al crear la copia de trabajo: La ruta del repositorio no puede ser la misma que la de la ruta de trabajo.");
            }

            if (rutaCopiaTrabajo == rutaCopiaAntigua)
            {
                return("Exito");
            }

            // TODO Checar si ya hay un repositorio o copia en las rutas proporcionadas.
            using (var client = new SvnClient())
            {
                try
                {
                    // SvnUriTarget es una clase que envuelve las URIs de los repositorios SVN.
                    var target = new SvnUriTarget(rutaRepositorio);

                    // Hacemos el "svn checkout".
                    if (client.CheckOut(target, rutaCopiaTrabajo))
                    {
                        msj = "Exito";
                    }
                    else
                    {
                        msj += "Error al crear la copia de trabajo.";
                    }
                }
                catch (SvnException se)
                {
                    Debug.WriteLine(se.ToString());
                    msj += "Error al crear la copia de trabajo: " + se.Message;

                    if (se.InnerException != null)
                    {
                        msj += " " + se.InnerException.Message;
                    }
                }
                catch (UriFormatException ufe)
                {
                    Debug.WriteLine(ufe.ToString());
                    msj += "Error al con la ruta proporcionada: " + ufe.Message;

                    if (ufe.InnerException != null)
                    {
                        msj += " " + ufe.InnerException.Message;
                    }
                }
            }

            return(msj);
        }
Exemple #27
0
        static void Main(string[] args)
        {
            using (SvnClient client = new SvnClient())
            {
                SvnUpdateResult result;
                // Checkout the code to the specified directory
                client.CheckOut(new Uri("https://svn01.bauerverlag.de/svn/dev_net/dev/Beispiele/"), @"C:\test\SharpSvnCheckoutTest", out result);

            }
        }
Exemple #28
0
 /// <summary>
 ///     Method to checkout current source code from the specified
 ///     repository with given url and a destination folder
 /// </summary>
 /// <param name="repo">
 ///     Repository under consideration
 /// </param>
 /// <param name="url">
 ///     URL from where the source code to checkout
 /// </param>
 /// <param name="destinationFolder">
 ///     Folder to save the source code
 /// </param>
 static public void CheckOutFromSourceSVN(string repo, string url, string destinationFolder)
 {
     if (repo.Equals(eRepository.svn.ToString()))
     {
         using (SvnClient client = new SvnClient())
         {
             SvnUriTarget uriTarget = new SvnUriTarget(url);
             client.CheckOut(uriTarget, destinationFolder);
         }
     }
 }
Exemple #29
0
 protected virtual void CheckOutPackage(SvnClient svnClient, string packageUrl, string packagePath)
 {
     try {
         var packageContentUrl = GetPackageContentUri(packageUrl);
         svnClient.CheckOut(packageContentUrl, packagePath, new SvnCheckOutArgs {
             AllowObstructions = true
         });
         Logger.LogInfo($"CheckOut: {packagePath}");
     } catch (Exception e) {
         Logger.LogError(e.Message);
     }
 }
Exemple #30
0
 public static void Update(ConfigRepository repository, Log log, string directory)
 {
     if (!repository.Enabled)
     {
         Utility.Log(LogStatus.Skipped, string.Format("Disabled - {0}", repository.Url), log);
     }
     else if (string.IsNullOrWhiteSpace(repository.Url))
     {
         Utility.Log(LogStatus.Skipped, string.Format("No Url specified - {0}", repository.Url), log);
     }
     else
     {
         try
         {
             string dir = Path.Combine(directory, repository.Url.GetHashCode().ToString("X"));
             using (var client = new SvnClient())
             {
                 bool cleanUp = false;
                 client.Conflict +=
                     delegate(object sender, SvnConflictEventArgs eventArgs)
                 {
                     eventArgs.Choice = SvnAccept.TheirsFull;
                 };
                 client.Status(dir, new SvnStatusArgs {
                     ThrowOnError = false
                 },
                               delegate(object sender, SvnStatusEventArgs args)
                 {
                     if (args.Wedged)
                     {
                         cleanUp = true;
                     }
                 });
                 if (cleanUp)
                 {
                     client.CleanUp(dir);
                 }
                 client.CheckOut(new Uri(repository.Url), dir);
                 client.Update(dir);
                 Utility.Log(LogStatus.Ok, string.Format("Updated - {0}", repository.Url), log);
             }
         }
         catch (SvnException ex)
         {
             Utility.Log(LogStatus.Error, string.Format("{0} - {1}", ex.RootCause, repository.Url), log);
         }
         catch (Exception ex)
         {
             Utility.Log(LogStatus.Error, string.Format("{0} - {1}", ex.Message, repository.Url), log);
         }
     }
 }
 public bool RefreshWorkingCopy()
 {
     _Logger.Info("Starting to refresh the working copy folder");
     if (!IsSvnControlled(WorkingCopyPath))
     {
         _Logger.Info("No working copy folder or currently not under SVN control. Checking out content");
         SvnCheckOutArgs checkoutArgs = new SvnCheckOutArgs();
         checkoutArgs.Depth   = SvnDepth.Infinity;
         checkoutArgs.Notify += new EventHandler <SvnNotifyEventArgs>(CheckoutNotificationHandler);
         try
         {
             SvnUpdateResult result;
             bool            returncode = _SvnClient.CheckOut(SvnUriTarget.FromString(RepositoryUri), WorkingCopyPath, out result);
             if (returncode)
             {
                 _RepositoryRevision = (int)result.Revision;
                 _Logger.Info(String.Format("Sucessfully checked out revision {0} from {1} to {2}", _RepositoryRevision, RepositoryUri, WorkingCopyPath));
             }
         }
         catch (Exception ex)
         {
             _Logger.Fatal(String.Format("Checkout from {0} to {1} failed! - {2}", RepositoryUri, WorkingCopyPath, ex));
             return(false);
         }
     }
     else
     {
         _Logger.Info("Updating working copy folder");
         SvnUpdateArgs updateArgs = new SvnUpdateArgs();
         updateArgs.Depth     = SvnDepth.Infinity;
         updateArgs.Notify   += new EventHandler <SvnNotifyEventArgs>(CheckoutNotificationHandler);
         updateArgs.Conflict += new EventHandler <SvnConflictEventArgs>(ConflictHandler);
         try
         {
             SvnUpdateResult result;
             bool            returncode = _SvnClient.Update(WorkingCopyPath, updateArgs, out result);
             if (!returncode || (result.Revision < 0))
             {
                 _Logger.Error(String.Format("Updating from {0} to {1} failed!", RepositoryUri, WorkingCopyPath));
                 return(false);
             }
             _RepositoryRevision = (int)result.Revision;
             _Logger.Info(String.Format("Sucessfully updated  to revision {0}", _RepositoryRevision));
         }
         catch (Exception ex)
         {
             _Logger.Fatal(String.Format("Checkout from {0} to {1} failed! - {2}", RepositoryUri, WorkingCopyPath, ex));
             return(false);
         }
     }
     return(true);
 }
Exemple #32
0
 public void CheckOut(string svnUriTarget, string SvnPathTarget)
 {
     ShowState(String.Format("{0} start CheckOut", SvnPathTarget));
     client.CheckOut(new SvnUriTarget(svnUriTarget), SvnPathTarget);
     SvnInfoEventArgs clientInfo;
     client.GetInfo(new SvnPathTarget(SvnPathTarget), out clientInfo);
     if (!client.Update(SvnPathTarget))
     {
         ShowState(String.Format("{0} CheckOut errer", SvnPathTarget));
     }
     ShowState(string.Format("Svn remote path is :{0} \r\nLocal path is :{1} \r\nLast change revision is :{2} \r\nLast change time is :{3} \r\nLast change author is :{4} \r\n",
         clientInfo.Uri, clientInfo.Path, clientInfo.LastChangeRevision, clientInfo.LastChangeTime, clientInfo.LastChangeAuthor, clientInfo.Revision));
 }
Exemple #33
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            WorkerArguments arguments = (WorkerArguments)e.Argument;

            using (SvnClient client = new SvnClient())
            {
                SvnUI.Bind(client, this);
                SvnUriTarget svnUri = new SvnUriTarget(arguments.uri);
                SvnUpdateResult result;
                client.CheckOut(svnUri, arguments.checkoutFolder, arguments.checkoutArgs, out result);
                e.Result = result;
            }
        }
 public static void CheckOut(string source, string target, string SVNUser, string SVNPassword)
 {
     using (SvnClient client = new SvnClient())
     {
         client.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true);
         client.Authentication.SslServerTrustHandlers += delegate(object sender, SvnSslServerTrustEventArgs e)
         {
             e.Cancel = false;
         };
         client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(SVNUser, SVNPassword);
         client.CheckOut(new SvnUriTarget(source), target);
     }
 }
Exemple #35
0
 static public void Checkout(Uri fromUri, string localPath, SvnDepth depth)
 {
     using (SvnClient svnClient = new SvnClient())
     {
         try
         {
             SvnCheckOutArgs args = new SvnCheckOutArgs();
             args.Depth = depth;
             svnClient.CheckOut(fromUri, localPath, args);
         }
         catch (Exception ex)
         {
             LogMessage(ex.Message);
         }
     }
 }
Exemple #36
0
        public override void Checkout(string url, FilePath path, Revision rev, bool recurse, IProgressMonitor monitor)
        {
            var args = new SvnCheckOutArgs();

            BindMonitor(monitor);
            args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Empty;
            lock (client) {
                try {
                    client.CheckOut(new SvnUriTarget(url, GetRevision(rev)), path);
                } catch (SvnOperationCanceledException) {
                    if (Directory.Exists(path.ParentDirectory))
                    {
                        FileService.DeleteDirectory(path.ParentDirectory);
                    }
                }
            }
        }
Exemple #37
0
 public void GetProject()
 {
     if (mClient == null)
     {
         Init();
     }
     try
     {
         mClient.CheckOut(new Uri(mSourceConnectionDetails.SourceURL +
                                  mSourceConnectionDetails.GingerSolutionName + @"/SharedRepository"),
                          mSolutionFullLocalPath + @"/SharedRepository", out mOperationResult);
     }
     catch (Exception ex)
     {
         mClient = null;
         throw ex;
     }
 }
        protected override void ExecuteSVNTask(SvnClient client)
        {
            if (Dir.Exists && !IsEmpty(Dir))
            {
                throw new BuildException(string.Format(Resources.SVNCheckoutEmptyDirectory, Dir.FullName), Location);
            }

            Log(Level.Info, Resources.SVNCheckingOut, Url, Dir.FullName);
            SvnCheckOutArgs args = new SvnCheckOutArgs();
            args.ThrowOnError = true;
            args.Depth = SvnDepth.Infinity;
            args.Revision = SvnRevision.Head;
            SvnUpdateResult result;

            bool conflictedFiles = false;
            client.Conflict += delegate(object sender, SvnConflictEventArgs conflictArgs)
                                    {
                                        conflictedFiles = true;
                                        Log(Level.Warning, string.Concat(@"Conflicted: ", conflictArgs.Path));
                                    };

            client.Notify += delegate(object sender, SvnNotifyEventArgs notifyArgs)
                                    {
                                        Log(Level.Info, string.Concat(notifyArgs.Action, ": ", notifyArgs.Path));
                                    };

            client.CheckOut(SvnUriTarget.FromUri(Url), Dir.FullName, args, out result);

            if (conflictedFiles)
            {
                throw new BuildException(string.Format(Resources.SVNConflict, Dir.FullName));
            }

            if (result != null)
            {
                Log(Level.Info, Resources.SVNCheckedOut, Dir.FullName, result.Revision);
            }
        }
        /// <summary>
        /// Actual method to be executed for the implementing task
        /// </summary>
        /// <param name="client">The instance of the SVN client</param>
        /// <returns></returns>
        public override bool ExecuteCommand(SvnClient client)
        {
            SvnUriTarget uriTarget = new SvnUriTarget(RepositoryUrl);
            SvnCheckOutArgs checkOutArgs = new SvnCheckOutArgs();
            checkOutArgs.Depth = GetDepth();
            checkOutArgs.IgnoreExternals = IgnoreExternals;
            checkOutArgs.Revision = RevisionParser.SafeParse(Revision);

            SvnUpdateResult result;

            bool success = client.CheckOut(uriTarget, RepositoryPath, checkOutArgs, out result);

            if (result.HasRevision)
            {
                CheckedRevision = result.Revision;
                Log.LogMessage(MessageImportance.Normal, "Checked revision: {0}", CheckedRevision);
            }
            if (result.HasResultMap)
            {
                ReadResults(result);
            }

            return success;
        }
Exemple #40
0
        private static void Main(string[] args)
        {
            //SvnUpdateResult provides info about what happened during a checkout

            //we will use this to tell CheckOut() which revision to fetch

            //SvnCheckoutArgs wraps all of the options for the 'svn checkout' function
            SvnCheckOutArgs arguments = new SvnCheckOutArgs();
            bool tagOk = false;
            string tag = string.Empty;
            while (!tagOk)
            {
                Console.WriteLine("Tag: ");
                tag = Console.ReadLine();
                Regex twoDotPattern = new Regex("[0-9]*[.][0-9]*[.][0-9]*");
                if (string.IsNullOrEmpty(tag))
                {
                    Console.WriteLine("Tag vuoto.");
                }
                else
                {
                    if (!twoDotPattern.IsMatch(tag))
                    {
                        Console.WriteLine("Tag non corretto.");
                    }
                    else
                    {
                        tagOk = true;
                    }
                }
            }
            string reposUri = string.Format(ConfigurationManager.AppSettings["ReposUri"], tag);
            string defaultPath = ConfigurationManager.AppSettings["DefaultPath"];

            bool pathOk = false;
            string localPath = string.Empty;
            while (!pathOk)
            {
                try
                {
                    Console.WriteLine("Local path to checkout (default {0}): ", defaultPath);
                    string startingPath = Console.ReadLine();
                    if (string.IsNullOrEmpty(startingPath))
                    {
                        startingPath = defaultPath;
                    }
                    localPath = Path.Combine(startingPath, tag);

                    //Verifico se la dir è vuota
                    if(Directory.Exists(localPath))
                    {
                        string[] fileSystemEntries = Directory.GetFileSystemEntries(localPath);
                        if (fileSystemEntries.Length > 0)
                        {
                            throw new Exception("La directory non è vuota!");
                        }
                    }
                    pathOk = true;

                }
                catch (Exception e)
                {
                    Console.WriteLine("Errore: {0}", e.Message);
                    pathOk = false;
                }
            }

            Console.WriteLine("TAG: " + tag);
            Console.WriteLine("LOCAL PATH: " + localPath);
            Console.WriteLine("Repos URI: " + reposUri);

            Console.WriteLine("Prosegui? (Y/N)");
            if (Console.ReadLine().ToUpper() == "Y")
            {
                using (SvnClient client = new SvnClient())
                    try
                    {
                        //client.Processing +=new EventHandler<SvnProcessingEventArgs>(client_Processing);
                        //client.Committing +=new EventHandler<SvnCommittingEventArgs>(client_Committing);
                        //client.Progress += new EventHandler<SvnProgressEventArgs>(ClientProgress);
                        //SvnUriTarget is a wrapper class for SVN repository URIs
                        SvnUriTarget target = new SvnUriTarget(reposUri);
                        SvnUpdateResult result;
                        client.CheckOut(target, localPath, arguments, out result);
                        //client.Update(localPath, out result);
                        Console.WriteLine("OK: " + result);

                    }
                    catch (SvnException se)
                    {
                        Console.WriteLine(se.Message);
                        throw se;
                    }
                    catch (UriFormatException ufe)
                    {
                        Console.WriteLine(ufe.Message);
                        throw ufe;
                    }

                Console.WriteLine("Vuoi copiare i file di deploy sui server di produzione? (Y/N)");
                if (Console.ReadLine().ToUpper() == "Y")
                {
                    //Verifica dell'esistenza dei file di configurazione
                    string configurationFilesPath = Path.Combine(localPath, @"Build\ProductionConfigurations");
                    bool confOk = false;

                    string webDPCList = string.Empty;
                    while (!confOk)
                    {
                        try
                        {
                            Console.WriteLine("Elenco dei DPC separati da vigola: ");
                            webDPCList = Console.ReadLine();
                            foreach (string webDPCName in webDPCList.Split(','))
                            {
                                if (!File.Exists(Path.Combine(configurationFilesPath, webDPCName + ".xml")))
                                {
                                    throw new Exception(string.Format("Configurazione per il DPC {0} non trovata", webDPCName));
                                }
                            }
                            confOk = true;
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                            confOk = false;
                        }
                    }

                    try
                    {
                        Executor executorDeploy = new Executor();
                        executorDeploy.WorkingDirectory = localPath + @"\Build";
                        executorDeploy.FileName = String.Format(string.Format(@"{0}\Build\nant\bin\NAnt.exe", localPath));
                        executorDeploy.Arguments = "CopyFilesOnServerDeploy -D:WebDPCList=" + webDPCList;
                        executorDeploy.ErrorMatchString = "BUILD FAILED";
                        executorDeploy.Exec();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }

            Console.ReadLine();
        }
Exemple #41
0
        /// <summary>
        /// While the server isn't up to date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void doSvnUpdate(object sender, DoWorkEventArgs e)
        {
            client = new SvnClient();
            client.Notify += onSvnNotify;
            client.Authentication.Clear();
            client.Authentication.DefaultCredentials = null;

            System.Console.Out.WriteLine(client.GetUriFromWorkingCopy(System.IO.Directory.GetCurrentDirectory()));

            Uri rep = client.GetUriFromWorkingCopy(System.IO.Directory.GetCurrentDirectory());
            Uri rel = new Uri("http://subversion.assembla.com/svn/skyrimonlineupdate/");

            if (rep == null || rep != rel)
            {
                SvnDelete.findSvnDirectories(System.IO.Directory.GetCurrentDirectory());
                exploreDirectory(rel);

                download.Maximum = iCount;
                updating = true;

                SvnCheckOutArgs args = new SvnCheckOutArgs();
                args.AllowObstructions = true;

                if (client.CheckOut(rel, System.IO.Directory.GetCurrentDirectory(), args, out mResult))
                {
                    updated = true;
                }

            }
            else
            {
                downloadprogress.Text = "Building update list, please be patient...";

                updating = true;
                SvnStatusArgs sa = new SvnStatusArgs();
                sa.RetrieveRemoteStatus = true;

                Collection<SvnStatusEventArgs> r;
                client.GetStatus(System.IO.Directory.GetCurrentDirectory(), sa, out r);

                foreach (SvnStatusEventArgs i in r)
                {
                    client.Revert(i.FullPath);

                    if (i.IsRemoteUpdated)
                        iCount++;
                }

                download.Maximum = iCount;
                SvnUpdateArgs args = new SvnUpdateArgs();
                args.AllowObstructions = true;

                if (client.Update(System.IO.Directory.GetCurrentDirectory(), args))
                {
                    updated = true;
                }
                else
                {
                    Application.Exit();
                }
            }
        }
Exemple #42
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string localProdDirectoryRootedPath = @"C:\Code\PROD";
            string repositorySourceDirectoryUri = @"https://github.com/CosimoDeMedici/Duomo/trunk/Source"; // NOTE, http:// requires final '/' whereas svn:// does not.
            int repositorySourceDirectoryUriLength = repositorySourceDirectoryUri.Length;

            // TODO, will need to ensure no duplicate repository solution URIs.
            Dictionary<string, int> repositorySolutionUrisAndRevisions = new Dictionary<string, int>();
            repositorySolutionUrisAndRevisions.Add(@"https://github.com/CosimoDeMedici/Duomo/trunk/Source/Common/Applications/Gunther/Duomo.Common.Gunther.sln", 17);

            // Ensure that all repository solution URIs are in the source directory.
            Dictionary<string, int> repositorySolutionRelativeUrisAndRevisions = new Dictionary<string, int>();
            foreach (string curUri in repositorySolutionUrisAndRevisions.Keys)
            {
                if (curUri.Substring(0, repositorySourceDirectoryUriLength) == repositorySourceDirectoryUri)
                {
                    string solutionRelativeUri = curUri.Substring(repositorySourceDirectoryUriLength);
                    repositorySolutionRelativeUrisAndRevisions.Add(solutionRelativeUri, repositorySolutionUrisAndRevisions[curUri]);
                }
                else
                {
                    throw new ApplicationException(String.Format("Repository solution URI '{0}' was not within the repositoryl source directory URI '{1}'.", curUri, repositorySourceDirectoryUri));
                }
            }

            // Checkout (the checkout command will update if the directory already exists) the Lib directory. This assumes there is a 'Lib' directory as a sibling to the main 'Source' directory.
            string libFolderName = @"Lib";
            string localLibDirectoryRootedPath = Path.Combine(localProdDirectoryRootedPath, libFolderName);

            Uri uri = new Uri(repositorySourceDirectoryUri);
            string repositorySourceParentDirectoryUri = uri.GetParentUriString();
            uri = new Uri(repositorySourceParentDirectoryUri);
            string repositoryLibDirectoryUri = uri.AppendSegment(libFolderName);

            using (SvnClient client = new SvnClient())
            {
                SvnUriTarget target = new SvnUriTarget(repositoryLibDirectoryUri);
                client.CheckOut(new SvnUriTarget(repositoryLibDirectoryUri), localLibDirectoryRootedPath);
            }

            // For each solution, check out the solution's directory to the proper local path.
            WshShell wshShell = new WshShellClass(); // For creating a short-cut to the solution.
            foreach (string curRelativeUri in repositorySolutionRelativeUrisAndRevisions.Keys)
            {
                // Check out the solution.
                string curRepoRootedUri = repositorySourceDirectoryUri + curRelativeUri;
                Uri curRepoUri = new Uri(curRepoRootedUri);

                string solutionFileName = curRepoUri.GetLeaf();
                string solutionName = solutionFileName.Substring(0, solutionFileName.Length - 4);

                string localFolderName = Path.Combine(localProdDirectoryRootedPath, solutionName);
                if (!Directory.Exists(localFolderName))
                {
                    Directory.CreateDirectory(localFolderName);
                }

                string repoSolutionFolder = curRepoUri.GetParentUriString();
                string localSolutionFileRootedPath = localFolderName + curRelativeUri;
                FileInfo fInfo = new FileInfo(localSolutionFileRootedPath);
                string localSolutionDirectoryRootedPath = fInfo.DirectoryName;

                using (SvnClient client = new SvnClient())
                {
                    client.CheckOut(new SvnUriTarget(repoSolutionFolder), localSolutionDirectoryRootedPath);
                }

                // Create a short-cut to the solution file and place it in the local folder for the solution.
                string shortCutFileName = String.Format("{0} - Shortcut.lnk", solutionFileName);
                string shortCutFileRootedPath = Path.Combine(localFolderName, shortCutFileName);
                if (!System.IO.File.Exists(shortCutFileRootedPath))
                {
                    IWshShortcut shortCut = (IWshShortcut)wshShell.CreateShortcut(shortCutFileRootedPath);
                    shortCut.TargetPath = localSolutionFileRootedPath;
                    shortCut.Save();
                }

                // Now get the list of relative project paths by parsing the solution file.
                List<string> solutionFileLines = TextFileSerializer.DeserializeFromRootedPath(localSolutionFileRootedPath);

                List<string> projectLines = new List<string>();
                string projectSignifier = @"Project";
                foreach (string line in solutionFileLines)
                {
                    if (line.Length >= projectSignifier.Length && projectSignifier == line.Substring(0, projectSignifier.Length))
                    {
                        projectLines.Add(line);
                    }
                }

                List<string> relativeFilePaths = new List<string>();
                string[] separators = new string[] { "=", "," };
                foreach (string line in projectLines)
                {
                    string[] tokens = line.Split(separators, StringSplitOptions.None);
                    string relativePath = tokens[2].Trim().Trim('"');

                    if (@".." == relativePath.Substring(0, 2)) // Otherwise it's a subdirectory of the main solution directory, which has already been checked out.
                    {
                        relativeFilePaths.Add(relativePath);
                    }
                }

                // Now check out the folders containing each of the relative projects to their appropriate relative local paths.
                foreach (string relativeFilePath in relativeFilePaths)
                {
                    string relativeOtherProjectPath = Path.Combine(localSolutionDirectoryRootedPath, relativeFilePath);
                    string localOtherProjectRootedFilePath = Path.GetFullPath(relativeOtherProjectPath);
                    FileInfo localOtherProjectFileInfo = new FileInfo(localOtherProjectRootedFilePath);
                    string localOtherProjectDirectoryRootedPath = localOtherProjectFileInfo.DirectoryName;

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

                    Uri repoOtherProjectUri = new Uri(repoSolutionFolder + relativeFilePath);
                    string repoOtherProjectFolderUri = repoOtherProjectUri.GetParentUriString();

                    using (SvnClient client = new SvnClient())
                    {
                        client.CheckOut(new SvnUriTarget(repoOtherProjectFolderUri), localOtherProjectDirectoryRootedPath);
                    }
                }
            }
        }
Exemple #43
0
        public void Log_LogFromFile()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri repos = sbox.CreateRepository(SandBoxRepository.MergeScenario);

            string dir = sbox.Wc;

            using (SvnClient client = new SvnClient())
            {
                client.CheckOut(new Uri(repos, "trunk/"), dir);

                int n = 0;
                client.Log(Path.Combine(dir, "index.html"),
                    delegate(object sender, SvnLogEventArgs e)
                    {
                        switch (n++)
                        {
                            case 0:
                                Assert.That(e.LogMessage, Is.EqualTo("Merge branch b - product roadmap and update about page"));
                                break;
                            case 1:
                                Assert.That(e.LogMessage, Is.EqualTo("Merge branch a.  Added medium product"));
                                break;
                            case 2:
                                Assert.That(e.LogMessage, Is.EqualTo("Create initial product structure"));
                                break;
                        }
                    });
                Assert.That(n, Is.EqualTo(3));

            }
        }
Exemple #44
0
 private async void Checkout(string url) {
     var branchName = url.Split('/').Last();
     var checkoutPath = GetDansBranchPath(branchName);
     var svnClient = new SvnClient();
     AppendLog("Checking out from SVN...");
     // This is an async operator, it makes sure Checkout() runs in background without freezing the whole application
     await Task.Run(() => { svnClient.CheckOut(new SvnUriTarget(url), checkoutPath); });
     AppendLog("Complete!");
 }
Exemple #45
0
 public static void downloadSVNFromFile(string file)
 {
     var files = File.ReadAllText(file).Split('\n');
     using (SvnClient client = new SvnClient())
     {
         foreach (string f in files)
         {
             Console.Out.WriteLine(f + " started.");
             try
             {
                 string[] fparts = f.Replace("\r", "").Split(',');
                 client.CheckOut(new Uri(fparts[0]), Directory.GetCurrentDirectory() + "\\missed\\" + fparts[1]);
                 Console.Out.WriteLine(f + " completed.");
             }
             catch { Console.Out.WriteLine(f + " failed."); }
         }
     }
 }
Exemple #46
0
 /// <summary>
 /// Gets the SVN Project
 /// </summary>
 /// <param name="Projects"></param>
 public static void checkoutCode(List<project> Projects)
 {
     using (SvnClient client = new SvnClient())
     {
         foreach (project p in Projects)
             // Checkout the code to the specified directory
             try { Directory.GetDirectories(Directory.GetCurrentDirectory() + "\\" + p.Name); }
             catch{
                 try
                 {
                     client.CheckOut(new Uri(p.SVN), Directory.GetCurrentDirectory() + "\\" + p.Name);
                 }
                 catch {Console.Out.WriteLine("Couldn't write: " + p.Name); }
             }
     }
 }
        public static string Update(string url, Log log, string directory)
        {
            if (string.IsNullOrWhiteSpace(url))
            {
                Utility.Log(LogStatus.Skipped, "Updater", string.Format("No Url specified - {0}", url), log);
            }
            else
            {
                try
                {
                    var dir = Path.Combine(directory, url.GetHashCode().ToString("X"));
                    using (var client = new SvnClient())
                    {
                        var cleanUp = false;
                        client.Conflict +=
                            delegate(object sender, SvnConflictEventArgs eventArgs)
                            {
                                eventArgs.Choice = SvnAccept.TheirsFull;
                            };
                        client.Status(
                            dir, new SvnStatusArgs { ThrowOnError = false },
                            delegate(object sender, SvnStatusEventArgs args)
                            {
                                if (args.Wedged)
                                {
                                    cleanUp = true;
                                }
                            });

                        if (cleanUp)
                        {
                            client.CleanUp(dir);
                        }

                        try
                        {
                            if (Directory.Exists(dir))
                            {
                                SvnInfoEventArgs remoteVersion;
                                var b1 = client.GetInfo(new Uri(url), out remoteVersion);

                                SvnInfoEventArgs localVersion;
                                var b2 = client.GetInfo(dir, out localVersion);

                                if (b1 && b2 && remoteVersion.Revision == localVersion.Revision)
                                {
                                    Utility.Log(
                                        LogStatus.Ok, "Updater", string.Format("Update not needed - {0}", url), log);
                                    return dir;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Utility.Log(LogStatus.Error, "Updater", string.Format("{0} - {1}", ex, url), log);
                        }

                        client.CheckOut(new Uri(url), dir);
                        client.Update(dir);
                        Utility.Log(LogStatus.Ok, "Updater", string.Format("Updated - {0}", url), log);
                    }
                    return dir;
                }
                catch (SvnException ex)
                {
                    Utility.Log(LogStatus.Error, "Updater", string.Format("{0} - {1}", ex.RootCause, url), log);
                }
                catch (Exception ex)
                {
                    Utility.Log(LogStatus.Error, "Updater", string.Format("{0} - {1}", ex.Message, url), log);
                }
            }

            return string.Empty;
        }
 private void AddButtonClick(object sender, EventArgs e)
 {
     // Get the url to the repository
     string answer;
     if (Environment.ExpandEnvironmentVariables("path").IndexOf("git") != 0)
     {
         answer = Microsoft.VisualBasic.Interaction.InputBox(Resources.addRepoMessageGitEnabled, Resources.addRepoHeader, Resources.addRepoDefaultValue);
     }
     else
     {
         answer = Microsoft.VisualBasic.Interaction.InputBox(Resources.addRepoMessageGitDisabled, Resources.addRepoHeader, Resources.addRepoDefaultValue);
     }
     if (answer == string.Empty)
     {
         return;
     }
     if (answer == "url")
     {
         MessageBox.Show(@"You must give the url", @"No url given");
         return;
     }
     // Check if it is a git repository
     if (answer.LastIndexOf("git") != 0)
     {
         var dir = Microsoft.VisualBasic.Interaction.InputBox(Resources.repoFolderMessage, Resources.repoFolderHeader);
         Process.Start("git", string.Format("clone {0} {1}", answer, _installDir + "\\" + dir)).WaitForExit();
     }
         // ...else checkout a SVN repository
     else
     {
         var url = new Uri(answer);
         using (var svnClient = new SvnClient())
         {
             var dir = Microsoft.VisualBasic.Interaction.InputBox(Resources.repoFolderMessage, Resources.repoFolderHeader);
             svnClient.CheckOut(url, _installDir + "\\" + dir);
         }
     }
     UpdateStuff();
 }
		public static void Checkout(string repoDir, string wcDir)
		{
			if (Directory.Exists(wcDir))
			{
				Directory.Delete(wcDir, true);
			}

			using (var svn = new SvnClient())
			{
				var repoUri = new Uri("file:///" + repoDir.Replace('\\', '/'));

				svn.CheckOut(new SvnUriTarget(repoUri), wcDir);

				foreach (var fse in Directory.EnumerateFileSystemEntries(wcDir))
				{
					if (Path.GetFileName(fse).ToLowerInvariant() == ".svn")
						continue;

					svn.Add(fse, SvnDepth.Infinity);
				}

				svn.Commit(wcDir, new SvnCommitArgs { LogMessage = "PreCreate revision" });
			}
		}