private SyncConfiguration GetCurrentConfigFromUI(bool applyVars = false)
        {
            SyncConfiguration config = new SyncConfiguration();
            Type type = config.GetType();

            FieldInfo[] properties = type.GetFields();

            foreach (FieldInfo property in properties)
            {
                if (property.Name.StartsWith("m_"))
                {
                    if (m_mapTextItems.ContainsKey(property.Name))
                    {
                        var v = m_mapTextItems[property.Name].Text;
                        v = applyVars ? RunImplementation.applyVariables(v, m_variables) : v;
                        property.SetValue(config, v);
                    }
                    else if (m_mapCheckItems.ContainsKey(property.Name))
                    {
                        property.SetValue(config, m_mapCheckItems[property.Name].Checked);
                    }
                    else
                    {
                        MessageBox.Show("unknown property:" + property.Name);
                    }
                }
            }

            return(config);
        }
Esempio n. 2
0
        static void TestMethod_TestIndividualFailures()
        {
            var sDirectory = Testing.SetUpSynctestEnvironment();
            CCreateSyncResultsSet results;

            CCreateSyncResultsSet.showWarnings = false;
            using (Stream iStream2 = File.Open(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt", FileMode.Append, FileAccess.Write, FileShare.None))
            {
                var config = GetRealConfig(sDirectory, 4 /*nThreads*/);
                config.m_nRetries           = "1";
                config.m_waitBetweenRetries = "1";
                string sLogFilename = RunImplementation.GetLogFilename();
                RunImplementation.Go(config, sLogFilename, false /*preview*/, false);
                results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/);
                File.Delete(sLogFilename);
            }

            CCreateSyncResultsSet.showWarnings = true;

            Utils.AssertEq(0, results.items.Count);
            Utils.AssertEq(true, results.sSummary.Contains("Summary indicated failures"));
            Utils.AssertEq(true, results.sSummary.Contains("*EXTRA File"));
            Utils.AssertEq(true, results.sSummary.Contains("it is being used by another process"));
            Utils.AssertEq(true, results.sSummary.Contains("RETRY LIMIT EXCEEDED"));
            Utils.AssertEq(true, results.sSummary.Contains("Bytes :"));
        }
        void RunCopyingOnSeparateThread()
        {
            foreach (var config in this.configs)
            {
                CCreateSyncResultsSet results = null;
                string sExceptionOccurred     = null;
                try
                {
                    string sLogFilename = RunImplementation.GetLogFilename();
                    RunImplementation.Go(config, sLogFilename, preview, false);
                    results = CCreateSyncResultsSet.ParseFromLogFile(
                        config, sLogFilename, preview);
                }
                catch (Exception e)
                {
                    sExceptionOccurred = e.ToString();
                }

                Action action = delegate() { OnRunComplete(results, sExceptionOccurred); };
                btnToTemporarilyDisable.BeginInvoke(action);
            }

            // Don't restore btn text until all configs were processed
            Action restoreBtnText = delegate()
            {
                btnToTemporarilyDisable.Text    = sPreviousButtonName;
                btnToTemporarilyDisable.Enabled = true;
            };

            btnToTemporarilyDisable.BeginInvoke(restoreBtnText);
        }
Esempio n. 4
0
        static void TestMethod_GetCommandLineParameters02()
        {
            var config     = SyncConfiguration.Deserialize(Testing.GetTestFile("test_cfg_02.xml"));
            var sArguments = RunImplementation.GetCommandLineArgs(config);
            var sExpected  = " \"chg8\" \"chg9\"  /XD \"chg10\"  /XF \"chg11\"  /E  /COPY:#1@  /DCOPY:#2@  /IPG:#3@  /R:#4@  /W:#5@  /MT:#6@  #7@  /FFT ";

            Utils.AssertEq(sExpected, sArguments);
        }
Esempio n. 5
0
        static void TestMethod_GetCommandLineParameters01()
        {
            var config     = SyncConfiguration.Deserialize(Testing.GetTestFile("test_cfg_01.xml"));
            var sArguments = RunImplementation.GetCommandLineArgs(config);
            var sExpected  = " \"chg1\" \"chg2\"  /XD \"chg3\"  /XF \"chg4\"  /MIR  /COPY:#1  /DCOPY:#2  /IPG:#3  /R:#4  /W:#5  /MT:#6  #7  /SL  /DST ";

            Utils.AssertEq(sExpected, sArguments);
        }
Esempio n. 6
0
 private void btnShowRight_Click(object sender, EventArgs e)
 {
     foreach (var item in IterateListViewItems(true))
     {
         RunImplementation.ShowInExplorer(item.GetRightPath(m_results.config));
         return;
     }
 }
        private void btnShowCmd_Click(object sender, EventArgs e)
        {
            var args = RunImplementation.Go(GetCurrentConfigFromUI(true), RunImplementation.GetLogFilename(), true, true);

            MessageBox.Show(args);
            if (Utils.AskToConfirm("Copy to clipboard?"))
            {
                Clipboard.SetText(args);
            }
        }
 private void OnTextFieldChange(TextBox textBox, Label label)
 {
     if (Directory.Exists(RunImplementation.applyVariables(textBox.Text, m_variables)))
     {
         label.Text = "✓";
     }
     else
     {
         label.Text = "X";
     }
 }
        private void btnOpenWinmerge_Click(object sender, EventArgs e)
        {
            var config = GetCurrentConfigFromUI(true);

            if (!SyncConfiguration.Validate(config))
            {
                return;
            }

            RunImplementation.OpenWinmerge(m_globalSettings.m_winMergeDir, config.m_src, config.m_destination, true);
        }
Esempio n. 10
0
 private void btnCompareWinmerge_Click(object sender, EventArgs e)
 {
     // "View in winmerge"
     foreach (var item in IterateListViewItems(true))
     {
         var itemObj = item as CCreateSyncItem;
         if (itemObj != null && (itemObj.status == CCreateSyncItemStatus.ChangedAndDestNewer || itemObj.status == CCreateSyncItemStatus.ChangedAndSrcNewer))
         {
             RunImplementation.OpenWinmerge(m_globalSettings.m_winMergeDir,
                                            itemObj.GetLeftPath(m_results.config), itemObj.GetRightPath(m_results.config), false);
         }
     }
 }
        public static SyncConfiguration Deserialize(string sFilename, Dictionary <string, string> vars = null)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(SyncConfiguration));
            TextReader    reader       = new StreamReader(sFilename);
            var           txt          = reader.ReadToEnd();

            if (vars != null)
            {
                txt = RunImplementation.applyVariables(txt, vars);
            }

            var    stm = new MemoryStream(Encoding.UTF8.GetBytes(txt));
            object obj = deserializer.Deserialize(stm);

            reader.Close();
            return((SyncConfiguration)obj);
        }
