views:

26

answers:

1

I want to check whether repository exist on the given path or not before executing the process below..any ideas ?

var exe = Components.classes['@mozilla.org/filelocal;1'].
                     createInstance(Components.interfaces.nsILocalFile);

exe.initWithPath("HG.EXE");

var process = Components.classes["@mozilla.org/process/util;1"].
              createInstance(Components.interfaces.nsIProcess);

Process.init(exe);

args = ["init", "D:\\testRepo\\"];
process.run(blocking, args, args.length);
A: 

Well, you could use

hg -R the/path/you/want/to/test root

which tell if there is a repository at the/path/you/want/to/test or above. Look at the exit code of the command to see if it succeeded.

You will also need to compare the root printed by the command with your actual directory -- it could be that there is a repository at some higher level and then hg root will report that.

Martin Geisler
awesome...thanks for the info...
Nitesh
Nitesh: I'm glad you could use it, feel free to accept this answer as the correct answer :-)
Martin Geisler