示例#1
0
        public bool Exec(InitCommandOptions options)
        {
            bool ok;

            Toolchain.RequirePackDm(true);
            Toolchain.RequireSubversion(true);

            var pack = new Library.PackDm.PackDm();

            pack.PackConf = options.ConfFile.Text;
            pack.PackInfo = options.PackFile.Text;

            var svn = new Svn();

            ok = pack.Init();
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            ok = svn.Ignore("packages");
            if (!ok)
            {
                return(Prompt.PrintCannotContinue());
            }

            return(true);
        }
示例#2
0
        //
        // Gets the logs for a given set of revisions
        //
        public static Log[] GetRevisionLogs(string svnPath, string[] revisions, Logging logger, LogRetrieved logRetrieved)
        {
            // We need to track properties throughout the loop
            Object     writeLock = new Object();
            List <Log> logs      = new List <Log>();
            int        logCount  = 0;

            // Spin through all the revisions requested
            ParallelLoopResult result = Parallel.ForEach(revisions, new ParallelOptions {
                MaxDegreeOfParallelism = 16
            }, (thisRevision, loopState) =>
            {
                // Pull out the log
                string logOutput = Svn.GetLog(svnPath, thisRevision, true, logger);
                if (logOutput == null)
                {
                    loopState.Stop();
                }

                // Get the log we found
                logger.Log("* Recieved log\n{0}\n", logOutput);

                // Continue?
                if (loopState.IsStopped == false)
                {
                    // Read in the log input
                    Log[] individualLogs = ParseLogOutput(logOutput, logger);
                    if (individualLogs == null)
                    {
                        loopState.Stop();
                    }

                    // How many did we get
                    logger.Log("* Identified {0} logs", individualLogs.Length);

                    // Continue?
                    if (loopState.IsStopped == false)
                    {
                        // Lock our writes
                        lock (writeLock)
                        {
                            // Add and update
                            logs.AddRange(individualLogs);
                            logRetrieved(++logCount);
                        }
                    }
                }
            });

            // If we didn't succeed, bail
            if (result.IsCompleted == false)
            {
                logger.Log("* The log generation loop did not complete successfully");
                return(null);
            }

            // Return all our logs
            logger.Log("* In total we found {0} logs", logs.Count);
            return(logs.ToArray());
        }
        //
        // Returns a revision list for a given path
        //
        private static Revisions Request(string path, Logging logger)
        {
            // Get the list of revisions we want to look at
            string revisonList = GetRevisionList(path, logger);

            if (revisonList == null)
            {
                logger.Log("No revisions were provided");
                return(null);
            }

            // Parse the list of revisions we're interested in
            string[] revisionsToReview = ParseRevisionList(revisonList, logger);
            if (revisionsToReview == null)
            {
                return(null);
            }

            // Get the URL of this repository
            string url = Svn.GetBranch(path);

            logger.Log("Using SVN URL '{0}', url");

            // Return our results
            return(new Revisions(path, url, revisionsToReview));
        }
示例#4
0
        public ActionResult GetSvnLog(SvnDetails svnDetails, string TrunckPath, string BranchPath)
        {
            svnDetails.BranchPath = BranchPath;
            svnDetails.TrunckPath = TrunckPath;

            var Log = new Svn(mSvnExecutablePath, svnDetails.TrunckPath, svnDetails.BranchPath, svnDetails.SvnUser, svnDetails.SvnPassword);
            var AllChanges = new List<Svn.LogEntry>();

            try
            {
                AllChanges = Log.GetChanges();
            }
            catch (SvnProcess.SvnException ex)
            {
                foreach (var error in ex.SvnError)
                    ModelState.AddModelError("", error);
                ModelState.AddModelError("", ex.Command);
            }

            //Add each log to the class we are going to pass between sessions so we can keep a list of all the posibile revisions (dont want to rely on the client supplying it)
            svnDetails.Changes.Clear();
            foreach (var Change in AllChanges)
                svnDetails.Changes.Add(Change);

            return PartialView("ViewUserControl", svnDetails);
        }
示例#5
0
        public Ret <ProjectHeader> LoadProjectHeader(string folder = ".")
        {
            try
            {
                bool ok;

                var svn = new Svn();
                svn.User = SvnUser ?? Svn.DefaultUser;
                svn.Pass = SvnPass ?? Svn.DefaultPass;
                ok       = svn.Fill();
                if (!ok)
                {
                    Ret.Fail();
                }

                var pack = new PackDm.PackDm();
                pack.PackConf = PackConf;
                pack.PackInfo = PackInfo;
                ok            = pack.Fill();
                if (!ok)
                {
                    Ret.Fail();
                }

                var header = LoadProjectHeader(svn, pack);
                return(header);
            }
            catch (Exception ex)
            {
                return(ex);
            }
        }
示例#6
0
 protected override void ExecuteTask()
 {
     try
     {
         try
         {
             AprPool          p   = Svn.PoolCreate();
             SvnClientContext ctx = SvnClientContext.Create(p);
             ctx.Config  = SvnConfig.GetConfig(p);
             this.Client = new SvnClient(ctx, p);
             this.Client.AddSimpleProvider();
             this.Client.AddUsernameProvider();
             this.Client.AddSslServerTrustFileProvider();
             this.Client.AddSslClientCertFileProvider();
             this.Client.AddSslClientCertPwFileProvider();
             this.Client.OpenAuth();
             this.Client.Status2(this.Directory, new SvnRevision(Svn.Revision.Head), new SvnWcStatus2.Func(this.Clean), IntPtr.Zero, this.Recurse, true, false, false, false);
         }
         catch (Exception ex)
         {
             throw new BuildException(ex.Message, this.Location, ex);
         }
     }
     finally
     {
         if (this.Client != null)
         {
             this.Client.Pool.Destroy();
         }
     }
 }
        //
        // Finds the root path of the review
        //
        private static string FindReviewRootPath(string[] reviewContent, Logging logger)
        {
            // Spin through and get the root
            string rootPath = string.Empty;

            foreach (string thisEntry in reviewContent)
            {
                // Get the root of this file
                string thisRoot = Svn.GetRoot(thisEntry);
                if (thisRoot == null)
                {
                    continue;
                }

                // We have a root, send it back
                logger.Log("Calculated root path is '{0}'", thisRoot);
                return(thisRoot);
            }

            // If we got here, no root
            logger.Log("Unable to calculate the root path for the review - is SVN installed");
            MessageBox.Show("Unable to find a working SVN root directly, are the SVN command line tools installed?", "Unable to raise review", MessageBoxButtons.OK, MessageBoxIcon.Error);

            // Return nothing
            return(null);
        }
