From be7325db2d7606cfdb2709f81e582d55d8fbec7f Mon Sep 17 00:00:00 2001 From: Bogolisk Date: Mon, 10 Dec 2012 07:06:29 -0500 Subject: [PATCH] cleanup svn remote handlers --- Makefile | 6 ++++-- egg-git.el | 31 ++++++++++++++----------------- egg-svn.el | 31 +++++++++++++++++++------------ 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 264386c..ace85fa 100644 --- a/Makefile +++ b/Makefile @@ -37,8 +37,10 @@ clean : doc.clean loaddeps : $(LOAD_DEPS) -egg-reload.el : $(LOAD_DEPS) +egg-reload.el : Makefile $(LOAD_DEPS) @echo Generating $@ - @cat $^ | tsort | sed -nre 's/^(.+)$$/\(load "\1"\)/p' > $@ + @cat $(filter-out $<, $^) | tsort | sed -nre 's/^(.+)$$/\(load "\1"\)/p' > $@ + @echo "(defun egg-reload ()\n (interactive)" >> $@ + @echo " (load \"egg-reload\"))\n" >> $@ -include $(DEPS) diff --git a/egg-git.el b/egg-git.el index 918abfa..1e0660c 100644 --- a/egg-git.el +++ b/egg-git.el @@ -790,7 +790,7 @@ as repo state instead of re-read from disc." (and (egg-git-dir) (cadr (assoc attr (egg-config-section type name))))) -(defvar egg-speciall-remote-handlers nil) +(defvar egg-special-remote-handlers nil) (defun egg-tracking-target (branch &optional mode) (let ((remote (egg-config-get "branch" "remote" branch)) @@ -800,7 +800,8 @@ as repo state instead of re-read from disc." (setq rbranch (egg-rbranch-name rbranch-full)) (cond ((null mode) (concat remote "/" rbranch)) ((eq :name-only mode) rbranch) - (t (or (run-hook-with-args-until-success 'egg-speciall-remote-handlers rbranch-full remote) + (t (if (setq remote (run-hook-with-args-until-success 'egg-special-remote-handlers + remote rbranch-full)) (list rbranch remote))))))) (defun egg-complete-get-all-refs (prefix &optional matches) @@ -901,7 +902,7 @@ REMOTE-REF-PROPERTIES and REMOTE-SITE-PROPERTIES." ;; 8: is annotated tag '(1 2 3 4 5 6 7) "show-ref" "-d")) (symbolic-HEAD (egg-get-symbolic-HEAD)) - annotated-tags refs special-names r-remote r-branch) + annotated-tags refs) ;; remove the annotated tags from the list (setq refs-desc-list (delq nil @@ -919,7 +920,8 @@ REMOTE-REF-PROPERTIES and REMOTE-SITE-PROPERTIES." (mapcar (lambda (desc) (let ((full-name (cdr (assq 1 desc))) (name (cdr (or (assq 5 desc) (assq 7 desc)))) - (remote (cdr (assq 6 desc)))) + (remote (cdr (assq 6 desc))) + short-name) (cond ((assq 2 desc) ;; head (cons full-name @@ -941,26 +943,21 @@ REMOTE-REF-PROPERTIES and REMOTE-SITE-PROPERTIES." tag-properties)))) ((assq 4 desc) ;; remote + (setq short-name (substring name (length remote))) + (setq remote (or (run-hook-with-args-until-success + 'egg-special-remote-handlers remote full-name short-name) + remote)) (cons full-name - (progn - (setq special-names - (or (cdr (run-hook-with-args-until-success - 'egg-speciall-remote-handlers full-name remote - (substring name (length remote)))) - (list remote (substring name (length remote))))) - (setq r-remote (nth 0 special-names) - r-branch (nth 1 special-names)) - (concat (if (stringp r-remote) - (apply 'propertize r-remote + (concat (if (stringp remote) + (apply 'propertize remote :ref (cons name :remote) remote-site-properties) ;; svn has no remote namee "") - (apply 'propertize r-branch + (apply 'propertize short-name :full-name full-name :ref (cons name :remote) - remote-ref-properties)) - ))) + remote-ref-properties)))) ((assq 7 desc) ;; stash (cons full-name diff --git a/egg-svn.el b/egg-svn.el index cba1b77..dafe7ab 100644 --- a/egg-svn.el +++ b/egg-svn.el @@ -346,18 +346,25 @@ output processing function for `egg--do-handle-exit'." (defsubst egg-svn-full-to-remote (full-ref) (file-name-nondirectory (directory-file-name (file-name-directory full-ref)))) -(defun egg-svn-handle-svn-remote (branch remote &rest names) - (if (or (egg-git-to-string "config" "--get" (concat "svn-remote." remote ".url")) - (and (member branch (egg-svn-all-full-refs)) - (setq remote (egg-svn-full-to-remote branch)))) - (cons branch (mapcar (lambda (name) - (propertize name - :svn-remote (egg-git-svn-remote-name) - :push #'egg-push-to-svn - :fetch #'egg-fetch-from-svn)) - (cons remote names))))) - -(add-hook 'egg-speciall-remote-handlers #'egg-svn-handle-svn-remote) +(defun egg-svn-handle-svn-remote (remote branch &rest names) + (when (or (egg-git-to-string "config" "--get" (concat "svn-remote." remote ".url")) + (and (stringp branch) + (member branch (egg-svn-all-full-refs)) + (setq remote (egg-svn-full-to-remote branch)))) + (setq remote (propertize remote + :svn-remote (egg-git-svn-remote-name) + :push #'egg-push-to-svn + :fetch #'egg-fetch-from-svn)) + (mapc (lambda (name) + (add-text-properties 0 (length name) + (list :svn-remote (egg-git-svn-remote-name) + :push #'egg-push-to-svn + :fetch #'egg-fetch-from-svn) + name)) + names) + remote)) + +(add-hook 'egg-special-remote-handlers #'egg-svn-handle-svn-remote)