Commits

Kevin Turner committed ce66db3

Add DarcsCommands to base.fscommands

  • Participants
  • Parent commits 0cb0908

Comments (0)

Files changed (1)

rope/base/fscommands.py

     commands = {'.hg': MercurialCommands,
                 '.svn': SubversionCommands,
                 '.git': GITCommands,
-                '_svn': SubversionCommands}
+                '_svn': SubversionCommands,
+                '_darcs': DarcsCommands}
     for key in commands:
         if key in dirlist:
             try:
         return self.root
 
 
+class DarcsCommands(object):
+
+    def __init__(self, root):
+        self.root = root
+        self.normal_actions = FileSystemCommands()
+
+    def create_file(self, path):
+        self.normal_actions.create_file(path)
+        self._do(['add', path])
+
+    def create_folder(self, path):
+        self.normal_actions.create_folder(path)
+        self._do(['add', path])
+
+    def move(self, path, new_location):
+        self._do(['mv', path, new_location])
+
+    def remove(self, path):
+        self.normal_actions.remove(path)
+
+    def write(self, path, data):
+        self.normal_actions.write(path, data)
+
+    def _do(self, args):
+        _execute(['darcs'] + args, cwd=self.root)
+
+
 def _execute(args, cwd=None):
     process = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE)
     process.wait()