示例#8
0
        public override Annotation[] GetAnnotations(FilePath repositoryPath)
        {
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, repositoryPath, SvnRevision.First, SvnRevision.Base));
            Annotation        nextRev     = new Annotation(GettextCatalog.GetString("working copy"), "<uncommitted>", DateTime.MinValue);
            var baseDocument    = Mono.TextEditor.TextDocument.CreateImmutableDocument(GetBaseText(repositoryPath));
            var workingDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(File.ReadAllText(repositoryPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            foreach (var hunk in baseDocument.Diff(workingDocument))
            {
                annotations.RemoveRange(hunk.RemoveStart - 1, hunk.Removed);
                for (int i = 0; i < hunk.Inserted; ++i)
                {
                    if (hunk.InsertStart + i >= annotations.Count)
                    {
                        annotations.Add(nextRev);
                    }
                    else
                    {
                        annotations.Insert(hunk.InsertStart - 1, nextRev);
                    }
                }
            }

            return(annotations.ToArray());
        }
示例#9
0
        public void PopulateFromFullySpecifiedXml()
        {
            string xml = @"
<svn>
	<executable>c:\svn\svn.exe</executable>
	<trunkUrl>svn://myserver/mypath</trunkUrl>
	<timeout>5</timeout>
	<workingDirectory>c:\dev\src</workingDirectory>
	<username>user</username>
	<password>password</password>
	<tagOnSuccess>true</tagOnSuccess>
	<tagWorkingCopy>true</tagWorkingCopy>
	<tagBaseUrl>svn://myserver/mypath/tags</tagBaseUrl>
	<autoGetSource>true</autoGetSource>
	<checkExternals>true</checkExternals>
</svn>";

            svn = (Svn)NetReflector.Read(xml);
            Assert.AreEqual(@"c:\svn\svn.exe", svn.Executable);
            Assert.AreEqual("svn://myserver/mypath", svn.TrunkUrl);
            Assert.AreEqual(new Timeout(5), svn.Timeout);
            Assert.AreEqual(@"c:\dev\src", svn.WorkingDirectory);
            Assert.AreEqual("user", svn.Username);
            Assert.AreEqual("password", svn.Password.PrivateValue);
            Assert.AreEqual(true, svn.TagOnSuccess);
            Assert.AreEqual(true, svn.TagWorkingCopy);
            Assert.AreEqual(true, svn.AutoGetSource);
            Assert.AreEqual(true, svn.CheckExternals);
            Assert.AreEqual("svn://myserver/mypath/tags", svn.TagBaseUrl);
        }
        //
        // Create a review if the content only contains a single patch file
        //
        private static Content CreatePatchOnlyReview(string[] reviewContent, Logging logger)
        {
            // If we have more than one file, it can't be a patch file
            if (reviewContent.Length != 1)
            {
                logger.Log("Review content is >1 so it cannot be a patch file");
                return(null);
            }

            // Get the file, is it a patch or diff file?
            string fileToCheck = reviewContent[0];

            if (IsFilePatch(fileToCheck) == false)
            {
                logger.Log("Given path to review is not a patch file");
                return(null);
            }

            // It is a patch file, now we need to make sure it's not part of the
            // repository because otherwse we'd need to review that!
            if (Svn.IsPathTracked(fileToCheck) == true)
            {
                logger.Log("Given path is a patch file but it is under source control");
                return(null);
            }

            // This is a patch file that has been selected specifically to review the
            // content and is not part of the repository
            return(new Content(Source.Patch, fileToCheck, null));
        }
示例#11
0
        public ActionResult GetSvnLog(SvnDetails svnDetails, string TrunckPath, string BranchPath)
        {
            svnDetails.BranchPath = BranchPath;
            svnDetails.TrunckPath = TrunckPath;

            var Log        = new Svn(mSvnExecutablePath, svnDetails.TrunckPath, svnDetails.BranchPath, svnDetails.SvnUser, svnDetails.SvnPassword);
            var AllChanges = new List <Svn.LogEntry>();

            try
            {
                AllChanges = Log.GetChanges();
            }
            catch (SvnProcess.SvnException ex)
            {
                foreach (var error in ex.SvnError)
                {
                    ModelState.AddModelError("", error);
                }
                ModelState.AddModelError("", ex.Command);
            }

            //Add each log to the class we are going to pass between sessions so we can keep a list of all the posibile revisions (dont want to rely on the client supplying it)
            svnDetails.Changes.Clear();
            foreach (var Change in AllChanges)
            {
                svnDetails.Changes.Add(Change);
            }

            return(PartialView("ViewUserControl", svnDetails));
        }
示例#12
0
        public override async Task <Annotation []> GetAnnotationsAsync(FilePath repositoryPath, Revision since, CancellationToken cancellationToken)
        {
            SvnRevision       sinceRev    = since != null ? (SvnRevision)since : null;
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, repositoryPath, SvnRevision.First, sinceRev ?? SvnRevision.Base));
            Annotation        nextRev     = new Annotation(null, GettextCatalog.GetString("<uncommitted>"), DateTime.MinValue, null, GettextCatalog.GetString("working copy"));
            var baseDocument    = Mono.TextEditor.TextDocument.CreateImmutableDocument(await GetBaseTextAsync(repositoryPath, cancellationToken).ConfigureAwait(false));
            var workingDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(File.ReadAllText(repositoryPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            if (sinceRev == null)
            {
                foreach (var hunk in baseDocument.Diff(workingDocument, includeEol: false))
                {
                    annotations.RemoveRange(hunk.RemoveStart - 1, hunk.Removed);
                    for (int i = 0; i < hunk.Inserted; ++i)
                    {
                        if (hunk.InsertStart + i >= annotations.Count)
                        {
                            annotations.Add(nextRev);
                        }
                        else
                        {
                            annotations.Insert(hunk.InsertStart - 1, nextRev);
                        }
                    }
                }
            }

            return(annotations.ToArray());
        }
示例#13
0
        public void SpecifyFromMinimallySpecifiedXml()
        {
            string xml = @"<svn/>";

            svn = (Svn)NetReflector.Read(xml);
            Assert.AreEqual("svn", svn.Executable);
            Assert.AreEqual(false, svn.TagWorkingCopy);
        }
示例#14
0
        public void GetIgnoredFiles(String refID, String directoryName, bool recursive)
        {
            if (!this.Project.DataTypeReferences.Contains(refID))
            {
                throw new BuildException(String.Format("The refid {0} is not defined.", refID));
            }

            FileSet RefFileSet = (FileSet)this.Project.DataTypeReferences[refID];

            try
            {
                AprPool          p   = Svn.PoolCreate();
                SvnClientContext ctx = SvnClientContext.Create(p);
                ctx.Config  = SvnConfig.GetConfig(p);
                this.Client = new SvnClient(ctx, p);

                String AdminDir = ".svn";
                if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("SVN_ASP_DOT_NET_HACK")))
                {
                    AdminDir = "_svn";
                }

                this.Client.SetWcAdmDir(AdminDir);
                this.Client.AddSimpleProvider();
                this.Client.AddUsernameProvider();
                this.Client.AddSslServerTrustFileProvider();
                this.Client.AddSslClientCertFileProvider();
                this.Client.AddSslClientCertPwFileProvider();
                this.Client.OpenAuth();
                AprArray crapList = this.Client.PropList(directoryName, new SvnRevision(Svn.Revision.Working), recursive);
                crapList.ElementType = typeof(SvnClientPropListItem);
                SvnClientPropListItem[] props = new SvnClientPropListItem[crapList.Count];
                crapList.CopyTo(props, 0);

                foreach (SvnClientPropListItem property in props)
                {
                    foreach (AprHashEntry entry in property.PropHash)
                    {
                        if (entry.KeyAsString == "svn:ignore")
                        {
                            foreach (String ignored in new SvnString(entry.Value).Data.Value.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                string FullPath = Path.Combine(property.NodeName.ToString(), ignored);

                                RefFileSet.Includes.Add(FullPath);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (this.Client != null)
                {
                    this.Client.Pool.Destroy();
                }
            }
        }
示例#15
0
        //
        // Parses the command line options
        //
        public static Result ParseCommands(string fileList, bool injectPaths, Logging logger)
        {
            logger.Log(@"Parsing the file list command");

            // Get the file
            if (File.Exists(fileList) == false)
            {
                logger.Log(@"Unable to find the file list command file - {0}", fileList);
                return(null);
            }

            string[] fileContent = File.ReadAllLines(fileList);
            if (fileContent.Length == 0)
            {
                logger.Log(@"The given file list contains no content - {0}", fileList);
                return(null);
            }

            // Handle any debug options
            fileContent = HandleDebugRequest(fileContent, injectPaths);

            // Track all our content
            List <string> validPaths   = new List <string>();
            List <string> invalidPaths = new List <string>();

            // Check they all exist, and check they all all SVN repositories
            foreach (string thisPath in fileContent)
            {
                // Even a string?
                if (string.IsNullOrWhiteSpace(thisPath) == true)
                {
                    continue;
                }

                // Does it exist
                if (File.Exists(thisPath) == false && Directory.Exists(thisPath) == false)
                {
                    logger.Log(@"* Invalid path found in file list - {0}", thisPath);
                    invalidPaths.Add(thisPath);
                    continue;
                }

                // SVN path
                if (Svn.IsPathTracked(thisPath) == false)
                {
                    logger.Log(@"* Invalid path found in file list - {0}", thisPath);
                    invalidPaths.Add(thisPath);
                    continue;
                }

                // It's fine
                logger.Log(@"* Using - {0}", thisPath);
                validPaths.Add(thisPath);
            }

            // Return our paths
            return(new Result(validPaths.ToArray(), invalidPaths.ToArray()));
        }
示例#16
0
        protected override async Task OnMoveFileAsync(FilePath localSrcPath, FilePath localDestPath, bool force, ProgressMonitor monitor)
        {
            bool destIsVersioned = false;

            if (File.Exists(localDestPath))
            {
                if (string.Equals(localSrcPath, localDestPath, StringComparison.OrdinalIgnoreCase))
                {
                    Svn.Move(localSrcPath, localDestPath, true, monitor);
                    return;
                }
                throw new InvalidOperationException("Cannot move file. Destination file already exist.");
            }

            if (await IsVersionedAsync(localDestPath, monitor.CancellationToken))
            {
                // Revert to the original status
                await RevertAsync(localDestPath, false, monitor);

                if (File.Exists(localDestPath))
                {
                    File.Delete(localDestPath);
                }
                destIsVersioned = true;
            }

            VersionInfo srcInfo = await GetVersionInfoAsync(localSrcPath, VersionInfoQueryFlags.IgnoreCache);

            if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd))
            {
                // Subversion automatically detects the rename and moves the new file accordingly.
                if (!destIsVersioned)
                {
                    MakeDirVersioned(Path.GetDirectoryName(localDestPath), monitor);
                    Svn.Move(localSrcPath, localDestPath, force, monitor);
                }
                else
                {
                    await base.OnMoveFileAsync(localSrcPath, localDestPath, force, monitor);

                    Add(localDestPath, false, monitor);
                    await DeleteFileAsync(localSrcPath, force, monitor, keepLocal : false);
                }
            }
            else
            {
                if (!destIsVersioned && await IsVersionedAsync(localSrcPath, monitor.CancellationToken))
                {
                    MakeDirVersioned(Path.GetDirectoryName(localDestPath), monitor);
                    Svn.Move(localSrcPath, localDestPath, force, monitor);
                }
                else
                {
                    await base.OnMoveFileAsync(localSrcPath, localDestPath, force, monitor);
                }
            }
            ClearCachedVersionInfo(localSrcPath, localDestPath);
        }
        //
        // Rejects the files in the list that are not valid
        //
        private static string[] RejectInvalidFiles(string[] reviewContent, string rootPath, Logging logger)
        {
            // Create a list to keep track of rejected files
            List <string> rejectedFiles = new List <string>();

            // Check all the entries to review are valid
            reviewContent = reviewContent.Where(x =>
            {
                // Get the root path in which this repostory lives
                string thisRoot = Svn.GetRoot(x);

                // If we don't have a root it's not source controlled so bail
                if (thisRoot == null)
                {
                    rejectedFiles.Add(x);
                    return(false);
                }

                // If we're under the same root we're fine
                bool underSameRoot = rootPath.Equals(thisRoot);
                if (underSameRoot == false)
                {
                    rejectedFiles.Add(x);
                    return(false);
                }

                // Return that we should keep this file
                return(true);
            }).ToArray();

            // If we have any rejected files, let the user know
            if (rejectedFiles.Count != 0)
            {
                logger.Log("Some files will not be reviewed");

                StringBuilder errorMessage = new StringBuilder("Unable to include the following files for review\n");
                foreach (string thisError in rejectedFiles)
                {
                    string stringToShow = Paths.TruncateLongPath(thisError);
                    errorMessage.Append("- " + stringToShow + "\n");

                    logger.Log(" * {0}", thisError);
                }

                MessageBox.Show(errorMessage.ToString(), "Warning when raising review", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Do we have any files left?
            if (reviewContent.Length == 0)
            {
                MessageBox.Show("No content was found that could actually be reviewed", "Unable to raise review", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // Return the updated files
            return(reviewContent.Count() == 0 ? null : reviewContent);
        }
        public override DiffInfo GenerateDiff(FilePath baseLocalPath, VersionInfo versionInfo)
        {
            string diff = Svn.GetUnifiedDiff(versionInfo.LocalPath, false, false);

            if (!string.IsNullOrEmpty(diff))
            {
                return(GenerateUnifiedDiffInfo(diff, baseLocalPath, new FilePath[] { versionInfo.LocalPath }).FirstOrDefault());
            }
            return(null);
        }
示例#19
0
 protected void SetUp()
 {
     from = DateTime.Parse("2001-01-21 20:00:00Z");
     to   = DateTime.Parse("2001-01-21 20:30:50Z");
     CreateProcessExecutorMock(Svn.DefaultExecutable);
     mockHistoryParser = new DynamicMock(typeof(IHistoryParser));
     mockFileSystem    = new DynamicMock(typeof(IFileSystem));
     svn                  = new Svn((ProcessExecutor)mockProcessExecutor.MockInstance, (IHistoryParser)mockHistoryParser.MockInstance, (IFileSystem)mockFileSystem.MockInstance);
     svn.TrunkUrl         = "svn://myserver/mypath";
     svn.TagBaseUrl       = "svn://someserver/tags/foo";
     svn.WorkingDirectory = DefaultWorkingDirectory;
 }
示例#20
0
        protected override void OnMoveFile(FilePath localSrcPath, FilePath localDestPath, bool force, IProgressMonitor monitor)
        {
            bool destIsVersioned = false;

            if (File.Exists(localDestPath))
            {
                throw new InvalidOperationException("Cannot move file. Destination file already exist.");
            }

            if (IsVersioned(localDestPath))
            {
                // Revert to the original status
                Revert(localDestPath, false, monitor);
                if (File.Exists(localDestPath))
                {
                    File.Delete(localDestPath);
                }
                destIsVersioned = true;
            }

            VersionInfo srcInfo = GetVersionInfo(localSrcPath, VersionInfoQueryFlags.IgnoreCache);

            if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd))
            {
                // Subversion automatically detects the rename and moves the new file accordingly.
                if (!destIsVersioned)
                {
                    MakeDirVersioned(Path.GetDirectoryName(localDestPath), monitor);
                    Svn.Move(localSrcPath, localDestPath, force, monitor);
                }
                else
                {
                    base.OnMoveFile(localSrcPath, localDestPath, force, monitor);
                    if (!destIsVersioned)
                    {
                        Add(localDestPath, false, monitor);
                    }
                }
            }
            else
            {
                if (!destIsVersioned && IsVersioned(localSrcPath))
                {
                    MakeDirVersioned(Path.GetDirectoryName(localDestPath), monitor);
                    Svn.Move(localSrcPath, localDestPath, force, monitor);
                }
                else
                {
                    base.OnMoveFile(localSrcPath, localDestPath, force, monitor);
                }
            }
        }
示例#21
0
 public override void DeleteDirectories(FilePath[] paths, bool force, IProgressMonitor monitor)
 {
     foreach (string path in paths)
     {
         if (IsVersioned(path))
         {
             Svn.Delete(path, force, monitor);
         }
         else
         {
             Directory.Delete(path, true);
         }
     }
 }
示例#22
0
        public override void MoveFile(FilePath srcPath, FilePath destPath, bool force, IProgressMonitor monitor)
        {
            bool destIsVersioned = false;

            if (File.Exists(destPath))
            {
                throw new InvalidOperationException("Cannot move file. Destination file already exist.");
            }

            if (IsVersioned(destPath))
            {
                // Revert to the original status
                Revert(destPath, false, monitor);
                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }
                destIsVersioned = true;
            }

            VersionInfo srcInfo = GetVersionInfo(srcPath, false);

            if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd))
            {
                // If the file is scheduled to add, cancel it, move the file, and schedule to add again
                Revert(srcPath, false, monitor);
                if (!destIsVersioned)
                {
                    MakeDirVersioned(Path.GetDirectoryName(destPath), monitor);
                }
                base.MoveFile(srcPath, destPath, force, monitor);
                if (!destIsVersioned)
                {
                    Add(destPath, false, monitor);
                }
            }
            else
            {
                if (!destIsVersioned && IsVersioned(srcPath))
                {
                    MakeDirVersioned(Path.GetDirectoryName(destPath), monitor);
                    Svn.Move(srcPath, destPath, force, monitor);
                }
                else
                {
                    base.MoveFile(srcPath, destPath, force, monitor);
                }
            }
        }
