Merge remote branch 'refs/remotes/AlexeyVoinov/git-svn-fixes'
This commit is contained in:
commit
db53f15cb5
1 changed files with 48 additions and 20 deletions
68
magit.el
68
magit.el
|
@ -297,6 +297,9 @@ Many Magit faces inherit from this one by default."
|
||||||
(defun magit-get (&rest keys)
|
(defun magit-get (&rest keys)
|
||||||
(magit-git-string "config" (magit-concat-with-delim "." keys)))
|
(magit-git-string "config" (magit-concat-with-delim "." keys)))
|
||||||
|
|
||||||
|
(defun magit-get-all (&rest keys)
|
||||||
|
(magit-git-lines "config" "--get-all" (magit-concat-with-delim "." keys)))
|
||||||
|
|
||||||
(defun magit-set (val &rest keys)
|
(defun magit-set (val &rest keys)
|
||||||
(if val
|
(if val
|
||||||
(magit-git-string "config" (magit-concat-with-delim "." keys) val)
|
(magit-git-string "config" (magit-concat-with-delim "." keys) val)
|
||||||
|
@ -2238,6 +2241,27 @@ merge will be squashed."
|
||||||
(defun magit-svn-enabled ()
|
(defun magit-svn-enabled ()
|
||||||
(not (null (magit-get-svn-ref-info))))
|
(not (null (magit-get-svn-ref-info))))
|
||||||
|
|
||||||
|
(defun magit-get-svn-local-ref (url)
|
||||||
|
(let ((branches (cons (magit-get "svn-remote" "svn" "fetch")
|
||||||
|
(magit-get-all "svn-remote" "svn" "branches")))
|
||||||
|
(base-url (magit-get "svn-remote" "svn" "url"))
|
||||||
|
(result nil))
|
||||||
|
(while branches
|
||||||
|
(let* ((pats (split-string (pop branches) ":"))
|
||||||
|
(src (replace-regexp-in-string "\\*" "\\\\(.*\\\\)" (car pats)))
|
||||||
|
(dst (replace-regexp-in-string "\\*" "\\\\1" (cadr pats)))
|
||||||
|
(base-url (replace-regexp-in-string "\\+" "\\\\+" base-url))
|
||||||
|
(pat1 (concat "^" src "$"))
|
||||||
|
(pat2 (cond ((equal src "") (concat "^" base-url "$"))
|
||||||
|
(t (concat "^" base-url "/" src "$")))))
|
||||||
|
(cond ((string-match pat1 url)
|
||||||
|
(setq result (replace-match dst nil nil url))
|
||||||
|
(setq branches nil))
|
||||||
|
((string-match pat2 url)
|
||||||
|
(setq result (replace-match dst nil nil url))
|
||||||
|
(setq branches nil)))))
|
||||||
|
result))
|
||||||
|
|
||||||
(defvar magit-get-svn-ref-info-cache nil
|
(defvar magit-get-svn-ref-info-cache nil
|
||||||
"As `magit-get-svn-ref-info' might be considered a quite
|
"As `magit-get-svn-ref-info' might be considered a quite
|
||||||
expensive operation a cache is taken so that `magit-status'
|
expensive operation a cache is taken so that `magit-status'
|
||||||
|
@ -2254,31 +2278,35 @@ of `magit-get-svn-ref-info-cache'."
|
||||||
(url)
|
(url)
|
||||||
(revision))
|
(revision))
|
||||||
(when fetch
|
(when fetch
|
||||||
(setq magit-get-svn-ref-info-cache
|
(let* ((ref (cadr (split-string fetch ":")))
|
||||||
(list
|
(ref-path (file-name-directory ref))
|
||||||
(cons 'ref-path (file-name-directory
|
(trunk-ref-name (file-name-nondirectory ref)))
|
||||||
(cadr (split-string fetch ":"))))
|
(setq magit-get-svn-ref-info-cache
|
||||||
(cons 'trunk-ref-name (file-name-nondirectory
|
(list
|
||||||
(cadr (split-string fetch ":"))))
|
(cons 'ref-path ref-path)
|
||||||
;; get the local ref from the log. This is actually
|
(cons 'trunk-ref-name trunk-ref-name)
|
||||||
;; the way that git-svn does it.
|
;; get the local ref from the log. This is actually
|
||||||
(cons 'local-ref-name
|
;; the way that git-svn does it.
|
||||||
(with-temp-buffer
|
(cons 'local-ref
|
||||||
(insert (magit-git-string "log" "--first-parent"))
|
(with-temp-buffer
|
||||||
(goto-char (point-min))
|
(insert (or (magit-git-string "log" "--first-parent")
|
||||||
(when (re-search-forward "git-svn-id: \\(.+/\\(.+?\\)\\)@\\([0-9]+\\)" nil t)
|
""))
|
||||||
(setq url (match-string 1)
|
(goto-char (point-min))
|
||||||
revision (match-string 3))
|
(cond ((re-search-forward "git-svn-id: \\(.+/.+?\\)@\\([0-9]+\\)" nil t)
|
||||||
(match-string 2))))
|
(setq url (match-string 1)
|
||||||
(cons 'revision revision)
|
revision (match-string 2))
|
||||||
(cons 'url url)))))))
|
(magit-get-svn-local-ref url))
|
||||||
|
(t
|
||||||
|
(setq url (magit-get "svn-remote" "svn" "url"))
|
||||||
|
nil))))
|
||||||
|
(cons 'revision revision)
|
||||||
|
(cons 'url url))))))))
|
||||||
|
|
||||||
(defun magit-get-svn-ref (&optional use-cache)
|
(defun magit-get-svn-ref (&optional use-cache)
|
||||||
"Get the best guess remote ref for the current git-svn based
|
"Get the best guess remote ref for the current git-svn based
|
||||||
branch."
|
branch."
|
||||||
(let ((info (magit-get-svn-ref-info use-cache)))
|
(let ((info (magit-get-svn-ref-info use-cache)))
|
||||||
(concat (cdr (assoc 'ref-path info))
|
(cdr (assoc 'local-ref info))))
|
||||||
(cdr (assoc 'local-ref-name info)))))
|
|
||||||
|
|
||||||
;;; Resetting
|
;;; Resetting
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue