最简单的方法来纠正"意外使用mv而不是hg mv?

时间:2017-12-28 21:26:35

标签: bash mercurial mv idiomatic

我有一个跟踪foo。现在,既然我心不在焉,我就跑了:

mv foo bar

现在,当我hg st时,我得到:

! foo
? bar

我想追溯性地解决这个问题 - 好像我已经做了hg mv foo bar

现在,我可以编写一个bash脚本来为我做这个 - 但是有什么更好/更简单/更聪明我能做到吗?

2 个答案:

答案 0 :(得分:2)

使用import numpy as np import matplotlib.pyplot as plt .... .... plt.plot(m) # m is a matrix with size (1000,36) plt.show() 选项:--after

hg mv --after foo bar

答案 1 :(得分:0)

这就是我现在正在做的事情;

#!/bin/bash

function die {
    echo "$1" >&2
    exit -1
}

(( $# == 2 )) || die "Usage: $0 <moved filename> <original filename>"
[[ -e "$1" ]]  || die "Not an existing file: $1"
[[ ! -e "$2" ]] || die "Not a missing file: $2"

hg_st_lines_1=$(hg st "$1" 2>/dev/null | wc -l)
hg_st_lines_2=$(hg st "$2" 2>/dev/null | wc -l)

(( ${hg_st_lines_1} == 1 )) || die "Expected exactly one line in hg status for $1, but got ${hg_st_lines_1}"
(( ${hg_st_lines_2} == 1 )) || die "Expected exactly one line in hg status for $2, but got ${hg_st_lines_2}"

[[ "$(hg st "$1" 2>/dev/null)" == \?* ]] || die "Mercurial does not consider $1 to be an unknown (untracked) file"
[[ "$(hg st "$2" 2>/dev/null)" =~ !.* ]] || die "Mercurial does not consider $2 to be a missing file"

mv $1 $2
hg mv $2 $1