Jan Willems avatar Jan Willems committed 6adbfc1

Added hg_addremove command to the API.

Comments (0)

Files changed (2)

         str_rev = res.strip("\n +")
         return int(str_rev)
 
-    def hg_add(self, filepath):
-        """Add a file to the repo"""
-        self.hg_command("add", filepath)
+    def hg_add(self, filepath=None):
+        """
+        Add a file to the repo; when no filepath is given,
+        the hg add all files are added to the repo.
+        """
+        if filepath is None:
+            self.hg_command("add")
+        else:
+            self.hg_command("add", filepath)
+
+    def hg_addremove(self, filepath=None):
+        """
+        Add a file to the repo; when no filepath is given,
+        the hg add all files are added to the repo.
+        """
+        if filepath is None:
+            self.hg_command("addremove")
+        else:
+            self.hg_command("addremove", filepath)
 
     def hg_remove(self, filepath):
         """Remove a file from the repo"""

hgapi/testhgapi.py

         with open("test/file.txt", "w") as out:
             out.write("stuff")
         self.repo.hg_add("file.txt")
-        
+
+    def test_021_Add(self):
+        with open("test/foo.txt", "w") as out:
+            out.write("A sample file")
+        with open("test/bar.txt", "w") as out:
+            out.write("Another sample file")
+        self.repo.hg_add()
+
     def test_030_Commit(self):
         #Commit and check that we're on a real revision
         self.repo.hg_commit("adding", user="test")
-        rev  = self.repo.hg_rev()
+        rev = self.repo.hg_rev()
         hgid = self.repo.hg_id()
         self.assertEquals(rev, 0)
         self.assertNotEquals(hgid, "000000000000")
 
         #Commit and check that changes have been made
         self.repo.hg_commit("modifying", user="test")
-        rev2  = self.repo.hg_rev()
+        rev2 = self.repo.hg_rev()
         hgid2 = self.repo.hg_id()
         self.assertNotEquals(rev, rev2)
         self.assertNotEquals(hgid, hgid2)
             out.write("stuff stuff stuff")
         status = self.repo.hg_status()
         self.assertEquals(status, 
-                          {'A': [], 'M': ['file.txt'], '!': [], 
+                          {'A': [], 'M': ['file.txt'], '!': [],
                            '?': [], 'R': []})
         
     def test_100_CleanStatus(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.