mercurial/HGRepository.st
changeset 371 f271ddd2b5e0
parent 335 7e19ab19148b
child 395 fc0607653d8a
--- a/mercurial/HGRepository.st	Thu Feb 13 11:46:01 2014 +0000
+++ b/mercurial/HGRepository.st	Thu Feb 13 16:25:49 2014 +0000
@@ -84,6 +84,32 @@
 
 !HGRepository class methodsFor:'instance creation'!
 
+init: aStringOrFilename
+    "Create a new repository in given directory and
+     return HGRepository for it"
+
+    | dir |
+
+    dir := aStringOrFilename asFilename.
+    dir exists ifTrue:[ 
+        dir isDirectory ifTrue:[ 
+            dir directoryContents notEmpty ifTrue:[ 
+                HGRepositoryError raiseErrorString: 'Directory exists but not empty'.  
+                ^ self.
+            ].
+        ] ifFalse:[ 
+            HGRepositoryError raiseErrorString: 'Given path is not a directory'.
+            ^ self.
+        ].
+    ].
+    HGCommand init
+        path: dir;
+        execute.
+    ^self on: dir.
+
+    "Created: / 13-02-2014 / 12:38:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 on: aStringOrFilename
     ^self on: aStringOrFilename cached: false
 
@@ -144,9 +170,10 @@
         path: dst pathName;
         update: update;
         execute.
-    ^HGRepository on: dst.
+    ^self on: dst.
 
     "Created: / 21-11-2012 / 00:20:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 13-02-2014 / 12:40:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !HGRepository class methodsFor:'utilities'!