monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] emacs code for add-change-log-entry


From: Sebastian Rose
Subject: Re: [Monotone-devel] emacs code for add-change-log-entry
Date: Mon, 04 Dec 2006 23:18:39 +0100

So here it comes:

This would (nearly) be my suggestion for the function
 monotone-vc-update-change-log() in monotone.el:

--8<-----------------------------------------------
(defun monotone-vc-update-change-log ()
  "Edit the monotone change log."
  (interactive)
  (let ((mtn-top (monotone-find-_MTN-top)))
    (when (not mtn-top)
      (error "Unable to find _MTN directory"))
    (let ((logfile (concat mtn-top "_MTN/log")))
      (add-change-log-entry-other-window nil logfile))))
----------------------------------------------->8--

This works - but it writes to the file ~/current/_MTN/log, which is in
my case, as you remember, a symbolic link. So better would be

--8<-----------------------------------------------
(defun monotone-vc-update-change-log ()
  "Edit the monotone change log."
  (interactive)
  (let ((mtn-top (monotone-find-_MTN-top)))
    (when (not mtn-top)
      (error "Unable to find _MTN directory"))
    (let ((logfile
           (concat (file-name-as-directory (concat
                    (file-truename (file-name-as-directory mtn-top))
"_MTN") ) "log")))
      (add-change-log-entry-other-window nil logfile))))
----------------------------------------------->8--

and the very best IMO would be to alter the function, that finds mtn-top
to return a real path without links in it.

I also found, that  monotone-_MTN-revision() uses hardcoded filename
separators i.e. it will not work on Windows or Vax systems, right?

It should be

--8<-----------------------------------------------
(defun monotone-_MTN-revision ()
  "The current revision as read from '_MTN/revision'."
  (let ((dir (monotone-find-_MTN-top)))
    (when (not dir)
      (error "No _MTN top directory."))
    (let ((file (concat (file-name-as-directory (concat
(file-name-as-directory dir) "_MTN")) "revision")))
      (with-temp-buffer
        (insert-file-contents-literally file nil)
        (setq monotone-_MTN-revision (buffer-substring 1 41)))
      monotone-_MTN-revision)))
----------------------------------------------->8--

Actually there was another hardcoded path somewhere in function
monotone-vc-commit(args).

And the joined function, now called monotone-add-change-log-entry()
would be:

--8<-----------------------------------------------
(defun monotone-add-change-log-entry()
  "Searches in buffers default-directory and above for a directory
named '_MTN'. If it exists, monotone-add-change-log-entry calls
add-change-log-entry interactively with apropriate arguments.
Otherwise interactively calls add-change-log-entry the normal way.
So one can just bind this function to the keys, that call
add-change-log-entry now, and it will work just fine."
  (interactive)
  (let ((filename buffer-file-name)
        (mtn-top (monotone-find-_MTN-top))
        (original-default-directory default-directory)
        (original-change-log-filename nil))
    (if (boundp 'change-log-default-name)
        (setq original-change-log-filename change-log-default-name))
    (unwind-protect
        (progn
          (if mtn-top
              (let ((logdir
                     (concat
                      (file-truename (file-name-as-directory mtn-top))
"_MTN")))
                (setq change-log-default-name (concat
(file-name-as-directory logdir) "log"))
                (let ((default-directory logdir))
                  (call-interactively 'add-change-log-entry)))
            (call-interactively 'add-change-log-entry)))
      (setq default-directory original-default-directory)
      (setq change-log-default-name original-change-log-filename))))
----------------------------------------------->8--


The changed file is appended to this message. I think the easiest way to
check it would be ediff the original and my version and test it. I don't
know - is it possible to just commit/upload it somewhere people working
on monotone.el recognize it?

-- 
Sebastian Rose <address@hidden>

Attachment: monotone.el
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]