如何在每个文件的修订版之间创建补丁?

时间:2009-06-23 14:57:01

标签: svn

我有一个subversion存储库,它有8个修订版,在7到8之间有很多很多变化。如何为7到8之间的变化创建每个文件的补丁文件?

I.E。,不是一个庞大的补丁文件,但如果x.php发生变化并且y.php发生了变化,我想要一个x.php补丁文件和y.php

这可能吗?我该怎么办?

3 个答案:

答案 0 :(得分:2)

你需要某种脚本来获取文件名列表并为每个文件名请求补丁,或者请求“大量”补丁并将其拆分为---行......

答案 1 :(得分:0)

我知道可以使用InstallShield等工具。 InstallShield会找出两个版本之间的差异,并写出仅包含差异的补丁程序安装程序。因此,好像这是安装程序创建工具的属性。

答案 2 :(得分:0)

这是一个简单的winforms应用程序,它将在C#中完成拆分。它需要三个按钮:btnInbtnFolderbtnSplit和两个标签,lblInlblFolder

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PatchSplitter {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void btnIn_Click(object sender, EventArgs e) {
            OpenFileDialog ofd = new OpenFileDialog();

            if(ofd.ShowDialog() == DialogResult.OK) {
                lblIn.Text = ofd.FileName;
                if(lblIn.Text != "" && lblFolder.Text != "") {
                    btnSplit.Enabled = true;
                } else {
                    btnSplit.Enabled = false;
                }
            }
        }

        private void btnFolder_Click(object sender, EventArgs e) {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if(fbd.ShowDialog() == DialogResult.OK) {
                lblFolder.Text = fbd.SelectedPath;
                if (lblIn.Text != "" && lblFolder.Text != "") {
                    btnSplit.Enabled = true;
                } else {
                    btnSplit.Enabled = false;
                }
            }
        }

        private void btnSplit_Click(object sender, EventArgs e) {
            string file = "";
            string line;
            StreamWriter current = null;

            StreamReader input = new StreamReader(lblIn.Text);
            while ((line = input.ReadLine()) != null) {
                if (line.StartsWith("Index: ")) {
                    if (current != null) {
                        current.Close();
                    }
                    file = line.Remove(0, 7);
                    string directory;
                    if (file.LastIndexOf('/') == -1) {
                        directory = "";
                    } else {
                        directory = file.Substring(0, file.LastIndexOf('/'));
                    }
                    if (!Directory.Exists(lblFolder.Text + "\\" + directory)) {
                        Directory.CreateDirectory(lblFolder.Text + "\\" + directory);
                    }
                    current = new StreamWriter(new FileStream(lblFolder.Text + "\\" + file + ".patch", FileMode.Create));
                    current.WriteLine(line);
                } else {
                    if (current != null) {
                        current.WriteLine(line);
                    }
                }
            }
            current.Close();
            MessageBox.Show("Done");
        }
    }
}
相关问题