changeset 437:f2ca93785a54

merged
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Mon, 31 Oct 2011 03:09:40 +0200
parents efc7757f7652 (current diff) cba41fd95053 (diff)
children df33b9cc7d39 e3ef75c2486f
files
diffstat 4 files changed, 86 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/hg/hgsyncee	Mon Oct 31 01:28:02 2011 +0200
+++ b/hg/hgsyncee	Mon Oct 31 03:09:40 2011 +0200
@@ -5,6 +5,9 @@
 # Утилита безопасно синхорнизирует состояние эталонных репозиториев
 # посредством промежуточных репозиториев и репозиториев для мержа.
 
+# set -x
+# set -u
+
 UTIL_NAME=$0
 UTIL_NAME=${UTIL_NAME##*/}
 
@@ -59,12 +62,7 @@
 
 # Is hg utility present in system?
 Check_HG_exist() {
-    hg --help 1>/dev/null 2>/dev/null
-    if [ $? = 0 ]; then
-        return 0;
-    else
-        return 1;
-    fi
+    command -v hg && return 0 || return 1
 }
 
 Set_HG_REP_CONF() {
@@ -73,7 +71,6 @@
     if [ -e $HG_REP_CONF ]; then
         return 0;
     fi
-
     # Иначе ищем по стандартному пути.
     if [ x$HOME = x ] ; then
         MSG="Var HOME not set."
@@ -83,12 +80,10 @@
     if [ -e $HG_REP_CONF ] ; then
         return 0;
     fi
-
     HG_REP_CONF=/etc/hgsyncrc
     if [ -e $HG_REP_CONF ]; then
         return 0;
     fi
-
     MSG="Config file not found, see man page hgsyncrc(1)."
     return 1;
 }
@@ -97,12 +92,11 @@
     if [ x$HG_PUSH_DIR = x ] ; then
         MSG="HG_PUSH_DIR not set in $HG_REP_CONF"
         return 1;
+    fi
+    if [ -d $HG_PUSH_DIR ] ; then :
     else
-        if [ -d $HG_PUSH_DIR ] ; then :
-        else
-            MSG="HG_PUSH_DIR from $HG_REP_CONF point for non existing dir."
-            return 1;
-        fi
+        MSG="HG_PUSH_DIR from $HG_REP_CONF 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"
@@ -113,7 +107,6 @@
             return 1;
         fi
     fi
-
     return 0;
 }
 
@@ -129,7 +122,7 @@
 # Main work.
 # ##########
 
-case x$1 in
+case x${1-} in
     x-h|x--help)
         Usage
         exit 0;
--- a/hg/hgsyncee.1	Mon Oct 31 01:28:02 2011 +0200
+++ b/hg/hgsyncee.1	Mon Oct 31 03:09:40 2011 +0200
@@ -1,3 +1,4 @@
+.\" -*- fill-column: 78 -*-
 .\" Process this file with
 .\"   $ groff -man -Tascii hgsyncee.1
 .\" or see by
@@ -14,12 +15,24 @@
 is synchronization repositories which placed on usb stick, different fs with
 repositories in desired directory.
 
-Just cd to dir with repos, run hgsyncew. May happen that you must go to
-merge dir to merge changes manually and rerun hgsyncew.
+Just cd to dir with repos, run hgsyncew.
+
+May happen that you must go to merge dir (pointed by
+.IR $HG_PULL_DIR/$proj )
+to merge changes manually and rerun
+.BR hgsyncee .
 
 To use
 .B hgsyncee
-you must set options in hgsyncrc(5).
+you must set options in
+.BR hgsyncrc(5) .
+
+You can not use HTTP protocol in
+.IR HG_PULL_DIR
+and
+.IR HG_PUSH_DIR
+for
+.BR hgsyncee .
 .SH OPTIONS
 .IP --help
 Print help.
--- a/hg/hgsyncew	Mon Oct 31 01:28:02 2011 +0200
+++ b/hg/hgsyncew	Mon Oct 31 03:09:40 2011 +0200
@@ -5,11 +5,16 @@
 # Утилита безопасно синхорнизирует состояние эталонных репозиториев
 # с рабочими репозиториями.
 
