如何从bash中找出是否有任何未提交或推送的更改到mercurial存储库?

时间:2013-06-06 13:38:55

标签: mercurial diff

我想将此逻辑合并到bash脚本中:如果当前存储库有任何本地更改,则停止处理。

我对git有相同的逻辑,现在我需要为mercurial:

#!/bin/bash
set -ex
git pull
git update
# Disallow unstaged changes in the working tree
    if ! git diff-files --check --exit-code --ignore-submodules -- >&2
    then
        echo >&2 "error: you have unstaged changes."
        exit 1
    fi

# Disallow uncommitted changes in the index
    if ! git diff-index --cached --exit-code -r --ignore-submodules HEAD -- >&2
    then
        echo >&2 "error: your index contains uncommitted changes."
        exit 1
    fi

1 个答案:

答案 0 :(得分:1)

这应该这样做:

if [ -n "$(hg status -mar)" ]
then
    echo >&2 "error: your index contains uncommitted changes."
    exit 1
fi

检查移动,添加或删除的任何文件。如果你想检查已删除(缺失)或未知但未被忽略,你也可以这样做。