tags:

views:

159

answers:

3

I have a subversion repository, and it has 8 revisions in it with many, many changes between 7 and 8. How can I create patch files, per file, for the changes between 7 and 8?

I.E., not one massive patch file, but if x.php changed and y.php changed, I'd want a patch file for x.php and y.php

Is this possible? How can I do it?

A: 

I know it is possible with tools like InstallShield. InstallShield finds out what your differences are between the two versions, and writes out a patch installer containing only the differences. So it seems as if this is a property of your installer creation tool.

Robert Harvey
+2  A: 

you will need some kind of scripting to either get the list of filenames and request a patch for each one, or request a "massive" patch and split it at the --- lines...

mihi
I scripted it, I'll be posting an answer with the source. I'll accept yours as the answer
Malfist
A: 

This is a simple winforms application that will split it, done in C#. It needs three buttons: btnIn, btnFolder, btnSplit and two labels, lblIn, lblFolder.

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");
        }
    }
}
Malfist