+ Reply to Thread
Results 1 to 5 of 5

Thread: Recreating old versions of documents using stored diffs

  1. #1
    arunproff is offline x10Hosting Member arunproff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    9

    Recreating old versions of documents using stored diffs

    hi,
    i'm trying to build a simple wiki using Python (yes I know there are a couple out there). I also want to track document history. But instead of saving each revision of the document, I thought it might consume less space by just storing the diff for each version compared to the more current version.

    I have found a python library for calculating the diff between document versions, but can't seem to find anything for reconstructing an old version using the diffs and the current version of the document.

    Has anyone come across a library (pure python preferrably) that can do this? Or have a simple algorithm they can post that can do this?

    thanks,
    arun

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Recreating old versions of documents using stored diffs

    The way to do it from the command line is `patch`, so perhaps python-patch is the way to do it in python.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    arunproff is offline x10Hosting Member arunproff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    9

    Re: Recreating old versions of documents using stored diffs

    doh, i was searching for everything but patch.

    thanks misson!

  4. #4
    Mr. DOS is offline x10 Sophmore Mr. DOS is an unknown quantity at this point
    Join Date
    Oct 2009
    Location
    Nova Scotia, Canada
    Posts
    228

    Re: Recreating old versions of documents using stored diffs

    I would be very careful about just storing the complete original version and then diffs from there on up. If you do incremental diffs (i.e., rev 1 -> rev 2 -> rev 3) then you're going to have to rebuild the entire document from the first revision every time it's called, and if you only diff between the changes and the original, the diffs are probably going to end up being very large. Look into how subversion handles diffs; I believe it keeps a full copy of the most recent revision, then uses backward incremental diffs when the user requests old versions.

    --- Mr. DOS
    I've written a couple articles on automatic application of AlphaImageLoader in IE6 using nothing but IE6-specific CSS rules.

  5. #5
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: Recreating old versions of documents using stored diffs

    My proposition would be to use both complete copies and incremental diffs. For instance, each 50 copies, a complete version is saved, and diffs are used in between. This would shorten the amount of time needed to recover an old diff.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers