[Kde-scm-interest] l10n-kde4/scripts

Chani Armitage chanika at gmail.com
Fri Jun 5 21:16:32 CEST 2009


SVN commit 977987 by chani:

git support for scripty!
-qt is using the git repo now, so we're prepared for qt-copy leaving
-there's a git-test repo in here which translators should IGNORE. if nothing explodes it'll be removed after some tests are done.
-all the $transmod stuff is still svn-only.
CCMAIL:kde-scm-interest at kde.org


 M  +2 -1      extract-messages.sh  
 M  +55 -2     get_paths  
 M  +7 -2      make_docs_externals  
 M  +155 -52   update_translations  


--- trunk/l10n-kde4/scripts/extract-messages.sh #977986:977987
@@ -9,6 +9,7 @@
 PREPARETIPS=${PREPARETIPS:-preparetips}
 REPACKPOT=${REPACKPOT:-repack-pot.pl}
 export EXTRACTRC EXTRACTATTR PREPARETIPS REPACKPOT
+IGNORE=${IGNORE:-.svn}
 
 for subdir in $dirs; do
   # skip Messages.sh files of KDevelop's app templates
@@ -17,7 +18,7 @@
   test -z "$VERBOSE" || echo "Making messages in $subdir"
   (cd $subdir
    ls -1 *.rc *.ui *.ui3 *.ui4 *.kcfg 2> /dev/null | xargs --no-run-if-empty $EXTRACTRC > rc.cpp
-   if find . -name \*.c\* -o -name \*.h\* | fgrep -v ".svn" | xargs fgrep -s -q KAboutData ; then
+   if find . -name \*.c\* -o -name \*.h\* | fgrep -v "$IGNORE" | xargs fgrep -s -q KAboutData ; then
 	echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> rc.cpp
 	echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> rc.cpp
    fi
--- trunk/l10n-kde4/scripts/get_paths #977986:977987
@@ -6,7 +6,7 @@
 
 function list_modules 
 {
-   echo kdelibs kdebase kdegames kdesdk kdegraphics kdeutils kdenetwork kdemultimedia kdeadmin kdetoys kdevplatform kdevelop kdepimlibs kdepim kdeartwork kdeedu kdeaccessibility kdeplasma-addons kdewebdev koffice kdereview extragear-sdk extragear-sysadmin extragear-graphics extragear-multimedia extragear-network extragear-security extragear-utils extragear-base extragear-pim extragear-office extragear-libs playground-accessibility playground-artwork playground-base playground-devtools playground-edu playground-games playground-graphics playground-ioslaves playground-libs playground-multimedia playground-network playground-pim playground-sysadmin playground-utils playground-office phonon
+   echo kdelibs kdebase kdegames kdesdk kdegraphics kdeutils kdenetwork kdemultimedia kdeadmin kdetoys kdevplatform kdevelop kdepimlibs kdepim kdeartwork kdeedu kdeaccessibility kdeplasma-addons kdewebdev koffice kdereview extragear-sdk extragear-sysadmin extragear-graphics extragear-multimedia extragear-network extragear-security extragear-utils extragear-base extragear-pim extragear-office extragear-libs playground-accessibility playground-artwork playground-base playground-devtools playground-edu playground-games playground-graphics playground-ioslaves playground-libs playground-multimedia playground-network playground-pim playground-sysadmin playground-utils playground-office phonon git-test
 }
 
 # List of module where only the documentation is extracted
@@ -40,11 +40,14 @@
 			echo trunk/l10n-kde4
 			;;
 		qt|qt-copy)
-			echo trunk/qt-copy
+			echo git/kde-qt
 			;;
 		phonon)
 			echo trunk/kdesupport/phonon
 			;;
+		git-test)
+			echo git/git-test
+			;;
 		*)
 			echo "ERROR: unknown module $1"
 			exit 1
@@ -63,3 +66,53 @@
 			;;
 	esac
 }
+
+function get_vcs
+{
+	case "$1" in
+		git-test)
+			echo git
+			;;
+		qt-copy)
+			echo git
+			;;
+		*)
+			echo svn
+			;;
+	esac
+}
+
+#TODO pick a naming scheme
+function get_branch
+{
+	case "$1" in
+		git-test)
+			echo "master"
+			;;
+		qt-copy)
+			echo "4.5.1-patched"
+			;;
+		*)
+			echo "ERROR: $1 is not a git repo"
+			exit 1
+			;;
+	esac
+}
+
+function get_url
+{
+	case "$1" in
+		git-test)
+			echo "git at gitorious.org:scripty-with-git/git-test.git"
+			;;
+		qt-copy)
+			echo "git://gitorious.org/+kde-developers/qt/kde-qt.git"
+			;;
+		*)
+			echo "ERROR: $1 is not a git repo"
+			exit 1
+			;;
+	esac
+}
+
+
--- trunk/l10n-kde4/scripts/make_docs_externals #977986:977987
@@ -31,10 +31,15 @@
 fi
 
 for mod in $modules; do
