Inheritance: ICloneable
Example #1
0
 public ScmRepositoryProcess(ScmRepository f, Process p, bool isUpdateCommand)
 {
     repository           = f;
     process              = p;
     updateError          = false;
     this.isUpdateCommand = isUpdateCommand;
 }
Example #2
0
        private void ResetFolder()
        {
            if (listViewFolders.SelectedIndices.Count == 0)
            {
                return;
            }

            int           selectedIndex = listViewFolders.SelectedIndices[0];
            ScmRepository folder        = folders[selectedIndex];

            if (MessageBox.Show($"Are you sure to reset all changes in {folder.Path} ?", "SCM Notifier", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
            {
                return;
            }

            folder.Status = ScmRepositoryStatus.Unknown;
            listViewFolders.Items[selectedIndex].ImageKey = folder.IconName;

            statusStrip.Items[0].Text = "Reseting '" + folder.Path + "'...";
            UpdateTray(true);
            Refresh();              // Show "Unknown" folder status during updating

            BeginUpdateFolderStatuses();

            folder.Reset();

            forcedFolders.Enqueue(folder);
        }
Example #3
0
        public SettingsProjectForm(ScmRepository folder)
        {
            InitializeComponent();                      // Required for Windows Form Designer support

            this.folder         = folder;
            textBox_folder.Text = folder.Path;

            if (folder.ActiveStatusUpdateInterval < 0)
            {
                numericUpDown_ActiveStatusUpdateIntervalHour.Value = Config.DefaultActiveStatusUpdateInterval / 3600;
                numericUpDown_ActiveStatusUpdateIntervalMin.Value  = (Config.DefaultActiveStatusUpdateInterval % 3600) / 60;
                numericUpDown_ActiveStatusUpdateIntervalSec.Value  = Config.DefaultActiveStatusUpdateInterval % 60;

                numericUpDown_IdleStatusUpdateIntervalHour.Value = Config.DefaultIdleStatusUpdateInterval / 3600;
                numericUpDown_IdleStatusUpdateIntervalMin.Value  = (Config.DefaultIdleStatusUpdateInterval % 3600) / 60;
                numericUpDown_IdleStatusUpdateIntervalSec.Value  = Config.DefaultIdleStatusUpdateInterval % 60;

                groupBox1.Checked = false;
            }
            else
            {
                numericUpDown_ActiveStatusUpdateIntervalHour.Value = folder.ActiveStatusUpdateInterval / 3600;
                numericUpDown_ActiveStatusUpdateIntervalMin.Value  = (folder.ActiveStatusUpdateInterval % 3600) / 60;
                numericUpDown_ActiveStatusUpdateIntervalSec.Value  = folder.ActiveStatusUpdateInterval % 60;

                numericUpDown_IdleStatusUpdateIntervalHour.Value = folder.IdleStatusUpdateInterval / 3600;
                numericUpDown_IdleStatusUpdateIntervalMin.Value  = (folder.IdleStatusUpdateInterval % 3600) / 60;
                numericUpDown_IdleStatusUpdateIntervalSec.Value  = folder.IdleStatusUpdateInterval % 60;

                groupBox1.Checked = true;
            }

            checkBoxDisable.Checked = folder.Disable;
            groupBox1.Enabled       = !checkBoxDisable.Checked;
        }
        public SettingsProjectForm(ScmRepository folder)
        {
            InitializeComponent();		// Required for Windows Form Designer support

            this.folder = folder;
            textBox_folder.Text = folder.Path;

            if (folder.ActiveStatusUpdateInterval < 0)
            {
                numericUpDown_ActiveStatusUpdateIntervalHour.Value = Config.DefaultActiveStatusUpdateInterval / 3600;
                numericUpDown_ActiveStatusUpdateIntervalMin.Value = (Config.DefaultActiveStatusUpdateInterval % 3600) / 60;
                numericUpDown_ActiveStatusUpdateIntervalSec.Value = Config.DefaultActiveStatusUpdateInterval % 60;

                numericUpDown_IdleStatusUpdateIntervalHour.Value = Config.DefaultIdleStatusUpdateInterval / 3600;
                numericUpDown_IdleStatusUpdateIntervalMin.Value = (Config.DefaultIdleStatusUpdateInterval % 3600) / 60;
                numericUpDown_IdleStatusUpdateIntervalSec.Value = Config.DefaultIdleStatusUpdateInterval % 60;

                groupBox1.Checked = false;
            }
            else
            {
                numericUpDown_ActiveStatusUpdateIntervalHour.Value = folder.ActiveStatusUpdateInterval / 3600;
                numericUpDown_ActiveStatusUpdateIntervalMin.Value = (folder.ActiveStatusUpdateInterval % 3600) / 60;
                numericUpDown_ActiveStatusUpdateIntervalSec.Value = folder.ActiveStatusUpdateInterval % 60;

                numericUpDown_IdleStatusUpdateIntervalHour.Value = folder.IdleStatusUpdateInterval / 3600;
                numericUpDown_IdleStatusUpdateIntervalMin.Value = (folder.IdleStatusUpdateInterval % 3600) / 60;
                numericUpDown_IdleStatusUpdateIntervalSec.Value = folder.IdleStatusUpdateInterval % 60;

                groupBox1.Checked = true;
            }

            checkBoxDisable.Checked = folder.Disable;
            groupBox1.Enabled = !checkBoxDisable.Checked;
        }
Example #5
0
        //////////////////////////////////////////////////////////////////////////////

        private void UpdateFolder()
        {
            if (listViewFolders.SelectedIndices.Count == 0)
            {
                return;
            }

            int           selectedIndex = listViewFolders.SelectedIndices[0];
            ScmRepository folder        = folders[selectedIndex];

            if (Config.ChangeLogBeforeUpdate && (folder.reviewedRevision < folder.GetRepositoryHeadRevision()))
            {
                MessageBox.Show("You need to see ChangeLog first!", "SCM Notifier", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            btnUpdate.Enabled = updateToolStripMenuItem.Enabled = checkNowToolStripMenuItem.Enabled = false;
            folder.Status     = ScmRepositoryStatus.Unknown;
            listViewFolders.Items[selectedIndex].ImageKey = folder.IconName;
            newNonUpdatedFolders.Clear();

            statusStrip.Items[0].Text = "Updating '" + folder.Path + "'...";
            UpdateTray(true);
            Refresh();                                          // Show "Unknown" folder status during updating

            updateNotInProgress.Reset();
            BeginUpdateFolderStatuses();

            folder.Update(false);

            forcedFolders.Enqueue(folder);

            updateNotInProgress.Set();
        }
Example #6
0
        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int           selectedIndex = listViewFolders.SelectedIndices[0];
            ScmRepository folder        = folders[selectedIndex];

            if (new SettingsProjectForm(folder).ShowDialog(this) == DialogResult.OK)
            {
                listViewFolders.Items[selectedIndex].Text = folder.Path;
                if (folder.Disable)
                {
                    folder.Status = ScmRepositoryStatus.Unknown;
                    listViewFolders.Items[selectedIndex].Font      = new Font(listViewFolders.Font, FontStyle.Strikeout);
                    listViewFolders.Items[selectedIndex].ForeColor = Color.LightGray;
                    listViewFolders.Items[selectedIndex].ImageKey  = folder.IconName;
                }
                else
                {
                    listViewFolders.Items[selectedIndex].Font      = listViewFolders.Font;
                    listViewFolders.Items[selectedIndex].ForeColor = SystemColors.WindowText;
                }

                newNonUpdatedFolders.Clear();

                UpdateListViewFolderNames();

                Config.SaveSvnFolders(folders);

                UpdateTray(true);
                BeginUpdateFolderStatuses();
            }
        }
Example #7
0
        private void AddFolder(string path)
        {
            if (!folders.ContainsPath(path))
            {
                ScmRepository repo = ScmRepository.create(path);

                if (repo != null)
                {
                    folders.Add(repo);
                    listViewFolders.Items.Add(new ListViewItem(path, repo.IconName));
                    UpdateListViewFolderNames();

                    Config.SaveSvnFolders(folders);

                    UpdateTray(false);
                    BeginUpdateFolderStatuses();
                }
                else
                {
                    MessageBox.Show("This folder is not repository", "SCM Notifier", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                SelectFolder(path);
            }
        }
Example #8
0
        /// <summary>
        /// Executed on working thread
        /// </summary>
        private void UpdateFolderStatus(ScmRepository folder)
        {
            SafeInvoke(new SetStatusBarTextMethod(SetStatusBarText), new object[] { "Checking '" + folder.Path + "'..." });
            DateTime statusTime = DateTime.Now;

            if (sessionEndInProgress)
            {
                return;                                                 // Need to avoid error on svn.exe invoking
            }
            ScmRepositoryStatus status = folder.GetStatus();

            SafeInvoke(new UpdateListViewMethod(UpdateListView), new object[] { folder, status, statusTime });
        }
Example #9
0
        ////////////////////////////////////////////////////////////////////////////////////

        #region listViewFolders handlers

        private void listViewFolders_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewFolders.SelectedIndices.Count > 0)
            {
                ScmRepository folder = folders[listViewFolders.SelectedIndices[0]];

                btnChangeLog.Enabled = btnUpdate.Enabled = btnLog.Enabled = false;

                if ((folder.Status == ScmRepositoryStatus.NeedUpdate) || (folder.Status == ScmRepositoryStatus.NeedUpdate_Modified))
                {
                    btnChangeLog.Enabled = btnUpdate.Enabled = btnLog.Enabled = true;
                }
                else if ((folder.Status == ScmRepositoryStatus.UpToDate) || (folder.Status == ScmRepositoryStatus.UpToDate_Modified))
                {
                    btnLog.Enabled = true;
                }

                if ((folder.Status == ScmRepositoryStatus.NeedUpdate_Modified) || (folder.Status == ScmRepositoryStatus.UpToDate_Modified))
                {
                    btnCommit.Enabled = true;
                }

                // Disable Log Button when GitUIPath not configured
                if (folder is GitRepository && (Config.GitUIPath == null || !File.Exists(Config.GitUIPath)))
                {
                    btnLog.Enabled = false;
                }

                deleteToolStripMenuItem.Enabled = true;
                btnDelete.Enabled     = true;
                btnOpenFolder.Enabled = Directory.Exists(folder.Path) || File.Exists(folder.Path);

                Text = Application.ProductName + " - " + folder.Path;
            }
            else
            {
                btnChangeLog.Enabled            = false;
                btnUpdate.Enabled               = false;
                btnCommit.Enabled               = false;
                deleteToolStripMenuItem.Enabled = false;
                btnDelete.Enabled               = false;
                btnOpenFolder.Enabled           = false;
                btnLog.Enabled = false;

                Text = Application.ProductName;
            }
        }
Example #10
0
        public static SvnFolderCollection ReadSvnFolders()
        {
            SvnFolderCollection folders = new SvnFolderCollection();

            for (int i = 1;; i++)
            {
                string s = iniFile.ReadString("Folders", "Folder" + i);
                if (s.Length == 0)
                {
                    break;
                }

                folders.Add(ScmRepository.Deserialize(s));
            }

            return(folders);
        }
Example #11
0
        private void UpdateListView(ScmRepository folder, ScmRepositoryStatus folderStatus, DateTime statusTime)
        {
            int i = folders.IndexOf(folder);

            if (i < 0)
            {
                return;
            }

            if (statusTime < folder.StatusUpdateTime)
            {
                return;
            }

            if (folder.Status != folderStatus)
            {
                folder.Status = folderStatus;
                listViewFolders.Items[i].ImageKey = folder.IconName;

                if ((folderStatus == ScmRepositoryStatus.NeedUpdate) ||
                    (folderStatus == ScmRepositoryStatus.NeedUpdate_Modified))
                {
                    newNonUpdatedFolders.Add(folder);
                    UpdateTray(true);
                }
                else
                {
                    UpdateTray(false);
                }

                // Refresh buttons
                listViewFolders_SelectedIndexChanged(null, null);
            }
            else
            {
                folder.Status = folderStatus;                           // Update status time only
            }
        }
Example #12
0
 public void Remove(ScmRepository f)
 {
     list.Remove(f);
 }
Example #13
0
 public void Insert(int index, ScmRepository f)
 {
     list.Insert(index, f);
 }
Example #14
0
 public int IndexOf(ScmRepository f)
 {
     return(list.IndexOf(f));
 }
Example #15
0
 /// <summary>
 /// Executed on working thread
 /// </summary>
 private void UpdateFolderStatus(ScmRepository folder)
 {
     SafeInvoke (new SetStatusBarTextMethod (SetStatusBarText), new object[] {"Checking '" + folder.Path + "'..."});
     DateTime statusTime = DateTime.Now;
     if (sessionEndInProgress) return;		// Need to avoid error on svn.exe invoking
     ScmRepositoryStatus status = folder.GetStatus();
     SafeInvoke (new UpdateListViewMethod (UpdateListView), new object[] {folder, status, statusTime});
 }
Example #16
0
        private void UpdateListView(ScmRepository folder, ScmRepositoryStatus folderStatus, DateTime statusTime)
        {
            int i = folders.IndexOf (folder);
            if (i < 0) return;

            if (statusTime < folder.StatusUpdateTime)
                return;

            if (folder.Status != folderStatus)
            {
                folder.Status = folderStatus;
                listViewFolders.Items[i].ImageKey = folder.IconName;

                if ((folderStatus == ScmRepositoryStatus.NeedUpdate) ||
                    (folderStatus == ScmRepositoryStatus.NeedUpdate_Modified))
                {
                    newNonUpdatedFolders.Add (folder);
                    UpdateTray (true);
                }
                else
                    UpdateTray (false);

                // Refresh buttons
                listViewFolders_SelectedIndexChanged (null, null);
            }
            else
                folder.Status = folderStatus;		// Update status time only
        }
Example #17
0
        /// <summary>
        /// Executed on working thread
        /// </summary>
        private void StatusUpdateThread_Run()
        {
            try
            {
                while (!Created)
                {
                    Thread.Sleep(10);
                }

                while (true)
                {
                    SafeInvoke(new MethodInvoker(BeginUpdateListView));

                    foreach (ScmRepository folder in (SvnFolderCollection)folders.Clone())
                    {
                        if (folder.Disable)
                        {
                            continue;
                        }

                        updateNotInProgress.WaitOne();

                        if (forcedCheckForNewVersion)
                        {
                            forcedCheckForNewVersion     = false;
                            lastTimeOfCheckForNewVersion = DateTime.Now;
                            SafeInvoke(new SetStatusBarTextMethod(SetStatusBarText), new object[] { "Checking for new version..." });
                            CheckForNewVersion(true);
                        }

                        bool skipUpdateStatus = false;

                        // Check commit and update processes for finishing
                        for (int i = 0; i < ScmRepository.svnFolderProcesses.Count; i++)
                        {
                            var sfp = (ScmRepositoryProcess)ScmRepository.svnFolderProcesses[i];

                            if (sfp.process.HasExited)
                            {
                                if (sfp.isUpdateCommand && sfp.updateError)
                                {
                                    SafeInvoke(new ShowUpdateErrorsMethod(ShowUpdateErrors), new object[] { sfp }, Int32.MaxValue);
                                }

                                UpdateFolderStatus(sfp.repository);
                                ScmRepository.svnFolderProcesses.RemoveAt(i--);
                            }
                            else if ((folder.Path == sfp.repository.Path) && sfp.isUpdateCommand)
                            {
                                skipUpdateStatus = true;                                                // Because updating is still in progress
                                ScmRepository.ReadProcessOutput(sfp);
                            }
                        }

                        while (forcedFolders.Count > 0)
                        {
                            UpdateFolderStatus((ScmRepository)forcedFolders.Dequeue());
                        }

                        if ((folder.StatusUpdateTime + new TimeSpan(0, 0, folder.GetInterval(formIsActive)) <= DateTime.Now) && !skipUpdateStatus)
                        {
                            UpdateFolderStatus(folder);
                        }
                    }

                    if (forcedCheckForNewVersion)
                    {
                        forcedCheckForNewVersion     = false;
                        lastTimeOfCheckForNewVersion = DateTime.Now;
                        SafeInvoke(new SetStatusBarTextMethod(SetStatusBarText), new object[] { "Checking for new version..." });
                        CheckForNewVersion(true);
                    }

                    if (Config.CheckForNewVersion && (lastTimeOfCheckForNewVersion + new TimeSpan(3, 0, 0) < DateTime.Now))
                    {
                        lastTimeOfCheckForNewVersion = DateTime.Now;
                        SafeInvoke(new SetStatusBarTextMethod(SetStatusBarText), new object[] { "Checking for new version..." });
                        CheckForNewVersion(false);
                    }

                    lock (this)
                    {
                        if (!reupdateStatus)
                        {
                            statusThread = null;
                            break;
                        }
                        else
                        {
                            reupdateStatus = false;
                        }
                    }
                }

                SafeInvoke(new MethodInvoker(EndUpdateListView));
            }
            catch (ThreadAbortException)
            {
                ScmRepository.KillBackgroundProcess();
            }
            catch (Exception e)                         // Otherwise it will just lost
            {
                ShowError("Error on status thread: " + e);
                Application.Exit();
            }
        }
Example #18
0
 public void Remove(ScmRepository f)
 {
     list.Remove (f);
 }
Example #19
0
 public void Insert(int index, ScmRepository f)
 {
     list.Insert (index, f);
 }
Example #20
0
 public ScmRepositoryProcess(ScmRepository f, Process p, bool isUpdateCommand)
 {
     repository = f;
     process = p;
     updateError = false;
     this.isUpdateCommand = isUpdateCommand;
 }
Example #21
0
 public int Add(ScmRepository f)
 {
     return(list.Add(f));
 }
Example #22
0
 public int Add(ScmRepository f)
 {
     return list.Add (f);
 }
Example #23
0
 public int IndexOf(ScmRepository f)
 {
     return list.IndexOf (f);
 }