second version attached.

I've changed the git stuff to use fetch, and only pull if a push fails.
I also updated make_docs_externals to ignore non-svn repos, and fixed some 
silly errors that uncovered.

remaining issues:
-it still aborts if checkout fails; I need to rewrite findfiles so that modules 
can be skipped if htey cause trouble.
-some reorganization to get the .desktop commits done sooner would be nice.
-someone needs to decide whether SVN_SILENT will still be called SVN_SILENT in 
git. :)

-- 
This message brought to you by eevil bananas and the number 3.
www.chani3.com

Index: update_translations
===================================================================
--- update_translations	(revision 965379)
+++ update_translations	(working copy)
@@ -47,45 +47,97 @@
   test -z "$TIMING1" || date
 
   for i in qt-copy $releases l10n; do
-    test -z "$NOUPDATE" || continue
+    vcs=`get_vcs $i`
+    if test -z "$NOUPDATE"; then
+      if test "$vcs" = git; then
+        branch=`get_git_branch $i`
+        i=`get_path $i`
+        git checkout $SVNQUIETFLAG $branch || echo "WARNING: failed to switch to $branch in $i, Bad Things may happen"
+      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)
+          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!"
+          exit 1
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          ;;
+      esac
     fi
   
     if cd $i; then
+      if test "$vcs" = "git"; then
+        git fetch
+        branch=`get_git_branch $modname`
+        if ! git branch | cut -c3- | grep -q "^$branch$"; then
+          git branch --track $branch origin/$branch
+        fi
+      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
+          git reset --hard $SVNQUIETFLAG origin
+          ;;
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          ;;
+      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 checkout $SVNQUIETFLAG $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
+          git pull $SVNQUIETFLAG || echo "ERROR: module $i was not correctly updated"
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          ;;
+      esac
       cd $BASEDIR
     else
       echo "ERROR: could not enter directory $i ! The module's update is SKIPPED!"
@@ -116,7 +168,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 +180,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 +188,40 @@
       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`
   
-      (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?
+          git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (after extraction)"
+	  git push #don't care if this fails, we'll deal with it on the second push
+        *)
+          echo "ERROR: unexpected VCS type?!"
+          ;;
+      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,10 +240,10 @@
             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
@@ -374,15 +438,32 @@
     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`
+        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)
+            git commit -a $SVNQUIETFLAG -m "SVN_SILENT made messages (.desktop file)"
+            if ! git push > /dev/null; then
+              echo "Need to update $i"
+              git pull $SVNQUIETFLAG
+              if ! git push; then
+                echo "ERROR: commiting .desktop files failed for module $i!"
+                git reset --hard $SVNQUIETFLAG origin
+              fi
+            fi
+          *)
+            echo "ERROR: unexpected VCS type?!"
+            ;;
+        esac
       fi
     done
   else
Index: get_paths
===================================================================
--- get_paths	(revision 965379)
+++ get_paths	(working copy)
@@ -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
@@ -45,6 +45,9 @@
 		phonon)
 			echo trunk/kdesupport/phonon
 			;;
+		git-test)
+			echo git/git-test
+			;;
 		*)
 			echo "ERROR: unknown module $1"
 			exit 1
@@ -63,3 +66,37 @@
 			;;
 	esac
 }
+
+function get_vcs
+{
+	case "$1" in
+		git-test)
+			echo git
+			;;
+		*)
+			echo svn
+			;;
+	esac
+}
+
+#TODO pick a naming scheme
+function get_git_branch
+{
+	echo "master"
+}
+
+#TODO give scripty permission to push/pull the repo
+function get_url
+{
+	case "$1" in
+		git-test)
+			echo "[email protected]:scripty-with-git/git-test.git"
+			;;
+		*)
+			echo "ERROR: $1 is not a git repo"
+			exit 1
+			;;
+	esac
+}
+
+
Index: extract-messages.sh
===================================================================
--- extract-messages.sh	(revision 965379)
+++ extract-messages.sh	(working copy)
@@ -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
Index: make_docs_externals
===================================================================
--- make_docs_externals	(revision 965379)
+++ make_docs_externals	(working copy)
@@ -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"`
 

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Kde-scm-interest mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-scm-interest

Reply via email to