示例#23
0
        public bool IsVersioned(string path)
        {
            this.QueryPath = path;
            try
            {
                try
                {
                    AprPool          p   = Svn.PoolCreate();
                    SvnClientContext ctx = SvnClientContext.Create(p);
                    ctx.Config  = SvnConfig.GetConfig(p);
                    this.Client = new SvnClient(ctx, p);

                    String AdminDir = ".svn";
                    if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("SVN_ASP_DOT_NET_HACK")))
                    {
                        AdminDir = "_svn";
                    }

                    this.Client.SetWcAdmDir(AdminDir);
                    this.Client.AddSimpleProvider();
                    this.Client.AddUsernameProvider();
                    this.Client.AddSslServerTrustFileProvider();
                    this.Client.AddSslClientCertFileProvider();
                    this.Client.AddSslClientCertPwFileProvider();
                    this.Client.OpenAuth();
                    this.Client.Status2(this.QueryPath, new SvnRevision(Svn.Revision.Head), new SvnWcStatus2.Func(this.Record), IntPtr.Zero, false, true, false, false, true);
                    return(this.IsVersionedReturnValue);
                }
                catch (SvnException SvnEx)
                {
                    if (SvnEx.AprErr == 155007)
                    {
                        return(false);
                    }
                    throw new BuildException(SvnEx.Message, SvnEx);
                }
                catch (Exception ex)
                {
                    throw new BuildException(ex.Message, ex);
                }
            }
            finally
            {
                this.Client.Pool.Destroy();
            }
        }
