changeset 572:8a1afde74602

Refactoring: simplify names.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Thu, 08 May 2014 22:46:22 +0300
parents 5ce1dc5f661f
children d8030b06fd51
files hg/hgsyncee hg/hgsyncew
diffstat 2 files changed, 79 insertions(+), 83 deletions(-) [+]
line wrap: on
line diff
--- a/hg/hgsyncee	Thu May 08 22:24:32 2014 +0300
+++ b/hg/hgsyncee	Thu May 08 22:46:22 2014 +0300
@@ -12,14 +12,12 @@
 LOG_FILE=$UTIL_NAME.log
 
 Usage() {
-    echo Sync two etalon repo set via intermediate repo set.
+    echo Sync external repo with master set via intermediate repo set.
     echo "Usage:"
     echo "$UTIL_NAME [--help]"
     echo "  --help   print this help"
 }
 
-# Один аргумент со значением INFO или ERROR.
-# Без аргументов - как если с аргументом ERROR.
 PrintLog() {
     if [ x$1 = x ] ; then
         MSG_SIGN=ERROR
@@ -63,10 +61,10 @@
     command -v hg && return 0 || return 1
 }
 
-Set_HG_REP_CONF() {
+Set_CFG() {
     # Если есть локальный файл конфигурации репозиториев (полезно для отладки).
-    HG_REP_CONF=./hgsyncrc
-    if [ -e $HG_REP_CONF ]; then
+    CFG=./hgsyncrc
+    if [ -e $CFG ]; then
         return 0;
     fi
     # Иначе ищем по стандартному пути.
@@ -74,34 +72,34 @@
         MSG="Var HOME not set."
         return 1;
     fi
-    HG_REP_CONF=$HOME/.hgsyncrc
-    if [ -e $HG_REP_CONF ] ; then
+    CFG=$HOME/.hgsyncrc
+    if [ -e $CFG ] ; then
         return 0;
     fi
-    HG_REP_CONF=/etc/hgsyncrc
-    if [ -e $HG_REP_CONF ]; then
+    CFG=/etc/hgsyncrc
+    if [ -e $CFG ]; then
         return 0;
     fi
     MSG="Config file not found, see man page hgsyncrc(1)."
     return 1;
 }
 
-Check_HG_REP_CONF() {
-    if [ x$HG_PUSH_DIR = x ] ; then
-        MSG="HG_PUSH_DIR not set in $HG_REP_CONF"
+Check_CFG() {
+    if [ x$MASTER_DIR = x ] ; then
+        MSG="MASTER_DIR not set in $CFG"
         return 1;
     fi
-    if [ -d $HG_PUSH_DIR ] ; then :
+    if [ -d $MASTER_DIR ] ; then :
     else
-        MSG="HG_PUSH_DIR from $HG_REP_CONF point for non existing dir."
+        MSG="MASTER_DIR from $CFG point for non existing dir."
         return 1;
     fi
-    if [ x$HG_PULL_DIR = x ] ; then
-        MSG="HG_PULL_DIR not set in $HG_REP_CONF"
+    if [ x$EXTERNAL_DIR = x ] ; then
+        MSG="EXTERNAL_DIR not set in $CFG"
         return 1;
-        if [ -d $HG_PULL_DIR ] ; then :
+        if [ -d $EXTERNAL_DIR ] ; then :
         else
-            MSG="HG_PULL_DIR from $HG_REP_CONF point for non existing dir."
+            MSG="EXTERNAL_DIR from $CFG point for non existing dir."
             return 1;
         fi
     fi
@@ -140,30 +138,30 @@
     exit 1;
 fi
 
-if Set_HG_REP_CONF; then
-    . $HG_REP_CONF
+if Set_CFG; then
+    . $CFG
 else
-    PrintLog
+    PrintLog ERROR
     exit 1;
 fi
 
-if Check_HG_REP_CONF; then :
+if Check_CFG; then :
 else
-    PrintLog
+    PrintLog ERROR
     exit 1;
 fi
 
-if [ -d "$HG_PULL_DIR" ] || mkdir "$HG_PULL_DIR"; then
+if [ -d "$EXTERNAL_DIR" ] || mkdir "$EXTERNAL_DIR"; then
     :
 else
-    MSG="Can not create $HG_PULL_DIR."
-    PrintLog
+    MSG="Can not create $EXTERNAL_DIR."
+    PrintLog ERROR
     exit 1;
 fi
 
-MSG="Path to etalon repo set: $HG_PUSH_DIR"
+MSG="master dir: $MASTER_DIR"
 PrintLog INFO
-MSG="Path to intermediate repo set: $HG_PULL_DIR"
+MSG="external dir: $EXTERNAL_DIR"
 PrintLog INFO
 
 echo
@@ -175,53 +173,53 @@
     MSG="'$dir' repo."
     PrintLog PROCESSING
 
-    if [ -d $HG_PUSH_DIR/$dir/.hg ]; then
-        if [ -d $HG_PULL_DIR/$dir/.hg ] ; then
-            if CheckRepCompatibility $HG_PULL_DIR/$dir $HG_PUSH_DIR/$dir; then :
+    if [ -d $MASTER_DIR/$dir/.hg ]; then
+        if [ -d $EXTERNAL_DIR/$dir/.hg ] ; then
+            if CheckRepCompatibility $EXTERNAL_DIR/$dir $MASTER_DIR/$dir; then :
             else
-                MSG="It seems repositories $HG_PULL_DIR/$dir $HG_PUSH_DIR/$dir not compatable."
-                PrintLog
+                MSG="'$EXTERNAL_DIR/$dir' and '$MASTER_DIR/$dir' is not compatable."
+                PrintLog ERROR
                 exit 1;
             fi
-            hg -R $HG_PULL_DIR/$dir pull $HG_PUSH_DIR/$dir >>$LOG_FILE 2>&1
+            hg -R $EXTERNAL_DIR/$dir pull $MASTER_DIR/$dir >>$LOG_FILE 2>&1
         else
-            hg clone $HG_PUSH_DIR/$dir $HG_PULL_DIR/$dir >>$LOG_FILE 2>&1
+            hg clone $MASTER_DIR/$dir $EXTERNAL_DIR/$dir >>$LOG_FILE 2>&1
         fi
-        if CheckRepCompatibility $HG_PULL_DIR/$dir ./$dir; then :
+        if CheckRepCompatibility $EXTERNAL_DIR/$dir ./$dir; then :
         else
-            MSG="It seems repo '$dir' and etalon repo not compatable."
-            PrintLog
+            MSG="'$dir' and master is not compatable."
+            PrintLog ERROR
             exit 1;
         fi
-        hg -R $HG_PULL_DIR/$dir pull ./$dir >>$LOG_FILE 2>&1
+        hg -R $EXTERNAL_DIR/$dir pull ./$dir >>$LOG_FILE 2>&1
     else
-        MSG="'$dir' repo skiped. It is absent in etalon repo set."
+        MSG="'$dir' skiped. It is absent in master repo set."
         PrintLog INFO
         continue
     fi
 
-    HEAD_CNT=`hg -R $HG_PULL_DIR/$dir head | grep "changeset:" | wc -l`
+    HEAD_CNT=`hg -R $EXTERNAL_DIR/$dir head | grep "changeset:" | wc -l`
     case $HEAD_CNT in
         # Если нет необходимости мержить - изменения "правильные"
         # и должны быть возвращены как в промежуточный репозиторий,
         # так и в эталонный репозиторий.
         1)
-            CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R $HG_PULL_DIR/$dir out \
-                --template '{node}\n' $HG_PUSH_DIR/$dir | wc -l`
+            CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R $EXTERNAL_DIR/$dir out \
+                --template '{node}\n' $MASTER_DIR/$dir | wc -l`
             case $CHANGESET_CNT in
                 0) ;;
                 *)
-                    hg -R $HG_PULL_DIR/$dir push $HG_PUSH_DIR/$dir >>$LOG_FILE 2>&1
-                    MSG="==> etalon"
+                    hg -R $EXTERNAL_DIR/$dir push $MASTER_DIR/$dir >>$LOG_FILE 2>&1
+                    MSG="==> master"
                     PrintLog ADDED
                     ;;
             esac
-            CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R $HG_PULL_DIR/$dir out \
+            CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R $EXTERNAL_DIR/$dir out \
                 --template '{node}\n' ./$dir | wc -l`
             case $CHANGESET_CNT in
                 0) ;;
                 *)
-                    hg -R $HG_PULL_DIR/$dir push ./$dir >>$LOG_FILE 2>&1
+                    hg -R $EXTERNAL_DIR/$dir push ./$dir >>$LOG_FILE 2>&1
                     MSG="==> work"
                     PrintLog ADDED
                     ;;
@@ -232,9 +230,9 @@
         *)
             MSG="You must manually merge '$dir' proj and repeat run $UTIL_NAME."
             PrintLog WARNING
-            MSG="Go to $HG_PULL_DIR/$dir dir."
+            MSG="Go to $EXTERNAL_DIR/$dir dir."
             PrintLog WARNING
-            hg -R $HG_PUSH_DIR/$dir push -f ./$dir >>$LOG_FILE 2>&1
+            hg -R $MASTER_DIR/$dir push -f ./$dir >>$LOG_FILE 2>&1
             ;;
     esac
 done
--- a/hg/hgsyncew	Thu May 08 22:24:32 2014 +0300
+++ b/hg/hgsyncew	Thu May 08 22:46:22 2014 +0300
@@ -14,15 +14,13 @@
 HTTP_USED=no
 
 Usage() {
-    echo Sync working repo set with etalon repo set.
+    echo Sync work repo set with master set.
     echo "Usage:"
     echo "$UTIL_NAME [--help | --push]"
     echo "  --help    print this help"
-    echo "  --push    back changeset to etalon repo set"
+    echo "  --push    back changeset to master repo set"
 }
 
-# Один аргумент со значением INFO или ERROR.
-# Без аргументов - как если с аргументом ERROR.
 PrintLog() {
     if [ x$1 = x ] ; then
         MSG_SIGN=ERROR
@@ -66,10 +64,10 @@
     command -v hg && return 0 || return 1
 }
 
-Set_HG_REP_CONF() {
+Set_CFG() {
     # Если есть локальный файл конфигурации репозиториев (полезно для отладки).
-    HG_REP_CONF=./hgsyncrc
-    if [ -e $HG_REP_CONF ]; then
+    CFG=./hgsyncrc
+    if [ -e $CFG ]; then
         return 0;
     fi
     # Иначе ищем по стандартному пути.
@@ -77,12 +75,12 @@
         MSG="Var HOME not set."
         return 1;
     fi
-    HG_REP_CONF=$HOME/.hgsyncrc
-    if [ -e $HG_REP_CONF ] ; then
+    CFG=$HOME/.hgsyncrc
+    if [ -e $CFG ] ; then
         return 0;
     fi
-    HG_REP_CONF=/etc/hgsyncrc
-    if [ -e $HG_REP_CONF ]; then
+    CFG=/etc/hgsyncrc
+    if [ -e $CFG ]; then
         return 0;
     fi
     MSG="Config file not found, see man page hgsyncrc(1)."
@@ -90,17 +88,17 @@
 }
 
 # May set HTTP_USED to 'yes'.
-Check_HG_REP_CONF() {
-    if [ x$HG_PUSH_DIR = x ] ; then
-        MSG="HG_PUSH_DIR not set in $HG_REP_CONF"
+Check_CFG() {
+    if [ x$MASTER_DIR = x ] ; then
+        MSG="MASTER_DIR is not set in $CFG"
         return 1;
     fi
-    if [ -d $HG_PUSH_DIR ] ; then :
+    if [ -d $MASTER_DIR ] ; then :
     else
-        http=${HG_PUSH_DIR#http://}
+        http=${MASTER_DIR#http://}
         http=${http#https://}
-        if [ "$http" = $HG_PUSH_DIR ]; then
-            MSG="HG_PUSH_DIR from $HG_REP_CONF point for non existing dir."
+        if [ "$http" = $MASTER_DIR ]; then
+            MSG="MASTER_DIR from $CFG point for non existing dir."
             return 1
         else
             HTTP_USED=yes
@@ -146,20 +144,20 @@
     exit 1;
 fi
 
-if Set_HG_REP_CONF; then
-    . $HG_REP_CONF
+if Set_CFG; then
+    . $CFG
 else
-    PrintLog
+    PrintLog ERROR
     exit 1;
 fi
 
-if Check_HG_REP_CONF; then :
+if Check_CFG; then :
 else
-    PrintLog
+    PrintLog ERROR
     exit 1;
 fi
 
-MSG="Path to etalon repo set: $HG_PUSH_DIR"
+MSG="master dir: $MASTER_DIR"
 PrintLog INFO
 
 [ $NEED_PUSH != y ] && echo "INFO: You also may use --push opt."
@@ -174,25 +172,25 @@
     PrintLog PROCESSING
 
     if [ $HTTP_USED = no ]; then
-        if [ -d $HG_PUSH_DIR/$dir/.hg ]; then
-            if CheckRepCompatibility ./$dir $HG_PUSH_DIR/$dir; then :
+        if [ -d $MASTER_DIR/$dir/.hg ]; then
+            if CheckRepCompatibility ./$dir $MASTER_DIR/$dir; then :
             else
-                MSG="It seems repo '$dir' and etalon repo not compatable."
+                MSG="'$dir' and master repo is not compatable."
                 PrintLog
                 exit 1;
             fi
         else
-            MSG="'$dir' repo skiped. It is absent in etalon repo set."
+            MSG="'$dir' repo skiped. It is absent in master repo set."
             PrintLog INFO
             continue
         fi
     fi
 
     CHANGESET_CNT=`hg --config defaults.incoming="" --quiet -R ./$dir in \
-        --template '{node}\n' $HG_PUSH_DIR/$dir | wc -l`
+        --template '{node}\n' $MASTER_DIR/$dir | wc -l`
     if [ $CHANGESET_CNT -ge 1 ]; then
         # Переносим changeset из эталонного в рабочий репозиторий.
-        hg -R ./$dir pull $HG_PUSH_DIR/$dir >>$LOG_FILE 2>&1
+        hg -R ./$dir pull $MASTER_DIR/$dir >>$LOG_FILE 2>&1
         MSG="==> work"
         PrintLog ADDED
         CHANGED_FILES_CNT=`hg -R ./$dir st -m -a -r -d | wc -l`
@@ -210,12 +208,12 @@
         case $HEAD_CNT in
             1)
                 CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R ./$dir out \
-                    --template '{node}\n' $HG_PUSH_DIR/$dir | wc -l`
+                    --template '{node}\n' $MASTER_DIR/$dir | wc -l`
                 case $CHANGESET_CNT in
                     0) ;;
                     *)
-                        hg -R ./$dir push $HG_PUSH_DIR/$dir >>$LOG_FILE 2>&1
-                        MSG="==> etalon"
+                        hg -R ./$dir push $MASTER_DIR/$dir >>$LOG_FILE 2>&1
+                        MSG="==> master"
                         PrintLog ADDED
                         ;;
                 esac