Commits

Fredrik Håård committed b0f697f

Imported fix from Adam Gooma: #10

Comments (0)

Files changed (2)

         """Commit changes to the repository."""
         userspec = "-u" + user if user else "-u" + self.user if self.user else ""
         close = "--close-branch" if close_branch else ""
-        self.hg_command("commit", "-m", message, close, 
-                        userspec, *files)
+        args = [close, userspec] + files
+        # don't send a "" arg for userspec or close, which HG will
+        # consider the files arg, committing all files instead of what
+        # was passed in files kwarg
+        args = [arg for arg in args if arg]
+        self.hg_command("commit", "-m", message, *args)
 
     def hg_log(self, identifier=None, limit=None, template=None, **kwargs):
         """Get repositiory log. 

hgapi/testhgapi.py

         heads = self.repo.hg_heads()
         self.assertEquals(len(heads), 1)
 
+    def test_160_CommitFiles(self):
+        with open("test/file2.txt", "w") as out:
+            out.write("newstuff")
+        with open("test/file3.txt", "w") as out:
+            out.write("this is even more stuff")
+        self.repo.hg_commit("only committing file2.txt", user="test", files=["file2.txt"])
+        self.assertTrue("file3.txt" in self.repo.hg_status()["M"])
+
+
 def test_doc():
     #Prepare for doctest
     os.mkdir("./test_hgapi")