代码之家  ›  专栏  ›  技术社区  ›  Jeffrey04 George

记录mercurial事务

  •  0
  • Jeffrey04 George  · 技术社区  · 16 年前

    这是对上一个脚本的一个小补充,这次我想记录备份的详细信息。

    script /tmp/commit-push-log
    
    # add all files to the repository
    for REPOSITORY in $@ 
    do
    
        cd $REPOSITORY
    
        # commit the changes
        hg commit -A -m "Commit changes `date`"
    
        # push the changes to the remote repository
        if hg push 
        then
            logger hg push completed without failure
        else
            logger hg push fails
        fi
    
    done
    
    exit
    
    cat /tmp/commit-push-log | logger
    
    rm /tmp/commit-push-log
    

    问题是我在日志中没有看到任何mercurial消息。我的剧本会出什么问题?

    2 回复  |  直到 16 年前
        1
  •  1
  •   Paweł Polewicz    16 年前
    1. cd "$REPOSITORY" 而不是“cd$REPOSITORY”,否则当存储库包含任何空格或特殊字符时,事情会变得有趣。
    2. 您不应该编写自动提交注释。 See here
    3. hg commit -A -m "$comment" 2>&1 hg push 2>&1
        2
  •  1
  •   Jeffrey04 George    16 年前

    我的当前版本

    for REPOSITORY in $@ 
    do
    
        # new temp file
        OUTPUT_LOG=`tempfile`
        echo -n > $OUTPUT_LOG
    
        # checks whether $REPO is a repo
        if [ ! -d $REPOSITORY/.hg ]; then
          echo "Not a repository: $REPOSITORY"
          exit 1;
        fi
    
        # change to that dir
        cd "$REPOSITORY"
    
        logger "Repository: $REPOSITORY"
    
        # commit the changes
        hg commit -A -m "Commit changes `date`" 2>&1 >> $OUTPUT_LOG
    
        # push the changes to the remote repository
        if hg push 2>&1 >> $OUTPUT_LOG
        then
        logger hg push completed without failure
        else
        logger hg push fails
        exit 1;
        fi
    
        # log the contents and delete the tempfile
        cat $OUTPUT_LOG | logger
    
        rm -f $OUTLOG_LOG
    
    done
    
    exit 0
    
    推荐文章