示例#24
0
        protected override async Task OnDeleteDirectoriesAsync(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal)
        {
            foreach (string path in localPaths)
            {
                if (!keepLocal)
                {
                    FileService.AssertCanDeleteDirectory(path, RootPath);
                }

                if (await IsVersionedAsync(path, monitor.CancellationToken).ConfigureAwait(false))
                {
                    string newPath = String.Empty;
                    if (keepLocal)
                    {
                        newPath = FileService.CreateTempDirectory();
                        FileService.CopyDirectory(path, newPath);
                    }
                    try {
                        Svn.Delete(path, force, monitor);
                    } finally {
                        if (keepLocal)
                        {
                            FileService.MoveDirectory(newPath, path);
                        }
                    }
                }
                else
                {
                    if (keepLocal)
                    {
                        foreach (var info in await GetDirectoryVersionInfoAsync(path, false, true, monitor.CancellationToken).ConfigureAwait(false))
                        {
                            if (info != null && info.HasLocalChange(VersionStatus.ScheduledAdd))
                            {
                                // Revert the add command
                                await RevertAsync(path, false, monitor).ConfigureAwait(false);
                            }
                        }
                    }
                    else
                    {
                        Directory.Delete(path, true);
                    }
                }
            }
        }
示例#25
0
        private static ProjectHeader LoadProjectHeader(Svn svn, PackDm.PackDm pack)
        {
            var header = new ProjectHeader
            {
                Group    = pack.Group,
                Artifact = pack.Artifact,
                Version  = pack.Version
            };

            if (header.Version.PreRelease == null)
            {
                header.Version.PreRelease = InferPreRelease();
            }

            header.Version.Revision = int.TryParse(svn.Revision, out int n) ? n : 0;

            return(header);
        }
示例#26
0
        private Svn CreateSvnSvc(ISvcRepository repo)
        {
            string repoPath = WorkspacePathProvider.SvnRepositoryPath(this.sync);
            var    user     = this.retriever.GetUser(repo.CheckoutUser.Id);

            string login = user.RepositoryCredentials.FirstOrDefault(c => c.RepositoryType == repo.Type)?.Login;

            if (login == null)
            {
                throw new InvalidOperationException($"User {repo.CheckoutUser.Name} does not have {repo.Type} credentials.");
            }

            string password = this.retriever.GetPassword(repo.CheckoutUser.Id, repo.Type);

            var svn = new Svn(this.sync, repo, repoPath, login, password, this.syncLogger);

            return(svn);
        }
示例#27
0
        protected override void ExecuteTask()
        {
            try
            {
                try
                {
                    AprPool          p   = Svn.PoolCreate();
                    SvnClientContext ctx = SvnClientContext.Create(p);
                    ctx.Config  = SvnConfig.GetConfig(p);
                    this.Client = new SvnClient(ctx, p);

                    String AdminDir = ".svn";
                    if (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("SVN_ASP_DOT_NET_HACK")))
                    {
                        AdminDir = "_svn";
                    }

                    this.Client.SetWcAdmDir(AdminDir);
                    this.Client.AddSimpleProvider();
                    this.Client.AddUsernameProvider();
                    this.Client.AddSslServerTrustFileProvider();
                    this.Client.AddSslClientCertFileProvider();
                    this.Client.AddSslClientCertPwFileProvider();
                    this.Client.OpenAuth();
                    this.Client.Status2(this.Directory, new SvnRevision(Svn.Revision.Head), new SvnWcStatus2.Func(this.Clean), IntPtr.Zero, this.Recurse, true, false, false, false);

                    if (this.DeleteIgnored)
                    {
                        this.DeleteIgnoredFiles();
                    }
                }
                catch (Exception ex)
                {
                    throw new BuildException(ex.Message, this.Location, ex);
                }
            }
            finally
            {
                if (this.Client != null)
                {
                    this.Client.Pool.Destroy();
                }
            }
        }
