Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

This page shows how to extract one version back from svn on given file.

  1. The scripts gets a file name. It uses the command svn log to extract one version back, and overwrites the file with this version.
    On a tcsh, I use the following command to run the script on a list of files:

    1. cat ~/my_txt/my_svn_log.txt | xargs -n1 | xargs -t -i= ~/bin/svn_one_ver_back.unx =

  2. The script is shown below:

    1. #!/bin/bash

    2. #\.\/\([a-zA-Z].*\) r[0-9]* .*
    3. svn_ver=`svn log $1 | grep "^r[0-9]* " | head -2 | tail -1 | perl -e 'while (<STDIN>) {$t=index($_, " ");$s=substr($_, 0, $t);print("$s\n");};'`
    4. svn cat -r $svn_ver $1 > $1

  3. Note, that bash script calls perl in one line command invocation.


  4. Now suppose you want to change reveisions listed in a given file. This file contains the target files and their new revisions. In my case the file was created by the following script.
    The output of this script looks like:

    1. Tue Nov 6 09:39:52 IST 2012
    2. ./main_data/Clib/init.c r2 | dkuku | 2012-06-25 16:21:34 +0300 (Mon, 25 Jun 2012) | 1 line
    3. ./main_data/Clib/dbg_cmd.c r2 | dkuku | 2012-06-25 16:21:34 +0300 (Mon, 25 Jun 2012) | 1 line
    4. ...

    My idea is to take each line from the file, extract its name and version and update. This can be achieved by the following script:
    1. #!/bin/bash

    2. #restores to tag
    3. #~/bin/svn_tag.unx ~/restricted/my_svn_log_24779.txt
    4. OIFS="$IFS" #see below on IFS
    5. IFS=$'\n'

    6. for li in `cat $1 | grep " r[0-9]* "`; do
    7.   svn_ver=`echo $li | perl -e 'while (<STDIN>) {$t=index($_, " r");$s=substr($_, $t);$t=index($s, " |");$s=substr($s, 0, $t);print("$s\n");};'`
    8.   f=`echo $li | perl -e 'while (<STDIN>) {$t=index($_, " r");$s=substr($_, 0, $t);print("$s\n");};'`
    9.   
    10.   echo "file: "$svn_ver" version: "$f
    11.   svn cat -r $svn_ver $f > $f
    12. done

    13. IFS="$OIFS"

    Note that the bash scripts calls perl to extract some fields.

  ...


Home

How to change the default bash internal field space separator.

A simple c-code program to read a memory array from verilog RTL, using VPI.






Search This Site


Feedback This Site




new pages on this site