Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • This seems to get the branch name from the file system and not from svn. I don't always name my checkout directories the same as my branches and I frequently use symlinks to mark which one I'm currently using the most.

    Can your plugin instead use "svn info" to pull the actual branch name? It could pull the URL from "svn info" and then assume that the next path segment after "/branches" (or /branch, etc) is the actual branch name?
    • Can your plugin instead use "svn info" to pull the actual branch name?

      Turns out that's quite straightforward. Here's my version (below) modified to do that:

      let branch = matchstr(system('svn info .'), '\v(branch[^/]*/)@<=[^/]*')
      if branch != ''
        execute '1s//Branch: ' . branch . '\r\r -  '
      endif
      startinsert!
      • forgive my vi idiocy, but I get this error message when I use that:


        "svn-commit.2.tmp" 4L, 63C
        Error detected while processing function AddBranchName:
        line 3:
        E486: Pattern not found: retired

        Here's my full plugin source:
         

        function! AddBranchName()
            let branch = matchstr(system('svn info .'), '\v(branch[^/]*/)@<=[^/]*')
            if branch != ''
              execute '1s//Branch: ' . branch . '\r\r -  '
            endif
            startinsert!
        endfunction

        • I get this error message

          Ooops, my fault! s// repeats the most recent match; I'm guessing you previously searched for “retired” and that you have something in your Vim config which remembers the search register across sessions.

          Make that s/^/ instead. Sorry about that.

          my full plugin source

          Note you don't need that function definition around it; what I posted was intended to be the complete plug-in. See below for the explanation.