Esempio n. 12
0
        static void TestMethod_TestGlobalFailure()
        {
            var config = new SyncConfiguration();

            config.m_src         = "notexist1";
            config.m_destination = "notexist2";
            config.m_mirror      = true;
            config.m_copySubDirsAndEmptySubdirs = true;

            string sLogFilename = RunImplementation.GetLogFilename();

            RunImplementation.Go(config, sLogFilename, true /*preview*/, false);
            var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/);

            Utils.AssertEq(0, results.items.Count);
            Utils.AssertEq(true, results.sSummary.Contains("looks like errors occurred:"));
            Utils.AssertEq(true, results.sSummary.Contains("The system cannot find the file specified."));
            File.Delete(sLogFilename);
        }
Esempio n. 13
0
        static void TestActualSync(string sDirectory, int nThreads)
        {
            var    config       = GetRealConfig(sDirectory, nThreads);
            string sLogFilename = RunImplementation.GetLogFilename();

            RunImplementation.Go(config, sLogFilename, false /*preview*/, false);
            var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, false /*preview*/);

            File.Delete(sLogFilename);
            // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now
            Utils.AssertEq("Total    Copied   Skipped  Mismatch    Failed    Extras\r\n    Dirs :         5         5         3         0         0         2\r\n   Files :        22         8        14         0         0         2\r\n   Bytes :   632.0 k   126.6 k   505.4 k         0         0    30.7 k", results.sSummary.Trim());

            // check files
            string[]      filesExpected = @"..\..\test\testsync\dest
