예제 #1
0
        ////////////////////////////////////////////////////////////////
        public static SvnXmlStatus GetStatus(string sPath)
        {
            //MessageBox.Show("GetExternals");
            string sStdOut,
                   sStdErr;

            General.ShellWait("svn.exe", "status --xml \"" + sPath + "\"", out sStdOut, out sStdErr);

            if (sStdErr.Length == 0)
            {
                // https://msdn.microsoft.com/de-de/library/tz8csy73(v=vs.110).aspx
                XmlSerializer serializer = new XmlSerializer(typeof(SvnXmlStatus));
                StringReader  reader     = new StringReader(sStdOut);
                SvnXmlStatus  status     = (SvnXmlStatus)serializer.Deserialize(reader);

                return(status);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public bool ApplyChanges(bool bUpdate = true, bool bIgnoreLocalChanges = false, bool bSkipChangesCheck = false)
        {
            string sExternals;

            // externals changed?
            if (IsChangedEx(out sExternals) || bSkipChangesCheck)
            {
                // temporary select entry
                //m_TreeItem.IsSelected = true;

                bool   bForce            = true;
                string sModifiedElements = "";
                // check for local changes
                foreach (External ext in m_aExternals)
                {
                    if (ext.m_wc.Count > 0)
                    {
                        SvnXmlStatus status = SvnXmlStatus.GetStatus(ext.m_wc[0].Path);
                        sModifiedElements = sModifiedElements + status.GetModifiedElements();
                    }
                }

                // ask, if local changes can be ignored
                if ((sModifiedElements.Length > 0) &&
                    !bIgnoreLocalChanges)
                {
                    bForce = (MessageBoxResult.Yes ==
                              MessageBox.Show("The following elements have local modifications.\n" +
                                              "Do you want to proceed?\n\n" + sModifiedElements,
                                              "Warning", MessageBoxButton.YesNo));
                }

                if (bForce)
                {
                    // because of collision issues with the operative revision -r in externals with the svn propset option -r
                    // we have to use a parameter file
                    string sFilename = General.GetTempFileName();
                    File.WriteAllText(sFilename, sExternals);
                    if (!File.Exists(sFilename))
                    {
                        MessageBox.Show(sFilename, "Unable to create temporary file!");
                        return(false);
                    }

                    string sStdOut,
                           sStdErr;
                    General.ShellWait("svn.exe", "propset svn:externals -F \"" + sFilename + "\" \"" + m_sPath + "\"", out sStdOut, out sStdErr);
                    File.Delete(sFilename);          // remove parameter file

                    if (sStdErr.Length == 0)
                    {
                        if (bUpdate)
                        {
                            bool bResult = TortoiseProc.Update(m_sPath, TortoiseProc.ExitType.CloseOnNoErrors);
                            // trigger view update
                            if (bResult)
                            {
                                foreach (External ext in m_aExternals)
                                {
                                    TreeItem ti = (TreeItem)ext.TreeItem;
                                    ti.VersionPath = "";
                                    ti.Revision    = "";
                                }
                            }
                            return(bResult);
                        }
                    }
                    else
                    {
                        MessageBox.Show(sStdErr, "Error setting property");
                        return(false);
                    }
                }
                return(false);
            }
            else
            {
                // if no externals changed - traverse through externals
                foreach (External ext in m_aExternals)
                {
                    if (null != ext.m_wc)
                    {
                        if (!ext.m_wc[0].ApplyChanges(bUpdate))
                        {
                            return(false);
                        }
                    }
                }

                return(true);
            }
        }