예제 #1
0
        /// <summary>
        /// Pueshes selected changes from the selected project.
        /// </summary>
        public void Push(string[] files)
        {
            if (CheckProjects())
            {
                return;
            }

            if (files.Length == 0)
            {
                ClientUI.ShowMessage("No file changes selected, select some.");
                return;
            }

            try
            {
                ClientUI.ShowProgress("Building commit...");

                var diffs = CurrentProject.BuildDiff();
                var diff  = diffs.Where(file => files.Any(x => x == file.FileName)).ToList();

                if (diff.Count == 0)
                {
                    ClientUI.ShowMessage("No file changes selected, select some.");
                    return;
                }

                var commit   = Commit.FromDiff(diff.ToArray());
                var datafile = commit.Build(CurrentProject.RootDir, CurrentProject.RootDir + ".mysync\\commit.zip",
                                            x =>
                {
                    ClientUI.SetProgress("Building commit... " + x);
                });
                ClientUI.SetProgress("Pushing " + diff.Count + " change(s).");
                CurrentProject.Push(commit, datafile,
                                    x =>
                {
                    ClientUI.SetProgress("Pushing " + diff.Count + " change(s). " + x);
                });
                ClientUI.HideProgress();

                ClientUI.ShowProgress("Push done! Loading...");
                CurrentProject.Refresh(delegate
                {
                    UpdateView();
                    ClientUI.HideProgress();
                });
            }
            catch (Exception ex)
            {
                ClientUI.HideProgress();
                ClientUI.ShowMessage("Error when pushing, no changes were pushed, message: <br>" + ex.Message, true);
            }
        }