Пример #1
0
        /// <summary>Apply multiple patches.</summary>
        /// <param name="patchSources">Patch sources.</param>
        /// <param name="applyTo">Patch target.</param>
        /// <param name="reverse">Reverse patches.</param>
        public void ApplyPatches(IEnumerable <IPatchSource> patchSources, ApplyPatchTo applyTo, bool reverse)
        {
            Verify.Argument.IsNotNull(patchSources, "patchSources");

            var files = new List <IPatchFile>();

            using (Repository.Monitor.BlockNotifications(
                       RepositoryNotifications.IndexUpdated,
                       RepositoryNotifications.WorktreeUpdated))
            {
                try
                {
                    foreach (var patchSource in patchSources)
                    {
                        files.Add(patchSource.PreparePatchFile());
                    }
                    if (files.Count != 0)
                    {
                        var fileNames = new string[files.Count];
                        for (int i = 0; i < fileNames.Length; ++i)
                        {
                            fileNames[i] = files[i].FileName;
                        }
                        Repository.Accessor.ApplyPatch.Invoke(
                            new ApplyPatchParameters()
                        {
                            Patches = fileNames,
                            ApplyTo = applyTo,
                            Reverse = reverse,
                        });
                    }
                }
                finally
                {
                    foreach (var patchFile in files)
                    {
                        patchFile.Dispose();
                    }
                }
            }
            Refresh();
        }
Пример #2
0
        /// <summary>Apply patch.</summary>
        /// <param name="patchSource">Patch source.</param>
        /// <param name="applyTo">Patch target.</param>
        /// <param name="reverse">Reverse patches.</param>
        public void ApplyPatch(IPatchSource patchSource, ApplyPatchTo applyTo, bool reverse)
        {
            Verify.Argument.IsNotNull(patchSource, "patchSource");

            using (Repository.Monitor.BlockNotifications(
                       RepositoryNotifications.IndexUpdated,
                       RepositoryNotifications.WorktreeUpdated))
            {
                using (var patch = patchSource.PreparePatchFile())
                {
                    Repository.Accessor.ApplyPatch.Invoke(
                        new ApplyPatchParameters()
                    {
                        Patches = new[] { patch.FileName },
                        ApplyTo = applyTo,
                        Reverse = reverse,
                    });
                }
            }
            Refresh();
        }
Пример #3
0
        /// <summary>Apply multiple patches.</summary>
        /// <param name="patchSources">Patch sources.</param>
        /// <param name="applyTo">Patch target.</param>
        /// <param name="reverse">Reverse patches.</param>
        public void ApplyPatches(IEnumerable<IPatchSource> patchSources, ApplyPatchTo applyTo, bool reverse)
        {
            Verify.Argument.IsNotNull(patchSources, "patchSources");

            var files = new List<IPatchFile>();
            using(Repository.Monitor.BlockNotifications(
                RepositoryNotifications.IndexUpdated,
                RepositoryNotifications.WorktreeUpdated))
            {
                try
                {
                    foreach(var patchSource in patchSources)
                    {
                        files.Add(patchSource.PreparePatchFile());
                    }
                    if(files.Count != 0)
                    {
                        var fileNames = new string[files.Count];
                        for(int i = 0; i < fileNames.Length; ++i)
                        {
                            fileNames[i] = files[i].FileName;
                        }
                        Repository.Accessor.ApplyPatch.Invoke(
                            new ApplyPatchParameters()
                            {
                                Patches = fileNames,
                                ApplyTo = applyTo,
                                Reverse = reverse,
                            });
                    }
                }
                finally
                {
                    foreach(var patchFile in files)
                    {
                        patchFile.Dispose();
                    }
                }
            }
            Refresh();
        }
Пример #4
0
        /// <summary>Apply patch.</summary>
        /// <param name="patchSource">Patch source.</param>
        /// <param name="applyTo">Patch target.</param>
        /// <param name="reverse">Reverse patches.</param>
        public void ApplyPatch(IPatchSource patchSource, ApplyPatchTo applyTo, bool reverse)
        {
            Verify.Argument.IsNotNull(patchSource, "patchSource");

            using(Repository.Monitor.BlockNotifications(
                RepositoryNotifications.IndexUpdated,
                RepositoryNotifications.WorktreeUpdated))
            {
                using(var patch = patchSource.PreparePatchFile())
                {
                    Repository.Accessor.ApplyPatch.Invoke(
                        new ApplyPatchParameters()
                        {
                            Patches = new[] { patch.FileName },
                            ApplyTo = applyTo,
                            Reverse = reverse,
                        });
                }
            }
            Refresh();
        }