Fredrik Håård avatar Fredrik Håård committed e6b1e02

added short form to hg_heads

Comments (0)

Files changed (3)

 # built documents.
 # The short X.Y version.
-version = '1.2.0'
+version = '1.3.1'
 # The full version, including alpha/beta/rc tags.
-release = '1.2.0'
+release = '1.3.1a1'
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
             res[tag] = changeset.split(':')[1]
         return res
-    def hg_heads(self):
-        """Gets a list with the node id:s of all open heads"""
-        res = self.hg_command("heads","--template", "{node}\n")
+    def hg_heads(self, short=False):
+        """Gets a list with the node id:s of all open heads.
+        If short is given and is not False, return the short form of the node id"""
+        template = "{node}\n" if not short else "{node|short}\n"
+        res = self.hg_command("heads","--template", template)
         return [head for head in res.split("\n") if head]
     def hg_merge(self, reference):


         self.assertTrue(node in heads)
         self.assertTrue(self.repo.hg_node() in heads)
+        heads = self.repo.hg_heads(short=True)
+        self.assertEquals(len(heads), 2)
+        self.assertTrue(node[:12] in heads)
+        self.assertTrue(self.repo.hg_node()[:12] in heads)
         #Close head again
         self.repo.hg_commit("Closing branch", close_branch=True)
         # create a new branch, should still be default in branches until we commit
         # but branch should return the new branch
-        self.assertEquals(self.repo.hg_branch('test_branch'),
-            "marked working directory as branch test_branch")
+        self.assertTrue(self.repo.hg_branch('test_branch').startswith(
+            "marked working directory as branch test_branch"))
         self.assertEquals(self.repo.hg_branch(), "test_branch")
         branches = self.repo.get_branches()
         self.assertEquals(len(branches), 1)
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
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.