-   url="$baseurl/`get_path $mod`/doc"
-   add $mod $url
+   if test `get_vcs $mod` = "svn"; then
+     url="$baseurl/`get_path $mod`/doc"
+     add $mod $url
+   else
+     echo "Skipping $mod"
+   fi
 done
 
+#echo $externals
 # interpret the \n
 externals=`echo -e "$externals"`
 
--- trunk/l10n-kde4/scripts/update_translations #977986:977987
@@ -47,45 +47,99 @@
   test -z "$TIMING1" || date
 
   for i in qt-copy $releases l10n; do
-    test -z "$NOUPDATE" || continue
+    vcs=`get_vcs $i`
+    if test -n "$NOUPDATE"; then
+      if test "$vcs" = git; then
+        branch=`get_branch $i`
+        i=`get_path $i`
+        if ! (cd $i && git reset --hard $SVNQUIETFLAG origin/$branch); then
+          echo "ERROR: failed to switch to $branch in $i"
+          exit 1
+        fi
+      fi
+      continue
+    fi
     test -z "$VERBOSE1" || echo "updating $i"
   
+    modname=$i
     i=`get_path $i`
     if test ! -d $i; then
-      mkdir -p $i
-      svn co -q $SVNROOT/$i $i || echo "ERROR: checking out $i has failed!"
+      case "$vcs" in
+        svn)
+          mkdir -p $i
+          svn co -q $SVNROOT/$i $i || echo "ERROR: checking out $i has failed!"
+          ;;
+        git)
+          git clone `get_url $modname` $i || echo "ERROR: checking out $i has failed!"
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          exit 1
+          ;;
+      esac
     fi
   
     if cd $i; then
+      if test "$vcs" = "git"; then
+        git fetch
+        branch=`get_branch $modname`
+      fi
       ### TODO: perhaps we could combine cleanup/svn-clean/revert (One svn stat -u, if it fails cleanup and revert are called, otherwise only svn-cleanup is done.)
       if test -z "$NO_INITIAL_CLEANUP"; then
-      svn cleanup .
-      if test "$i" = "l10n"; then
-        svn cleanup scripts/admin
-        # Cleanup the external documentation directories of l10n
-        if cd documentation; then
-          for $docdir in *
-          do
-            svn cleanup $docdir
-          done
-          cd ..
-        else
-          echo "Could not find l10n/documentation"
-        fi
-      elif test -d admin; then
-        svn cleanup admin
-      fi
-      perl $kdebasedir/kdesdk/scripts/svn-clean -f | fgrep -v "Subversion working directory" | grep -v '^F'
-      test -z "$VERBOSE1" || echo
-      # revert all changes, so that the following "svn update" is without conflicts
-      svn revert $SVNQUIETFLAG -R .
-      if test -d admin; then
-        svn revert $SVNQUIETFLAG -R admin
-      fi
-      ### TODO: do we need to revert the external directories of l10n too? (Are we modifying them at all?)
+      case "$vcs" in
+        svn)
+          svn cleanup .
+          if test "$i" = "l10n"; then
+            svn cleanup scripts/admin
+            # Cleanup the external documentation directories of l10n
+            if cd documentation; then
+              for $docdir in *
+              do
+                svn cleanup $docdir
+              done
+              cd ..
+            else
+              echo "Could not find l10n/documentation"
+            fi
+          elif test -d admin; then
+            svn cleanup admin
+          fi
+          perl $kdebasedir/kdesdk/scripts/svn-clean -f | fgrep -v "Subversion working directory" | grep -v '^F'
+          test -z "$VERBOSE1" || echo
+          # revert all changes, so that the following "svn update" is without conflicts
+          svn revert $SVNQUIETFLAG -R .
+          if test -d admin; then
+            svn revert $SVNQUIETFLAG -R admin
+          fi
+          ### TODO: do we need to revert the external directories of l10n too? (Are we modifying them at all?)
+          ;;
+        git)
+          git clean -dfx $SVNQUIETFLAG
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          exit 1
+          ;;
+      esac
       fi # test -z $NO_INITIAL_CLEANUP
+
       test -z "$VERBOSE1" || echo
-      svn update $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+      case "$vcs" in
+        svn)
+          svn update $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+          ;;
+        git)
+          if ! git reset --hard $SVNQUIETFLAG origin/$branch; then
+            echo "ERROR: failed to switch to branch $branch for module $modname."
+            exit 1 #FIXME I'd rather gracefully skip this module. but how?
+	    #perhaps I could filter $releases. findfiles could be trouble though.
+          fi
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          exit 1
+          ;;
+      esac
       cd $BASEDIR
     else
       echo "ERROR: could not enter directory $i ! The module's update is SKIPPED!"
@@ -116,7 +170,7 @@
     logmod=$templatename
     mod=`get_path $templatename`
     rm -rf /tmp/cvslog.$logmod
-    if test -d $mod; then
+    if cd $BASEDIR/$mod; then
       qtonly=`qt_only $templatename`
 
       if test x"$qtonly" = x"yes"; then
