changeset 363:51aaf8bcd6ec

vcs_functions: fix vcs_current_branch to use hg templating This takes it from 4 hg invocations to 1, and skips a bunch of pipelines.
author Augie Fackler <raf@durin42.com>
date Fri, 11 Sep 2015 09:53:34 -0400
parents 6dd0f2587d74
children 2ac43cd7bbf7
files .shell.d/50.vcs_functions.sh
diffstat 1 files changed, 2 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/.shell.d/50.vcs_functions.sh
+++ b/.shell.d/50.vcs_functions.sh
@@ -125,16 +125,9 @@ function vcs_current_branch() {
         echo $br $rev
         return 0
     fi
-    hg branch 2> /dev/null > /dev/null
+    hginfo=$(hg log -r . -T'{if(activebookmark,"{activebookmark}","{branch}")} {shortest(node)}')
     if [ $? = 0 ] ; then
-        local bm=$(hg book | egrep ' \* ' | awk '{print $2}')
-        local br=`hg branch | head -c 10`
-        local rid=`hg parents --template '{node}\n' | head -n 1 | head -c 7`
-        if [ -z "$bm" ] ; then
-          echo "$br $rid"
-        else
-          echo "$bm $rid"
-        fi
+        echo "$hginfo"
         return 0
     fi
     return 1