Reputation: 4297
I want to write an ant task to check if the file was added to the Mercurial repository. But I don't know how to write the condition.
Upvotes: 1
Views: 202
Reputation: 616
You can check the status from a file by simply call hg status filename
on that file. The returning string starts with some codes that shows the status of the file:
$ 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
You can also check the location of the file in Mercurial control, if the file is under Mercurial control then the hg locate filename
returns the name of the file, nothing otherwise. Or may be by the returning value of the program, 0 if match 1 otherwise.
$ hg locate
a.txt
dir/c.txt
$ hg locate a.txt
a.txt
$ hg locate b.txt
$
$ echo $?
1
And you can also check if the file is in the manifest list, as hg manifest
prints the list of version controlled files:
$ hg manifest
a.txt
dir/c.txt
Upvotes: 1