..\..\test\testsync\dest\Images
..\..\test\testsync\dest\Images\a.png
..\..\test\testsync\dest\Images\addempty
..\..\test\testsync\dest\Images\addir
..\..\test\testsync\dest\Images\addir\a.PNG
..\..\test\testsync\dest\Images\b.png
..\..\test\testsync\dest\Images\c.png
..\..\test\testsync\dest\Images\d.png
..\..\test\testsync\dest\Images\DB44-20-x64.jpg
..\..\test\testsync\dest\Images\e.png
..\..\test\testsync\dest\Images\f.gif
..\..\test\testsync\dest\Licenses
..\..\test\testsync\dest\Licenses\.weirdext
..\..\test\testsync\dest\Licenses\Apr-License.txt
..\..\test\testsync\dest\Licenses\Apr-Util-License.txt
..\..\test\testsync\dest\Licenses\BerkeleyDB-License.txt
..\..\test\testsync\dest\Licenses\Cyrus-Sasl-License.txt
..\..\test\testsync\dest\Licenses\GetText-Runtime-License.txt
..\..\test\testsync\dest\Licenses\noext
..\..\test\testsync\dest\Licenses\OpenSsl-License.txt
..\..\test\testsync\dest\Licenses\Serf-License.txt
..\..\test\testsync\dest\Licenses\SharpSvn-License.txt
..\..\test\testsync\dest\Licenses\Subversion-License.txt
..\..\test\testsync\dest\loren.html
..\..\test\testsync\dest\loren.txt
..\..\test\testsync\dest\pic1.png
..\..\test\testsync\src
..\..\test\testsync\src\Images
..\..\test\testsync\src\Images\a.png
..\..\test\testsync\src\Images\addempty
..\..\test\testsync\src\Images\addir
..\..\test\testsync\src\Images\addir\a.PNG
..\..\test\testsync\src\Images\b.png
..\..\test\testsync\src\Images\c.png
..\..\test\testsync\src\Images\d.png
..\..\test\testsync\src\Images\DB44-20-x64.jpg
..\..\test\testsync\src\Images\e.png
..\..\test\testsync\src\Images\f.gif
..\..\test\testsync\src\Licenses
..\..\test\testsync\src\Licenses\.weirdext
..\..\test\testsync\src\Licenses\Apr-License.txt
..\..\test\testsync\src\Licenses\Apr-Util-License.txt
..\..\test\testsync\src\Licenses\BerkeleyDB-License.txt
..\..\test\testsync\src\Licenses\Cyrus-Sasl-License.txt
..\..\test\testsync\src\Licenses\GetText-Runtime-License.txt
..\..\test\testsync\src\Licenses\noext
..\..\test\testsync\src\Licenses\OpenSsl-License.txt
..\..\test\testsync\src\Licenses\Serf-License.txt
..\..\test\testsync\src\Licenses\SharpSvn-License.txt
..\..\test\testsync\src\Licenses\Subversion-License.txt
..\..\test\testsync\src\loren.html
..\..\test\testsync\src\loren.txt
..\..\test\testsync\src\pic1.png".Replace("\r\n", "\n").Replace(@"..\..\test\testsync\", sDirectory + "\\").Split(new char[] { '\n' });
            List <string> filesGot      = Directory.GetFileSystemEntries(sDirectory, "*", SearchOption.AllDirectories).ToList();

            filesGot.Sort();
            Testing.AssertStringArrayEqual(filesExpected, filesGot);
            Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\OpenSsl-License.txt").Length, 6286L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Apr-License.txt").Length, 18324L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\src\\Licenses\\Serf-License.txt").Length, 11562L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\OpenSsl-License.txt").Length, 6286L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Apr-License.txt").Length, 18324L);
            Utils.AssertEq(new FileInfo(sDirectory + "\\dest\\Licenses\\Serf-License.txt").Length, 11562L);
        }
Esempio n. 14
0
        private void ManualCopyFileImpl(string s1, string s2)
        {
            try
            {
                if (File.Exists(s2) && !String.IsNullOrEmpty(this.m_globalSettings.m_directoryForDeletedFiles))
                {
                    var newName = m_globalSettings.m_directoryForDeletedFiles + "\\" + Path.GetFileName(s2) + RunImplementation.GetRandomNumbersInString();
                    File.Copy(s2, newName, true /*okOverwrite*/);
                }

                File.Copy(s1, s2, true /*okOverwrite*/);
            }
            catch (Exception e)
            {
                MessageBox.Show("Copying " + s1 + " to " + s2 + ". Exception " + e);
            }
        }
