[PATCH 2 of 2] hgcommand.vim: get current branch name with "hg branch"

Christian Ebert blacktrash at gmx.net
Wed Oct 25 11:34:16 CDT 2006


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1161793572 -7200
# Node ID 8d6df43c35d1c6833864ef648e6fb2e408a1ea0b
# Parent  c5b64f90621ea9654df327f3cd7875b5f20079ab
hgcommand.vim: get current branch name with "hg branch"

output of "hg branch" is a guess ATM.

diff -r c5b64f90621e -r 8d6df43c35d1 contrib/vim/hgcommand.vim
--- a/contrib/vim/hgcommand.vim	Wed Oct 25 18:13:58 2006 +0200
+++ b/contrib/vim/hgcommand.vim	Wed Oct 25 18:26:12 2006 +0200
@@ -372,15 +372,20 @@ function! s:HGGetStatusVars(revisionVar,
       let revision="ADDED"
     else
       " The file is tracked, we can try to get is revision number
-      let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " parents -b  "
+      let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " parents "
       let statustext=system(hgCommand)
       if(v:shell_error)
           return ""
       endif
       let revision=substitute(statustext, '^changeset:\s*\(\d\+\):.*\_$\_.*$', '\1', "")
-
-      if a:branchVar != "" && match(statustext, '^\_.*\_^branch:') >= 0
-        let branch=substitute(statustext, '^\_.*\_^branch:\s*\(\S\+\)\n\_.*$', '\1', "")
+      " Try to get current branch name
+      let hgCommand = <SID>HGGetOption("HGCommandHGExec", "hg") . " branch "
+      let branch=system(hgCommand)
+      if(v:shell_error)
+          return ""
+      endif
+
+      if a:branchVar != "" && branch != ""
         let returnExpression=returnExpression . " | let " . a:branchVar . "='" . branch . "'"
       endif
     endif


More information about the Mercurial-devel mailing list