Permalink
Browse files

Adds management of SVN externals through magit-svn-mode

Assuming the user has cloned all of their SVN externals into a single
directory which can be specified by magit-svn-externals-dir and then
symlinked in the appropriate places, "x" for "Fetch Externals" is added
to the menu and individually fetches and rebases each git svn repository
for the externals.
  • Loading branch information...
danlamanna committed Mar 3, 2013
1 parent 6ea4da6 commit 1c959240adb109db9bc30c171da2fe3fd2dcdc7e
Showing with 29 additions and 1 deletion.
  1. +29 −1 magit-svn.el
@@ -30,7 +30,13 @@

(require 'magit)
(eval-when-compile
(require 'cl))
(require 'cl)
(require 'find-lisp))

(defcustom magit-svn-externals-dir ".git_externals"
"Directory from repository root that stores cloned SVN externals."
:group 'magit
:type 'string)

;; git svn commands

@@ -189,6 +195,27 @@ If USE-CACHE is non nil, use the cached information."
" @ "
(cdr (assoc 'revision svn-info))))))

(defun magit-svn-fetch-externals()
"Loops through all external repos found by `magit-svn-external-directories'
and runs git svn fetch, and git svn rebase on each of them."
(interactive)
(let ((externals (magit-svn-external-directories)))
(if (not externals)
(message "No SVN Externals found. Check magit-svn-externals-dir.")
(dolist (external externals)
(let ((default-directory (file-name-directory external)))
(magit-run-git "svn" "fetch")
(magit-run-git "svn" "rebase")))
(magit-refresh))))

(defun magit-svn-external-directories()
"Returns all .git directories within `magit-svn-externals-dir'"
(require 'find-lisp)
(find-lisp-find-files-internal (expand-file-name magit-svn-externals-dir)
'(lambda(file dir)
(string-equal file ".git"))
'find-lisp-default-directory-predicate))

(easy-menu-define magit-svn-extension-menu
nil
"Git SVN extension menu"
@@ -214,6 +241,7 @@ If USE-CACHE is non nil, use the cached information."
(magit-key-mode-insert-action 'svn "s" "Find rev" 'magit-svn-find-rev)
(magit-key-mode-insert-action 'svn "B" "Create branch" 'magit-svn-create-branch)
(magit-key-mode-insert-action 'svn "T" "Create tag" 'magit-svn-create-tag)
(magit-key-mode-insert-action 'svn "x" "Fetch Externals" 'magit-svn-fetch-externals)
(magit-key-mode-insert-switch 'svn "-n" "Dry run" "--dry-run")

;; generate and bind the menu popup function

0 comments on commit 1c95924

Please sign in to comment.