@@ -128,7 +182,7 @@
           echo "creating templates directory for $templatename"
           mkdir $BASEDIR/backup/templates/messages/$templatename
           svn mkdir $templatename
-          cd $BASEDIR
+          cd $BASEDIR/$mod
         else
           echo "SKIPPING $mod - no template directory!"
 	  continue
@@ -136,28 +190,51 @@
       fi
   
       test -z "$VERBOSE1" || echo "making messages in $mod"
-      if test ! -d $mod/po; then
-        ln -s $BASEDIR/$transmod/templates/messages/$templatename $mod/po
+      if test ! -d po; then
+        ln -s $BASEDIR/$transmod/templates/messages/$templatename po
       fi
-      ls -d $mod/po
+      ls -d po
+
+      vcs=`get_vcs $logmod`
+      branch=`get_branch $logmod`
   
-      (cd $mod && XGETTEXT=`which xgettext` \
+      (           XGETTEXT=`which xgettext` \
                   EXTRACTRC="perl $extractrc --ignore-no-input" \
                   EXTRACTATTR="perl $extractattr" \
                   PREPARETIPS="perl $preparetips" \
                   REPACKPOT="perl $repackpot" \
                   PACKAGE=$mod \
+                  IGNORE=".$vcs" \
                   bash $BASEDIR/$transmod/scripts/extract-messages.sh)
-      rm -f $mod/messages.log
+      rm -f messages.log
   
-      (cd $mod && XGETTEXT=`which xgettext` \
+      (           XGETTEXT=`which xgettext` \
                   PACKAGE=$mod \
                   bash $BASEDIR/$transmod/scripts/extract-xml.sh)
-      rm -f $mod/messages.log
+      rm -f messages.log
   
-      (cd $mod &&
-        svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)" > /dev/null)
-      if cd $transmod/templates/messages/$templatename ; then
+      case "$vcs" in
+        svn)
+          svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)" > /dev/null
+          ;;
+        git)
+          #FIXME what'll the equivalent of SVN_SILENT be?
+          if git pull $SVNQUIETFLAG origin $branch; then
+            if git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)"; then
+              git push origin HEAD:$branch || echo "WARNING: commit failed in $mod"
+            else
+              echo "nothing to commit for $mod?"
+            fi
+          else
+            echo "WARNING: possible conflict in $mod"
+          fi
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          exit 1
+          ;;
+      esac
+      if cd $BASEDIR/$transmod/templates/messages/$templatename ; then
         for i in *.pot; do
           if test ! -f $i; then continue; fi
           if test ! -f $BASEDIR/backup/templates/messages/$templatename/$i ; then
@@ -176,13 +253,14 @@
             cp -f $i $BASEDIR/backup/templates/messages/$templatename/$i
           fi
         done
-        cd $BASEDIR
+        cd $BASEDIR/$mod
       fi
-      rm -rf $mod/po.backup
-      if test -L $mod/po; then rm -f $mod/po; fi
+      rm -rf po.backup
+      if test -L po; then rm -f po; fi
     fi
   
   done
+  cd $BASEDIR
   
   test -z "$VERBOSE1" || echo "extracting qt-copy"
   # As qt-copy is updated rarely (compared to other modules) and to simplify the code, we let the "late" code below do most of the work.
@@ -374,15 +452,40 @@
     test -z "$TIMING1" || date
     for i in $releases l10n; do
       if cd $BASEDIR/`get_path $i`; then
-        if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)" > /dev/null; then
-          # If the commit fails, then it means that a file was modified. Normally it will not be a .desktop file
-          echo "Need to update $i"
-          svn update $SVNQUIETFLAG
-          if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file, second try)"; then
-            echo "ERROR: commiting .desktop files failed for module $i!"
-            svn revert -R .
-          fi
-        fi
+        vcs=`get_vcs $i`
+        branch=`get_branch $i`
+        case "$vcs" in
+          svn)
+            if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)" > /dev/null; then
+              # If the commit fails, then it means that a file was modified. Normally it will not be a .desktop file
+              echo "Need to update $i"
+              svn update $SVNQUIETFLAG
+              if ! svn commit $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file, second try)"; then
+                echo "ERROR: commiting .desktop files failed for module $i!"
+                svn revert -R .
+              fi
+            fi
+            ;;
+          git)
+            if git pull $SVNQUIETFLAG origin $branch; then
+              if git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)"; then
+                if ! git push origin HEAD:$branch; then
+                  echo "ERROR: commiting .desktop files failed for module $i!"
+                  git reset --hard $SVNQUIETFLAG origin/$branch
+                fi
+              else
+                echo "nothing to commit for $i?"
+              fi
+            else
+              echo "ERROR: commiting .desktop files failed for module $i (possible conflict)"
+              git reset --hard $SVNQUIETFLAG origin/$branch
+            fi
+            ;;
+          *)
+            echo "ERROR: unexpected VCS type?!"
+            exit 1
+            ;;
+        esac
       fi
     done
   else


More information about the Kde-scm-interest mailing list