Subversion pre-commit hook filtering unwanted files (most generated by quartus & nios)

518 Views Asked by At

I wonder if there's any way the pre-commit hook used in svnserve can "filter" files based on a list of extensions. I have prepared the list which is similar to the global ignore list as in "%APPDATA%/subversion/config" with my own added patterns such as *.cdf *.sof *.elf for Quartus and Nios projects. Our primary objective is to save space by filtering out unnecessary files during commit, i.e. not to be displayed by "svn status"

I have done a lot of searches on Google but couldn't find any satisfying solution. One of the approaches I currently have is to write a windows batch file to automatically enable and replace the global ignore list on the subversion client side with my own list. The problem is obvious: it only works on a single client. If I want to enforce this filtering globally, every single client using the repository must execute my batch file. Not to mention that not everyone uses windows platform.

The next approach I have found was to modify the svn:ignore property recursively so that each pattern can be ignored globally. Again, this method requires client-side operations and it's non-trivial to maintain - it only applies to current directories in the repository. In other words, if I import a new directory, the ignore list won't apply to it.

I did write a pre-commit hook in python but it merely checks the length of the log messages and the size of the files being committed. From my understanding, pre-commit hooks are not supposed to make any modifications to the transaction because otherwise the working cache on the client side will be inconsistent and unusable, which is comprehensible. The hook does two things:

  1. REJECT the commit if any check fails with an (exit 1) code

  2. ACCEPT the commit so the transaction becomes a revision of the repository

What I initially thought was to reject the commit if any file within this transaction needs to be filtered. But my colleagues said it would be tedious to manage that many files on their own, besides they have no clue which file extensions are not required to rebuild the project.

I still sense there must be a way to automate the process of filtering without involving client-side operations. What's on my mind right now are two possible pre-commit hooks:

  1. Reject the commit, modify new added project property to ignore specific patterns (as in svn:ignore)

  2. Accept the commit, ignore unwanted file transaction, informing the user which files have been ignored, manage to get the working cache on the client-side to be consistent with the repository.

I would prefer option 2 though it looks a lot harder than option 1

In addition, please suggest which files should be put under version specifically for Quartus II and Nios projects, i.e. the whole project can be rebuilt immediately after checking out these files. The currently list I have is: .vhd .v .qpf .qsf .bsf

0

There are 0 best solutions below