示例#28
0
        public override Annotation[] GetAnnotations(FilePath localPath)
        {
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, localPath, SvnRevision.First, SvnRevision.Base));
            Annotation        nextRev     = new Annotation(GettextCatalog.GetString("working copy"), "", DateTime.MinValue);
            var baseDocument    = new Mono.TextEditor.Document(File.ReadAllText(GetPathToBaseText(localPath)));
            var workingDocument = new Mono.TextEditor.Document(File.ReadAllText(localPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            foreach (var hunk in baseDocument.Diff(workingDocument))
            {
                annotations.RemoveRange(hunk.InsertStart, hunk.Inserted);
                for (int i = 0; i < hunk.Inserted; ++i)
                {
                    annotations.Insert(hunk.InsertStart, nextRev);
                }
            }

            return(annotations.ToArray());
        }
示例#29
0
 public override void DeleteFiles(FilePath[] paths, bool force, IProgressMonitor monitor)
 {
     foreach (string path in paths)
     {
         if (IsVersioned(path))
         {
             Svn.Delete(path, force, monitor);
         }
         else
         {
             VersionInfo srcInfo = GetVersionInfo(path, false);
             if (srcInfo != null && srcInfo.HasLocalChange(VersionStatus.ScheduledAdd))
             {
                 // Revert the add command
                 Revert(path, false, monitor);
             }
             File.Delete(path);
         }
     }
 }
示例#30
0
        public ActionResult MergeSvnFiles(SvnDetails svnDetails, string SelectedRevisions)
        {
            var svnRepro  = new Svn(mSvnExecutablePath, svnDetails.TrunckPath, svnDetails.BranchPath, svnDetails.SvnUser, svnDetails.SvnPassword);
            var revisions = SelectedRevisions.Split(',').OrderBy(x => int.Parse(x));

            try
            {
                svnRepro.MergeChanges(svnDetails, revisions);
            }
            catch (SvnProcess.SvnException ex)
            {
                foreach (var error in ex.SvnError)
                {
                    ModelState.AddModelError("", error);
                }
                ModelState.AddModelError("", ex.Command);
            }

            return(PartialView("ValidationSummary"));
        }
示例#31
0
 protected override void OnDeleteDirectories(FilePath[] localPaths, bool force, IProgressMonitor monitor, bool keepLocal)
 {
     foreach (string path in localPaths)
     {
         if (IsVersioned(path))
         {
             string newPath = String.Empty;
             if (keepLocal)
             {
                 newPath = FileService.CreateTempDirectory();
                 FileService.CopyDirectory(path, newPath);
             }
             try {
                 Svn.Delete(path, force, monitor);
             } finally {
                 if (keepLocal)
                 {
                     FileService.MoveDirectory(newPath, path);
                 }
             }
         }
         else
         {
             if (keepLocal)
             {
                 foreach (var info in GetDirectoryVersionInfo(path, false, true))
                 {
                     if (info != null && info.HasLocalChange(VersionStatus.ScheduledAdd))
                     {
                         // Revert the add command
                         Revert(path, false, monitor);
                     }
                 }
             }
             else
             {
                 Directory.Delete(path, true);
             }
         }
     }
 }
示例#32
0
        public ActionResult MergeSvnFiles(SvnDetails svnDetails, string SelectedRevisions)
        {
            var svnRepro = new Svn(mSvnExecutablePath, svnDetails.TrunckPath, svnDetails.BranchPath, svnDetails.SvnUser, svnDetails.SvnPassword);
            var revisions = SelectedRevisions.Split(',').OrderBy(x => int.Parse(x));

            try
            {
                svnRepro.MergeChanges(svnDetails, revisions);
            }
            catch (SvnProcess.SvnException ex)
            {
                foreach(var error in ex.SvnError)
                    ModelState.AddModelError("", error);
                ModelState.AddModelError("", ex.Command);
            }

            return PartialView("ValidationSummary");
        }
示例#33
0
 public void MyTestInitialize()
 {
     mSvnLog = new Svn(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty);
 }