changeset 183:358fdd20674a

determine branch when hg not available
author smith@nwoca.org
date Mon, 22 Dec 2014 20:44:29 +0000
parents 0de8c0720fb4
children acd8d3b58440
files init20.gradle
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/init20.gradle	Fri Dec 19 20:25:12 2014 +0000
+++ b/init20.gradle	Mon Dec 22 20:44:29 2014 +0000
@@ -489,7 +489,8 @@
 }
 
 
-@ToString class BranchInfo {
+@ToString
+class BranchInfo {
     def name
     def stream = "none"
 
@@ -512,10 +513,18 @@
     }
 
     def determineName()  {
-        def branch = "hg branch".execute().text.trim()
-        def rawParents = 'hg parents'.execute().text
-        def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim()
-        return parent ?: branch
+        try {
+            def branch = "hg branch".execute().text.trim()
+            def rawParents = 'hg parents'.execute().text
+            def parent = rawParents.split('\n').find { it.startsWith("branch") }?.split(":")?.getAt(1)?.trim()
+            return parent ?: branch
+        } catch (e) {
+            if(new File('.hg/branch').exists()) {
+                return new File('.hg/branch').text
+            } else {
+                return ''
+            }
+        }
     }
 
     void determineStream() {