コミットログに自動でブランチ名を入れる2

http://d.hatena.ne.jp/yuto_sasaki/20120127/1327650259 を改良

;; http://hogepiyo.cmo/svn/hoge/branches/hogepiyo/dottokom
;; dsvn defadvice
;; Emacs/Lisp/Drill - Emacsグループ <http://emacs.g.hatena.ne.jp/k1LoW/200810>
(defadvice svn-commit (around svn-commit-around activate)
  (goto-char (point-min))
  (if (re-search-forward "\\([^/ ]+\\)/\\(trunk\\|branches\\|tags\\)\\(/[^/ ]+\\)?" nil t)
      (let (
            (component-name (match-string-no-properties 1))
            (branch (match-string-no-properties 2))
            (branch-name (match-string-no-properties 3))
            )
        (if (string= "trunk" branch)
            (kill-new (concat
                       "[" component-name "][trunk]"
                       ))
          (kill-new (concat
                     "[" component-name "]"
                     "[" branch branch-name "]"))
          )
        )
    (kill-new "[ ][trunk]")
    )
  ad-do-it
  (yank)
  )