"correct" 意外使用 mv 而不是 hg mv 的最简单方法?
Simplest way to "correct" an accidental use of mv instead of an hg mv?
我有一个跟踪 foo
。现在,因为我心不在焉,所以我 运行:
mv foo bar
现在,当我执行 hg st
时,我得到:
! foo
? bar
我想追溯修复此问题 - 就好像我已经完成了 hg mv foo bar
。
现在,我可以编写一个 bash 脚本来为我完成这些工作 - 但是有什么 better/simpler/smarter 我可以做的吗?
这是我现在正在做的事情;
#!/bin/bash
function die {
echo "" >&2
exit -1
}
(( $# == 2 )) || die "Usage: [=10=] <moved filename> <original filename>"
[[ -e "" ]] || die "Not an existing file: "
[[ ! -e "" ]] || die "Not a missing file: "
hg_st_lines_1=$(hg st "" 2>/dev/null | wc -l)
hg_st_lines_2=$(hg st "" 2>/dev/null | wc -l)
(( ${hg_st_lines_1} == 1 )) || die "Expected exactly one line in hg status for , but got ${hg_st_lines_1}"
(( ${hg_st_lines_2} == 1 )) || die "Expected exactly one line in hg status for , but got ${hg_st_lines_2}"
[[ "$(hg st "" 2>/dev/null)" == \?* ]] || die "Mercurial does not consider to be an unknown (untracked) file"
[[ "$(hg st "" 2>/dev/null)" =~ !.* ]] || die "Mercurial does not consider to be a missing file"
mv
hg mv
使用--after
选项:hg mv --after foo bar
$ hg mv --help
hg rename [OPTION]... SOURCE... DEST
aliases: move, mv
rename files; equivalent of copy + remove
Mark dest as copies of sources; mark sources for deletion. If dest is a
directory, copies are put in that directory. If dest is a file, there can
only be one source.
By default, this command copies the contents of files as they exist in the
working directory. If invoked with -A/--after, the operation is recorded,
but no copying is performed.
This command takes effect at the next commit. To undo a rename before
that, see 'hg revert'.
Returns 0 on success, 1 if errors are encountered.
options ([+] can be repeated):
-A --after record a rename that has already occurred
-f --force forcibly copy over an existing managed file
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
-n --dry-run do not perform actions, just print output
--mq operate on patch repository
(some details hidden, use --verbose to show complete help)
我有一个跟踪 foo
。现在,因为我心不在焉,所以我 运行:
mv foo bar
现在,当我执行 hg st
时,我得到:
! foo
? bar
我想追溯修复此问题 - 就好像我已经完成了 hg mv foo bar
。
现在,我可以编写一个 bash 脚本来为我完成这些工作 - 但是有什么 better/simpler/smarter 我可以做的吗?
这是我现在正在做的事情;
#!/bin/bash
function die {
echo "" >&2
exit -1
}
(( $# == 2 )) || die "Usage: [=10=] <moved filename> <original filename>"
[[ -e "" ]] || die "Not an existing file: "
[[ ! -e "" ]] || die "Not a missing file: "
hg_st_lines_1=$(hg st "" 2>/dev/null | wc -l)
hg_st_lines_2=$(hg st "" 2>/dev/null | wc -l)
(( ${hg_st_lines_1} == 1 )) || die "Expected exactly one line in hg status for , but got ${hg_st_lines_1}"
(( ${hg_st_lines_2} == 1 )) || die "Expected exactly one line in hg status for , but got ${hg_st_lines_2}"
[[ "$(hg st "" 2>/dev/null)" == \?* ]] || die "Mercurial does not consider to be an unknown (untracked) file"
[[ "$(hg st "" 2>/dev/null)" =~ !.* ]] || die "Mercurial does not consider to be a missing file"
mv
hg mv
使用--after
选项:hg mv --after foo bar
$ hg mv --help
hg rename [OPTION]... SOURCE... DEST
aliases: move, mv
rename files; equivalent of copy + remove
Mark dest as copies of sources; mark sources for deletion. If dest is a
directory, copies are put in that directory. If dest is a file, there can
only be one source.
By default, this command copies the contents of files as they exist in the
working directory. If invoked with -A/--after, the operation is recorded,
but no copying is performed.
This command takes effect at the next commit. To undo a rename before
that, see 'hg revert'.
Returns 0 on success, 1 if errors are encountered.
options ([+] can be repeated):
-A --after record a rename that has already occurred
-f --force forcibly copy over an existing managed file
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
-n --dry-run do not perform actions, just print output
--mq operate on patch repository
(some details hidden, use --verbose to show complete help)