+# set -x
+# set -u
+
 UTIL_NAME=$0
 UTIL_NAME=${UTIL_NAME##*/}
 
 LOG_FILE=$UTIL_NAME.log
 
+HTTP_USED=no
+
 Usage() {
     echo Sync working repo set with etalon repo set.
     echo "Usage:"
@@ -60,12 +65,7 @@
 
 # Is hg utility present in system?
 Check_HG_exist() {
-    hg --help 1>/dev/null 2>/dev/null
-    if [ $? = 0 ]; then
-        return 0;
-    else
-        return 1;
-    fi
+    command -v hg && return 0 || return 1
 }
 
 Set_HG_REP_CONF() {
@@ -74,7 +74,6 @@
     if [ -e $HG_REP_CONF ]; then
         return 0;
     fi
-
     # Иначе ищем по стандартному пути.
     if [ x$HOME = x ] ; then
         MSG="Var HOME not set."
@@ -84,28 +83,31 @@
     if [ -e $HG_REP_CONF ] ; then
         return 0;
     fi
-
     HG_REP_CONF=/etc/hgsyncrc
     if [ -e $HG_REP_CONF ]; then
         return 0;
     fi
-
     MSG="Config file not found, see man page hgsyncrc(1)."
     return 1;
 }
 
+# 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"
         return 1;
+    fi
+    if [ -d $HG_PUSH_DIR ] ; then :
     else
-        if [ -d $HG_PUSH_DIR ] ; then :
+        http=${HG_PUSH_DIR#http://}
+        http=${http#https://}
+        if [ "$http" = $HG_PUSH_DIR ]; then
+            MSG="HG_PUSH_DIR from $HG_REP_CONF point for non existing dir."
+            return 1
         else
-            MSG="HG_PUSH_DIR from $HG_REP_CONF point for non existing dir."
-            return 1;
+            HTTP_USED=yes
         fi
     fi
-
     return 0;
 }
 
@@ -123,7 +125,7 @@
 
 NEED_PUSH=n
 
-case x$1 in
+case x${1-} in
     x-h|x--help)
         Usage
         exit 0;
@@ -172,21 +174,23 @@
     MSG="'$dir' repo."
     PrintLog PROCESSING
 
-    if [ -d $HG_PUSH_DIR/$dir ]; then
-        if CheckRepCompatibility ./$dir $HG_PUSH_DIR/$dir; then :
+    if [ $HTTP_USED = no ]; then
+        if [ -d $HG_PUSH_DIR/$dir ]; then
+            if CheckRepCompatibility ./$dir $HG_PUSH_DIR/$dir; then :
+            else
+                MSG="It seems repo '$dir' and etalon repo not compatable."
+                PrintLog
+                exit 1;
+            fi
         else
-            MSG="It seems repo '$dir' and etalon repo not compatable."
-            PrintLog
-            exit 1;
+            MSG="'$dir' repo skiped. It is absent in etalon repo set."
+            PrintLog INFO
+            continue
         fi
-    else
-        MSG="'$dir' repo skiped. It is absent in etalon repo set."
-        PrintLog INFO
-        continue
     fi
 
-    CHANGESET_CNT=`hg --config defaults.outgoing="" --quiet -R $HG_PUSH_DIR/$dir out \
-        --template '{node}\n' ./$dir | wc -l`
+    CHANGESET_CNT=`hg --config defaults.incoming="" --quiet -R ./$dir in \
+        --template '{node}\n' $HG_PUSH_DIR/$dir | wc -l`
     if [ $CHANGESET_CNT -ge 1 ]; then
         # Переносим changeset из эталонного в рабочий репозиторий.
         hg -R ./$dir pull $HG_PUSH_DIR/$dir >>$LOG_FILE 2>&1
@@ -202,7 +206,7 @@
     fi
 
     # Если указана опция --push, безопасно переносим изменения в эталонный репозиторий.
-    if [ $NEED_PUSH = y ]; then
+    if [ $NEED_PUSH = y -a $HTTP_USED = no ]; then
         HEAD_CNT=`hg -R ./$dir head --template '{node}\n' | wc -l`
         case $HEAD_CNT in
             1)
--- a/hg/hgsyncew.1	Mon Oct 31 01:28:02 2011 +0200
+++ b/hg/hgsyncew.1	Mon Oct 31 03:09:40 2011 +0200
@@ -1,3 +1,4 @@
+.\" -*- fill-column: 78 -*-
 .\" Process this file with
 .\"   $ groff -man -Tascii hgsyncew.1
 .\" or see by
@@ -5,27 +6,48 @@
 .\"
 .TH HGSYNCEW 1 2009-05-29 "hgsync utilities 0.2" "User Manuals"
 .SH NAME
-hgsyncew \- synchronize set of Mercurial repositories
+hgsyncew \- synchronize a working set of Mercurial repositories
 .SH SYNOPSIS
 .B hgsyncew [ --help ] [ --push ]
 .SH DESCRIPTION
 Typical use of
 .B hgsyncew
-is synchronization repositories which placed on usb stick, different fs with
-repositories in desired directory.
-
-Just cd to dir with repos, run hgsyncew. May happen that you must go to
-merge dir to merge changes manually and rerun hgsyncew.
+is synchronization of a set of repositories with master repositories.
 
 To use
-.B hgsyncew
-you must set options in hgsyncrc(5).
+.BR hgsyncew
+you must set
+.IR HG_PUSH_DIR
+option in
+.BR hgsyncrc(5) .
+Only pull request was allowed to use remote protocol for
+.IR HG_PUSH_DIR .
+
 .SH OPTIONS
 .IP --help
 Print help.
 .IP --push
 Push changes back to main repositories.
-\" .SH EXAMPLES
+.SH EXAMPLES
+.nf
+.B $ cd $dir
+.B $ echo */
+proj1/ proj2/
+.B $ hgsyncew
+
+.fi
+Get changes from
+.IR $HG_PUSH_DIR/proj1
+and
+.IR $HG_PUSH_DIR/proj2
+to
+.IR proj1
+and
+.IR proj2 .
+If there are no local changes and there are only one head project
+automatically updated to
+.IR tip .
+
 .SH FILES
 Searching for config take place in such order: