如何检查存储库是否存在?
我想在执行下面的过程之前检查给定路径上是否存在存储库..有什么想法吗?
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,您可以使用
该命令告诉您在
the/path/you/want/to/test
或以上是否有存储库。查看命令的退出代码以查看是否成功。您还需要将命令打印的根目录与实际目录进行比较 - 可能存在更高级别的存储库,然后
hg root
将报告该情况。Well, you could use
That command tells you 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.您可以简单地检查
.hg
子目录是否存在(这仅在您检查存储库的根目录而不是从属于存储库的文件夹内时有效)。You could simply check if the
.hg
subdirectory exists (this only works if you are checking the root of the repository, not from within a folder that would be part of your repository).