Question

We are in the process of migrating from PVCS to Subversion. I have demoed a PVCS export => SVN import that does the job quite nicely for us but we have one issue.

We have made extensive use of PVCS labels and these give us a clear and consistent link to our Work Request numbers (W.R.). When we migrate to SVN these labels become tags (which in itself is fine) BUT we're also implementing JIRA and so need to link the appropriate SVN version to a JIRA issue number. This is done by writing the JIRA issue number into the SVN log message.

So far; at SVN Import time I am reading each SVN log message and where I find a work request number I append the appropriate JIRA issue number to the SVN log message (using a post-commit script in SVN). However the practice of writing the W.R. into the PVCS commit description has been optional whereas the use of PVCS labels has been mandatory. Therefore many of the versions do not have a W.R. number in the log, only in the PVCS label (or as it becomes SVN Tag).

Is there any way I can find the PVCS version label during the SVN import? I can see them in the dump file created by the PVCS export where they become a part of the Node-path.

Or alternately is there a report or query I can run that will give me a list of revisions for each tag?

Regards Karl

Was it helpful?

Solution

I ended up sorting this myself. If anyone else has the same problem, I found that it was possible to get a list of all tags using

svn ls <repo URL including tags location>

and then get the versions in those tags using

svn info ...

And AWK the SVN INFO output using the following. Note I had to decrement the version number by 1 to get the actual version I was interested in. I think this is because during the import SVN copies the approriate version to the tag folder after creating the version and this is considered a version.

BEGIN { RS="";
    FS = "\n"; }
/^Path:/ { n1 = split($1,path,":");
           n3 = split($6,nodeKind, ":");
           n2 = split($9,lastRev,":");
           theRev = lastRev[2] -1;
printf("%8s %10s, %-75s\n", theRev, nodeKind[2], path[2]); }

WRKEYFILE and PTKEYFILE are just .csv lookup files to match against with a format of

PT_TICKET,PKEY,Issue Title

Then I wrote a script as follows ...

REPO=svn://vuwunicocsagfg1/Banner/tags
REPOPATH=/var/subversion/Banner
WRKEYFILE=workReq_pKey.unix
PTKEYFILE=ptTicket_pKey.unix

# working variables
TEMPFILE=$$.tmp
TAGLIST=$$.tags
REVISIONS=$$.revisions
SVNINFO=$$.info
SVNLOOK=/usr/bin/svnlook


# look up details in Subversion
svn info -R $REPO | awk -f new_svn_report.awk > $SVNINFO
svn ls $REPO > $TAGLIST

cat $TAGLIST | awk '{ print $1}' | while read LINE
do

   JIRAISSUE=""
   WRNUM=""
   PTNUM=""
   UWRNUM=""
   UPTNUM=""

   # Find Work Request or Perfect Tracker number
   WRNUM=$(echo "$LINE" | sed -n -e "s:.*\([wW][rR][0-9# -][0-9]\+\).*:\1:p")
   PTNUM=$(echo "$LINE" | sed -n -e "s:.*\([pP][tT][0-9# -][0-9]\+\).*:\1:p")

   # upper case the strings found and remove unwanted chars
   UWRNUM=`echo $WRNUM| tr 'a-z' 'A-Z' | tr --delete '# -'`
   UPTNUM=`echo $PTNUM| tr 'a-z' 'A-Z' | tr --delete '# -'`
   # Debug
   # echo "=============================="
   # echo "Line is: $LINE,  WRNUM is: $WRNUM, PTNUM is: $PTNUM"

   if [[ -n "$UWRNUM" ]]
   then

      # Find the JIRA issue number
      awk -F',' '/'"$UWRNUM"'/ {print $2}' $WRKEYFILE | awk '{if (NR==1) {print $0}}'  > $TEMPFILE
      JIRAISSUE=`cat $TEMPFILE`

      awk -F',' '/'"$UWRNUM"'/ {print $2,"; " $3}' $WRKEYFILE | tr '"' '_' | awk '{if (NR==1) {print $0}}' > $TEMPFILE
      NEWLOG=`cat $TEMPFILE`

      # all revisions in this Tag which are not directories
      grep $UWRNUM $SVNINFO | grep -v "directory" > $REVISIONS
   fi

   if [[ -n "$UPTNUM" ]]
   then
      # Find the JIRA issue number
      awk -F',' '/'"$UPTNUM"'/ {print $2}' $PTKEYFILE | awk '{if (NR==1) {print $0}}'  > $TEMPFILE
      JIRAISSUE=`cat $TEMPFILE`

      awk -F',' '/'"$UPTNUM"'/ {print $2,"; " $3}' $PTKEYFILE | tr '"' '_' | awk '{if (NR==1) {print $0}}' > $TEMPFILE
      NEWLOG=`cat $TEMPFILE`

      # all revisions in this Tag which are not directories
      grep $UPTNUM $SVNINFO | grep -v "directory" > $REVISIONS
   fi

   if [[ -n "$JIRAISSUE"  ]]
   then
      cat $REVISIONS | awk '{ print $1}' | while read REVLINE
      do

         $SVNLOOK log -r "$REVLINE" "$REPOPATH" | tr '"' '_' > $TEMPFILE
         OLDLOG=`cat $TEMPFILE `

         if `echo $OLDLOG | grep "$JIRAISSUE" 1>/dev/null 2>&1`
         then
            LOGMSG=$OLDLOG
         else
            LOGMSG="$OLDLOG  $NEWLOG"
         fi
        # Debug
         # echo "Jira issue is: $JIRAISSUE"
         # echo "update the log message for Revision $REVLINE"
         # echo "New log message is: $LOGMSG"
         # echo "***********************************"

         echo "svn propset --revprop -r "$REVLINE" svn:log \""$LOGMSG"\" $REPO"
         svn propset --revprop -r "$REVLINE" svn:log \""$LOGMSG"\" $REPO
         echo ""

       done
   fi
done
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top