2

I have a project where I need to maintain changes to both the text and binary files. I have a couple of options:

  1. Use patches
  2. Use a versioning system like git or hg.

For my purposes, patches are a better option if it was only text files. However, since there are images that might be replaced/added/deleted, which is the best way to go?

Is there a clean diff/patch utility that can take care of binary differences as well (without me having to specify it is binary -- I should be able to diff the entire directory and not individual files, which I can't with bash's diff in binary mode) and use them as patches? If not, which versioning system is a cleaner option when it comes to binary files?

Vanwaril
  • 7,380
  • 6
  • 33
  • 47

3 Answers3

3

Both Git and Mercurial can easily handle both text and binary files. Use whichever you prefer. And yes, a VCS is the right choice.

Amber
  • 507,862
  • 82
  • 626
  • 550
  • VCS makes managing this a lot more complicated, believe it or not. For my purposes, its a lot cleaner if everything can be done in terms of some kind of patches and the patches are maintained in a repository. – Vanwaril Feb 17 '11 at 07:12
  • A VCS is nothing else than a tool around such a repository containing patches. – khmarbaise Feb 17 '11 at 07:35
  • @Vanwaril: It sounds like what you might be looking for is a patch queue? If so, there are projects that implement patch queues on top of both Mercurial and Git. For Mercurial, see `hg mq`, for Git, see https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Patch-management_Interface_layers – Amber Feb 17 '11 at 07:41
  • @khmarbaise: A VCS takes care of applying them for you. The problem is that this is for Wordpress, where there are updates outside of my system, and the patches need to be reapplied on top of the updates. To do this with a VCS requires a complicated rollback --> branch --> wordpress update --> merge procedure. – Vanwaril Feb 17 '11 at 07:50
  • @Amber: hg mq looks good, but it maintains linear patches -- my patches are distinct ones -- you can think of it as something maintained by multiple series files. With git, I'm not sure stgit handles binary very well. :( – Vanwaril Feb 17 '11 at 08:04
  • You need patch files? Every good VCS can make them for you (`hg diff`, `git diff` even `cvs diff` but the latter don't mangage binaries). You need multiple patch series? It's named a branch in VCS. Really, go for VCS. – shellholic Feb 17 '11 at 09:02
  • @shellholic: you don't seem to understand. When I update a component (it overwrites manual changes in that component), all I need to do is re-run a patch specific to the updated component. If normal diffs worked for binaries, this is the perfect solution. A branch in VCS does not solve the problem without making it extremely complicated. – Vanwaril Feb 17 '11 at 09:11
  • 1
    Mercurial and Git can make binary patches. – shellholic Feb 17 '11 at 09:17
  • 1
    @Vanwaril: hg mq can handle different patch queues (have a look at http://stevelosh.com/blog/2010/08/a-git-users-guide-to-mercurial-queues/#multiple-patch-queues ). More over you can easily change the patch order as long as they are really independent. – gizmo Feb 17 '11 at 09:24
  • @gizmo: perfect! can you post a clean answer so I can accept it, in case others have the same query? – Vanwaril Feb 17 '11 at 09:52
  • The entire point of any patch queue is to let you reorder (or add/remove independently) various patches. – Amber Feb 17 '11 at 18:19
3

Mercurial has the notion of patch queue (with the mq extension enabled), largely inspired by quilt.
This allows you to manage your patches in several ways:

  • Use a single patch queue and have all your patch order sequentially in it
  • Use several patch queues, with the qqueue command, and have patches grouped by whatever criteria fits you.

As a bonus, as patches queues are really patch files, you can easily change their order and even move/copy them from one queue to another (have a look in your .hg directory to find the patch queues).

You can find a lot more of usefull information about managing patch queues at Steve Losh's tutorial on mercurial queue.

gizmo
  • 11,819
  • 6
  • 44
  • 61
0

If you don't like a VCS as such, try using a ftp server containing patches. Version numbers can be used as directory names. This system can be backed with a script, which applies patches sequentially based on directory names.

In the project I'm working on, database patches are applied in this manner. However, they are maintained inside a VCS. A file can be used to maintain the current version, which will be read by the script to decide which patch to apply.