Esempio n. 15
0
 private void btnIncludeBoth_Click(object sender, EventArgs e)
 {
     // save the existing one by copying it to the left side
     foreach (var item in IterateListViewItems(true /*only selected*/))
     {
         if (item.IsInRight())
         {
             var nameOnLeft = Path.GetDirectoryName(item.GetLeftPath(m_results.config)) + "\\" + Path.GetFileNameWithoutExtension(item.GetLeftPath(m_results.config)) + RunImplementation.GetRandomNumbersInString() +
                              Path.GetExtension(item.GetLeftPath(m_results.config));
             if (MessageBox.Show("Confirm copy from " + item.GetRightPath(m_results.config) + " to " + nameOnLeft + "?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 File.Copy(item.GetRightPath(m_results.config), nameOnLeft, false /*okToOverwrite*/);
             }
         }
     }
 }
Esempio n. 16
0
        public static string SetUpSynctestEnvironment()
        {
            var testSyncPath = GetTestTempFile("testsync");

            if (!Directory.Exists(testSyncPath))
            {
                Directory.CreateDirectory(testSyncPath);
            }

            // use rbcpy itself to set up the sync test :)
            var config = new SyncConfiguration();

            config.m_src         = GetTestDirectory() + "\\testsync";
            config.m_destination = testSyncPath;
            config.m_mirror      = true;
            config.m_copySubDirsAndEmptySubdirs = true;
            config.m_copyFlags = "DA"; // don't copy times

            string sLogFilename = RunImplementation.GetLogFilename();

            RunImplementation.Go(config, sLogFilename, false /*preview*/, false);
            File.Delete(sLogFilename);
            string[]      filesExpected = @"..\..\test\testsync\dest
..\..\test\testsync\dest\Images
..\..\test\testsync\dest\Images\b.png
..\..\test\testsync\dest\Images\c.png
..\..\test\testsync\dest\Images\d.png
..\..\test\testsync\dest\Images\DB44-20-x64.jpg
..\..\test\testsync\dest\Images\e.png
..\..\test\testsync\dest\Images\f.gif
..\..\test\testsync\dest\Images\new.png
..\..\test\testsync\dest\Images\remdir
..\..\test\testsync\dest\Images\remdir\c.png
..\..\test\testsync\dest\Images\remempty
..\..\test\testsync\dest\Licenses
..\..\test\testsync\dest\Licenses\Apr-License.txt
..\..\test\testsync\dest\Licenses\Apr-Util-License.txt
..\..\test\testsync\dest\Licenses\BerkeleyDB-License.txt
..\..\test\testsync\dest\Licenses\Cyrus-Sasl-License.txt
..\..\test\testsync\dest\Licenses\GetText-Runtime-License.txt
..\..\test\testsync\dest\Licenses\OpenSsl-License.txt
..\..\test\testsync\dest\Licenses\Serf-License.txt
..\..\test\testsync\dest\Licenses\SharpSvn-License.txt
..\..\test\testsync\dest\Licenses\Subversion-License.txt
..\..\test\testsync\dest\loren.html
..\..\test\testsync\dest\loren.txt
..\..\test\testsync\dest\pic1.png
..\..\test\testsync\src
..\..\test\testsync\src\Images
..\..\test\testsync\src\Images\a.png
..\..\test\testsync\src\Images\addempty
..\..\test\testsync\src\Images\addir
..\..\test\testsync\src\Images\addir\a.PNG
..\..\test\testsync\src\Images\b.png
..\..\test\testsync\src\Images\c.png
..\..\test\testsync\src\Images\d.png
..\..\test\testsync\src\Images\DB44-20-x64.jpg
..\..\test\testsync\src\Images\e.png
..\..\test\testsync\src\Images\f.gif
..\..\test\testsync\src\Licenses
..\..\test\testsync\src\Licenses\.weirdext
..\..\test\testsync\src\Licenses\Apr-License.txt
..\..\test\testsync\src\Licenses\Apr-Util-License.txt
..\..\test\testsync\src\Licenses\BerkeleyDB-License.txt
..\..\test\testsync\src\Licenses\Cyrus-Sasl-License.txt
..\..\test\testsync\src\Licenses\GetText-Runtime-License.txt
..\..\test\testsync\src\Licenses\noext
..\..\test\testsync\src\Licenses\OpenSsl-License.txt
..\..\test\testsync\src\Licenses\Serf-License.txt
..\..\test\testsync\src\Licenses\SharpSvn-License.txt
..\..\test\testsync\src\Licenses\Subversion-License.txt
..\..\test\testsync\src\loren.html
..\..\test\testsync\src\loren.txt
..\..\test\testsync\src\pic1.png".Replace("\r\n", "\n").Replace(@"..\..\test\testsync\", testSyncPath + "\\").Split(new char[] { '\n' });
            List <string> filesGot      = Directory.GetFileSystemEntries(testSyncPath, "*", SearchOption.AllDirectories).ToList();

            filesGot.Sort();
            var sFilesExpected = string.Join("\r\n", filesExpected);
            var sFilesGot      = string.Join("\r\n", filesGot);

            Utils.AssertEq(sFilesExpected, sFilesGot);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\OpenSsl-License.txt").Length, 6286L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Apr-License.txt").Length, 18324L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Serf-License.txt").Length, 11562L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Cyrus-Sasl-License.txt").Length, 1865L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\OpenSsl-License.txt").Length, 6288L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Apr-License.txt").Length, 18320L);
            Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Serf-License.txt").Length, 11558L);

            // adjust file mod times
            MakeFileNewer(testSyncPath + "\\dest\\Licenses\\Cyrus-Sasl-License.txt");
            MakeFileNewer(testSyncPath + "\\dest\\Licenses\\OpenSsl-License.txt");
            MakeFileNewer(testSyncPath + "\\src\\Licenses\\Apr-License.txt");
            MakeFileNewer(testSyncPath + "\\src\\Licenses\\Serf-License.txt");
            return(testSyncPath);
        }
Esempio n. 17
0
        private static void TestSyncPreview(string sDirectory, int nThreads)
        {
            var config = GetRealConfig(sDirectory, nThreads);

            string sLogFilename = RunImplementation.GetLogFilename();

            RunImplementation.Go(config, sLogFilename, true /*preview*/, false);
            var results = CCreateSyncResultsSet.ParseFromLogFile(config, sLogFilename, true /*preview*/);

            // the number of skipped dirs is 3 instead of the 2 it used to be, but not important right now
            Utils.AssertEq("Total    Copied   Skipped  Mismatch    Failed    Extras\r\n    Dirs :         5         5         3         0         0         2\r\n   Files :        22         8        14         0         0         2\r\n   Bytes :   632.0 k   126.6 k   505.4 k         0         0    30.7 k", results.sSummary.Trim());
            File.Delete(sLogFilename);

            {
                CCreateSyncItem.SortFromColumnNumber(results.items, 3); // sort by path ascending
                var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString();

                var sGot      = String.Join("\n", resultsFilteredStrings);
                var sExpected = @"Create		\Images\a.png
Create		\Images\addir\a.PNG
Delete		\Images\new.png
Delete		\Images\remdir\c.png
Create		\Licenses\.weirdext
Update		\Licenses\Apr-License.txt
Update()		\Licenses\Cyrus-Sasl-License.txt
Create		\Licenses\noext
Update()		\Licenses\OpenSsl-License.txt
Update		\Licenses\Serf-License.txt"    .Replace("\r\n", "\n");
                Utils.AssertEq(sExpected, sGot);
            }

            {
                CCreateSyncItem.SortFromColumnNumber(results.items, -3); // sort by path descending
                var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString();

                var sGot      = String.Join("\n", resultsFilteredStrings);
                var sExpected = @"Update		\Licenses\Serf-License.txt
Update()		\Licenses\OpenSsl-License.txt
Create		\Licenses\noext
Update()		\Licenses\Cyrus-Sasl-License.txt
Update		\Licenses\Apr-License.txt
Create		\Licenses\.weirdext
Delete		\Images\remdir\c.png
Delete		\Images\new.png
Create		\Images\addir\a.PNG
Create		\Images\a.png"    .Replace("\r\n", "\n");
                Utils.AssertEq(sExpected, sGot);
            }

            {
                CCreateSyncItem.SortFromColumnNumber(results.items, 1); // sort by type where Update() != Update
                var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString();

                var sGot      = String.Join("\n", resultsFilteredStrings);
                var sExpected = @"Create		\Images\a.png
Create		\Images\addir\a.PNG
Create		\Licenses\.weirdext
Create		\Licenses\noext
Delete		\Images\new.png
Delete		\Images\remdir\c.png
Update		\Licenses\Apr-License.txt
Update		\Licenses\Serf-License.txt
Update()		\Licenses\Cyrus-Sasl-License.txt
Update()		\Licenses\OpenSsl-License.txt"        .Replace("\r\n", "\n");
                Utils.AssertEq(sExpected, sGot);
            }

            {
                CCreateSyncItem.SortFromColumnNumber(results.items, 2); // sort by type where Update() == Update
                var resultsFilteredStrings = from item in results.items where item.status != CCreateSyncItemStatus.Unknown select item.ToString();

                var sGot      = String.Join("\n", resultsFilteredStrings);
                var sExpected = @"Create		\Images\a.png
Create		\Images\addir\a.PNG
Create		\Licenses\.weirdext
Create		\Licenses\noext
Delete		\Images\new.png
Delete		\Images\remdir\c.png
Update		\Licenses\Apr-License.txt
Update()		\Licenses\Cyrus-Sasl-License.txt
Update()		\Licenses\OpenSsl-License.txt
Update		\Licenses\Serf-License.txt"    .Replace("\r\n", "\n");
                Utils.AssertEq(sExpected, sGot);
            }
        }