Commits

Fredrik Håård committed 4fd793e

I decided having missing keys in hg_status was stupid

  • Participants
  • Parent commits a3de019

Comments (0)

Files changed (2)

File hgapi/hgapi.py

         change char is in A, M, R, !, ?
 
         Example - added one.txt, modified a_folder/two.txt and three.txt: 
-            {'A': ['one.txt'], 'M': ['a_folder/two.txt', 'three.txt']}
-
-        Note that empty mappings are not created.
+            {'A': ['one.txt'], 'M': ['a_folder/two.txt', 'three.txt'],
+            '!': [], '?': [], 'R': []}
         """
         cmds = ['status']
         out = self.hg_command(*cmds).strip()
-        if not out: return {}
+        #default empty set
+        changes = {'A': [], 'M': [], '!': [], '?': [], 'R': []}
+        if not out: return changes
         lines = out.split("\n")
         status_split = re.compile("^(.) (.*)$")
-        changes = {}
+
         for change, path in [status_split.match(x).groups() for x in lines]:
             changes.setdefault(change, []).append(path)
         return changes

File hgapi/testhgapi.py

         with open("test/file.txt", "a") as out:
             out.write("stuff stuff stuff")
         status = self.repo.hg_status()
-        self.assertEquals(status, {'M': ['file.txt']})
-
+        self.assertEquals(status, 
+                          {'A': [], 'M': ['file.txt'], '!': [], 
+                           '?': [], 'R': []})
+        
     def test_100_CleanStatus(self):
         #commit file created in 090
         self.repo.hg_commit("Comitting changes", user="test")
         #Assert status is empty
-        self.assertEquals(self.repo.hg_status(), {})
+        self.assertEquals(self.repo.hg_status(), 
+                          {'A': [], 'M': [], '!': [], '?': [], 'R': []})
 
     def test_110_UntrackedStatus(self):
         #Create a new file
         with open("test/file2.txt", "w") as out:
             out.write("stuff stuff stuff")
         status = self.repo.hg_status()
-        self.assertEquals(status, {'?': ['file2.txt']})
+        self.assertEquals(status, 
+                          {'A': [], 'M': [], '!': [], 
+                           '?': ['file2.txt'], 'R': []})
 
     def test_120_AddedStatus(self):
         #Add file created in 110
         self.repo.hg_add("file2.txt")
         status = self.repo.hg_status()
-        self.assertEquals(status, {'A': ['file2.txt']})
+        self.assertEquals(status, 
+                          {'A': ['file2.txt'], 'M': [], '!': [], 
+                           '?': [], 'R': []})
 
     def test_130_MissingStatus(self):
         #Commit file created in 120
         import os
         os.unlink("test/file2.txt")
         status = self.repo.hg_status()
-        self.assertEquals(status, {'!': ['file2.txt']})
+        self.assertEquals(status, 
+                          {'A': [], 'M': [], '!': ['file2.txt'], 
+                           '?': [], 'R': []})
 
     def test_140_RemovedStatus(self):
         #Remove file from repo
         self.repo.hg_remove("file2.txt")
         status = self.repo.hg_status()
-        self.assertEquals(status, {'R': ['file2.txt']})
+        self.assertEquals(status, 
+                          {'A': [], 'M': [], '!': [], 
+                           '?': [], 'R': ['file2.txt']})
 
 
 def test_doc():