代码之家  ›  专栏  ›  技术社区  ›  Laurynas Biveinis

emacs:有没有一种方法可以从diff生成一个框架变更日志?

  •  6
  • Laurynas Biveinis  · 技术社区  · 15 年前

    我希望在版本控制中使用源代码时,部分自动创建GNU风格的变更日志条目。这个 add-changelog-entry-other-window 一次使用一个文件,您必须访问该文件才能使用它。

    相反,我想看到的是有一个命令,它将接受 diff -u -p (或与VC模式集成,以便处理 svn diff 等)并立即创建所有骨架条目。

    例如,如果 svn status 显示

    D file1.c
    M file2.c
    A file3.c
    

    命令将创建

    2009-09-05  My Name <my.email>
    
          * file1.c: Removed.
          * file2.c: WRITE YOUR CHANGES HERE
          * file3.c: New.
    

    更好的是,如果它能够以某种语言解析更改后的文件,那么它可以提供:

      * file2.c (new_function): New function.
      (deleted_function): Removed.
      (changed_function): WRITE YOUR CHANGES HERE
    

    我找到了 this feature in Emacs manual 但是我不知道如何在这里应用它。

    有什么建议吗?谢谢。

    编辑:建议一个答案 vc-update-change-log . 不幸的是,它只支持cvs,并且通过查询已经提交的vc日志来创建changelog条目。因此,即使它支持SVN和其他服务,也不可能在同一提交中提交更改和变更日志。

    edit2:显然,添加changelog entry other window(c-x 4 a)不仅可以从访问过的文件工作,还可以从涉及该文件的diff hunk工作。( Source )这几乎就是我要找的。这与遍历所有块的elisp循环一起应该解决它。

    4 回复  |  直到 11 年前
        1
  •  2
  •   Charlie Martin    15 年前

    我不知道有什么函数可以做到这一点,但它应该很容易实现。基本上,你想

    • 获取更改的文件
    • 对于每个文件,调用 add-change-log
    "Find change log file, and add an entry for today and an item for this file.
    Optional arg WHOAMI (interactive prefix) non-nil means prompt for user
    name and email (stored in `add-log-full-name' and `add-log-mailing-address').
    
    Second arg FILE-NAME is file name of the change log.
    If nil, use the value of `change-log-default-name'.
    
    Third arg OTHER-WINDOW non-nil means visit in other window.
    
    Fourth arg NEW-ENTRY non-nil means always create a new entry at the front;
    never append to an existing entry.  Option `add-log-keep-changes-together'
    otherwise affects whether a new entry is created.
    
    Option `add-log-always-start-new-record' non-nil means always create a
    new record, even when the last record was made on the same date and by
    the same person.
    
    The change log file can start with a copyright notice and a copying
    permission notice.  The first blank line indicates the end of these
    notices.
    
    Today's date is calculated according to `add-log-time-zone-rule' if
    non-nil, otherwise in local time."

    所以魔法密码看起来像

    (apply 'make-magic-change-log-entry changed-files-list)
    

    make-magic-change-log-entry 简单的咖喱 添加更改日志 函数的唯一参数是 file-name “你设置了其他的。

        2
  •  3
  •   viam0Zah    15 年前

    有一个函数 vc-update-change-log 它从版本控制日志条目中自动生成更改日志条目。

        3
  •  3
  •   SamB som-snytt    11 年前

    diff-add-change-log-entries-other-window 记录的目的是准确执行您在edit2中提到的操作:

    diff-add-change-log-entries-other-window is an interactive compiled
    Lisp function in `diff-mode.el'.
    
    (diff-add-change-log-entries-other-window)
    
    Iterate through the current diff and create ChangeLog entries.
    I.e. like `add-change-log-entry-other-window' but applied to all hunks.
    

    不幸的是,对于新的文件,比如说,它不能很好地工作:它甚至没有在骨架变更日志条目中包含此类文件的文件名。

    您可能会对gcc的mklog脚本有更好的运气,您可以从中获得 http://gcc.gnu.org/viewcvs/gcc/trunk/contrib/mklog .

        4
  •  2
  •   Lluis    15 年前

    我写了一个函数来做一些类似于你所说的事情。你可以在 http://www.emacswiki.org/emacs/log-edit-fill