/// <summary>
        /// Returns the full path to the specific directory. Assumes that this assembly is currently place in
        /// a subfolder of "src".
        /// </summary>
        /// <param name="dir"></param>
        /// <returns></returns>
        public static string Locate(RepositoryDirectory dir)
        {
            var loc = Assembly.GetExecutingAssembly().CodeBase;

            // CodeBase format is stupid as hell, but we can't use Location property as shadow copying (NUnit, etc.) will put us into some temporary directories, while CodeBase always points to the original location the dll is run from
            if (loc.StartsWith("file:///"))
            {
                loc = loc.Substring(8);
            }
            loc = loc.Replace("/", "\\");

            // move up until we are in the root
            while (loc.Contains("\\") && !loc.EndsWith("\\src"))
            {
                loc = loc.Substring(0, loc.LastIndexOf("\\", StringComparison.Ordinal));
            }
            if (!loc.Contains("\\"))
            {
                return(null);
            }

            switch (dir)
            {
            case RepositoryDirectory.SourceCode:
                return(loc);

            case RepositoryDirectory.TestFiles:
                return(Path.Combine(loc, "testfiles"));

            default:
                throw new ArgumentOutOfRangeException(nameof(dir));
            }
        }
Ejemplo n.º 2
0
        public override void SetUp()
        {
            base.SetUp();

            RepositoryDirectory.Refresh();
            if (RepositoryDirectory.Exists)
            {
                RepositoryDirectory.Delete();
            }

            RepositoryDirectory.Create();
        }
 Error[] Castle.SvnHooks.IPreCommit.PreCommit(RepositoryDirectory directory)
 {
     // Directories dont have any svn:eol-style properties
     return(null);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取库的下级目录
        /// </summary>
        private string GetSubDirByType(string repositoryId, RepositoryDirectory dirType)
        {
            string reposDir = Path.Combine(RootDirName, repositoryId);

            return(subDirs[dirType.GetHashCode()]);
        }
Ejemplo n.º 5
0
 Error[] Castle.SvnHooks.IPreCommit.PreCommit(RepositoryDirectory directory)
 {
     // Directories, for obvious reasons, cannot contain the copyright
     // notice at the top of its contents.
     return(Error.NoErrors);
 }
Ejemplo n.º 6
0
        public MenuItem MakeRemoteProviderItem(
            string repositoryFolder,
            RepositoryDirectory existingRepositories)
        {
            // This _should_ never be shown to the user, and is only here to
            // ensure the little drop-down arrow shows up
            var dummyItem  = new MenuItem("<DUMMY>");
            var dummyItems = new[] { dummyItem };

            MenuItem menuItem = default;

            var mergeType  = MenuMerge.Add;
            var mergeOrder = 0;
            var shortcut   = Shortcut.None;

            void onPopup(object sender, EventArgs eventArgs)
            {
                var originalCursor = Cursor.Current;

                Cursor.Current = Cursors.WaitCursor;

                while (true)
                {
                    try
                    {
                        var repositories = GetRepositories()
                                           .Where(repository => !existingRepositories.Any(existing => existing.Name == repository.Name))
                                           .OrderBy(repository => repository.Name);

                        var menuItems = repositories
                                        .Select(repository => repository.GetMenuItem(
                                                    repositoryFolder,
                                                    DefaultConfig))
                                        .ToArray();

                        menuItem.MenuItems.Clear();
                        menuItem.MenuItems.AddRange(menuItems);
                        break;
                    }
                    catch (Exception exception)
                    {
                        var          text    = exception.Message;
                        const string caption = "An error occurred";
                        var          buttons = MessageBoxButtons.RetryCancel;
                        var          icon    = MessageBoxIcon.Error;

                        var response = MessageBox.Show(text, caption, buttons, icon);

                        if (response == DialogResult.Retry)
                        {
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                Cursor.Current = originalCursor;
            }

            menuItem = new MenuItem(
                mergeType,
                mergeOrder,
                shortcut,
                Name,
                delegate { },
                onPopup,
                delegate { },
                dummyItems);

            return(menuItem);
        }