在蚂蚁中如何检查文件是否已添加到Mercurial存储库?

时间:2014-04-12 05:15:39

标签: ant mercurial

我想编写一个ant任务来检查文件是否已添加到Mercurial存储库中。但我不知道如何写这个条件。

1 个答案:

答案 0 :(得分:1)

您只需在该文件上调用hg status filename即可查看文件中的状态。返回的字符串以一些显示文件状态的代码开头:

$ hg help status
...
  M = modified
  A = added
  R = removed
  C = clean
  ! = missing (deleted by non-hg command, but still tracked)
  ? = not tracked
  I = ignored
    = origin of the previous file listed as A (added)
...
$ hg status
A a.txt
A dir/c.txt
? b.txt
$ hg status a.txt
A a.txt
$ hg status b.txt
? b.txt

您还可以在Mercurial控件中检查文件的位置,如果文件位于Mercurial控件下,则hg locate filename将返回文件名,否则返回任何内容。或者可以是程序的returning value,否则为0,否则为0。

$ hg locate
a.txt
dir/c.txt
$ hg locate a.txt
a.txt
$ hg locate b.txt
$
$ echo $?
1

您还可以检查文件是否在清单列表中,因为hg manifest打印版本控制文件列表:

$ hg manifest
a.txt
dir/c.txt