Search code examples
shellcvsmd5sum

get md5sum of all the version of a file in CVS


I have a CVS server which has around 50 version of a file. I want to get md5sum of all the versions. of course one way would be to revert to all version and get their md5sum but I am looking for a less painful method.


Solution

  • Assuming a GNU/Linux or similar environment, the following dump of a shell session illustrates a potential solution. As CVS stores the files internally as diffs that must be processed to reconstruct the revisions, there really is no "less painful" method, but certainly some of the pain can be removed by using a script:

    First, make sure the file has no local modifications:

    $ FILE=FileToSum
    $ cvs -nq update ${FILE}
    

    Next, generate a list of all revisions of the file, iterate over them, checkout each revision, collect MD5 sums, then clear the sticky version from the work space to clean up.

    $ cvs log -NS "${FILE}" \
    > | awk '/^revision:/ { print $2 }' - \
    > | while read revision; \
    >   do \
    >     echo -en "revision: ${revision}\n  "; \
    >     cvs update -r ${revision} "${FILE}" >/dev/null 2>&1; \
    >     md5sum "${FILE}"; \
    >   done >md5sums; \
    > cvs update -A ${FILE}
    

    The output looks like this:

    $ cat md5sums
    revision: 1.17
      4e70589a177f688a3bf29a3843b840dd  FileToSum
    revision: 1.16
      e9663f204cbc440235db7918e0be0a6a  FileToSum
    revision: 1.15
    .
    .
    .