Подвижный “hg состояние” и относительные пути

Если я правильно понимаю, вы хотите, чтобы значение ключа «SC» было минимальным, если 23, а для всех остальных 26.

Обратите внимание, что в строке: array_search('SC', $sc) ? min($consumed) >= 23:26 сначала проверьте, существует ли «SC», и установите минимум для всего массива как 23 или 26.

Если вы хотите, чтобы значение min различалось в зависимости от ключей, я бы порекомендовал это:

function checkMin($arr, $min, $exception) {
    foreach($arr as $k => $v) {
        if ($v < (isset($exception[$k]) ? $exception[$k] : $min)) 
            return false;
    }
    return true;
}

Теперь вы можете позвонить с помощью:

"condition" =>  checkMin($consumed, 26, ["SC" => 23])

Надеюсь, что это поможет! [117 ]

30
задан pachanga 7 May 2009 в 07:36
поделиться

2 ответа

The usual workaround is to run:

hg status $(hg root)

For older versions of Mercurial, prior to 1.7, you could use this hack, adding to your repository's ".hg/hgrc" file:

[alias]
 sst = status /path/to/root

That needs the alias extension enabled, so you may have to add "alias=" to your ~/.hgrc file.

Starting with Mercurial 1.7, the alias extension learned about the "!" escape to use shell commands, so you can now have a global alias that does this:

[alias]
sst = !hg status $($HG root) $HG_ARGS

Don't use st = !hg status $(hg root), since that creates an infinite loop, running hg status over and over. It looks like a bug in the alias parsing - if you want to alias hg status to show the path from the root, then the following incantation works in the global $HOME/.hgrc:

[alias]
__mystatus = status
st = !hg __mystatus $($HG root) $HG_ARGS
33
ответ дан 27 November 2019 в 23:19
поделиться

Чтобы увидеть статус рабочего пространства относительно текущего каталога, вы всегда можете использовать "." (одна точка) в качестве аргумента «hg status», то есть:

% hg root                   # root of the workspace
/work/foo

% pwd                       # current directory is <root>/src
/work/foo/src

% hg status                 # no argument, see all files
M etc/foo.conf              # all files are shown with paths
M src/foosetup.c            # relative to workspace root
%

Разница, когда вы явно запрашиваете текущий рабочий каталог, заключается в том, что относительные пути к именам файлов используют его в качестве начальной точки:

% hg status .               # see only files under current path
M foosetup.c
%
35
ответ дан 27 November 2019 в 23:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: