【问题标题】:Mercurial log with one-linersMercurial 单行日志
【发布时间】:2011-04-04 06:17:52
【问题描述】:

常规的hg log 命令给出每个变更集至少 4 行的输出。例如

changeset:   238:03a214f2a1cf
user:        My Name <my.name@example.com>
date:        Thu Aug 26 09:49:32 2010 +0200
summary:     Added tag v1.1 for changeset f22fd3974361

我的意思是要记住,有一个命令可以以更紧凑的方式打印日志,每个变更集只有一行。一种基本上可以保存在 changelog.txt 文件中的格式,它看起来不错。

存在吗?还是我将它与我在 git 中看到的东西或其他东西混合在一起?

【问题讨论】:

  • 对于更新日志样式,请尝试log --style changelog :)
  • 试试这个:hg log -T "\t{date|shortdate}\t[{rev}]\t{author|user}\t{desc}\n"

标签: mercurial command


【解决方案1】:
 hg log --style compact

您还可以使用模板以不同的格式显示注销

hg help templates

如果您只想显示节点 ID,请执行以下操作

hg log --template "{node}\n"

【讨论】:

    【解决方案2】:

    即使原始评论包含多行,也要在一行上获得描述,请结合如下分割线和连接功能:

    {join(splitlines(desc), ' ')}
    

    这是我用来将数据提取为 CSV 的示例:

    hg log --template "{node};{date|shortdate};{branch};{author};{join(splitlines(desc), ' ')};{diffstat};files: {join(files, ', ')}\n"
    

    【讨论】:

      【解决方案3】:

      您可以将hg log 与 --template 选项一起使用,例如:

      hg log --template '{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n'
      

      这应该显示类似这样的内容(来自我在本地转换为 hg 存储库的 GNU Emacs 主干的示例):

      $ hg log --limit 5 --template '{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n'
      36ab2e3f8ebd | 2010-09-08 16:54:00 +0200 | agustin: textmodes/ispell.el (ispell-valid-dictionary-list): Simplify logic.
      9f3ac6d4a645 | 2010-09-08 16:42:54 +0200 | michael: Migrate to Tramp 2.2.  Rearrange load dependencies.
      8c696d2a7695 | 2010-09-07 20:01:23 +0200 | agustin: Make sure original ispell arg list is initialized in (ispell-start-process).
      b5f110747072 | 2010-09-07 06:23:16 +0000 | yamaoka: gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
      b53cfb7d099e | 2010-09-07 01:20:19 +0000 | yamaoka: gnus-async.el (gnus-html-prefetch-images): Autoload it when compiling; (gnus-async-article-callback): Fix typo.
      $
      

      一旦你有了一个用于变更集的单行摘要的漂亮模板,你就可以在你的 ~/.hgrc 文件中添加一个命令 alias,如下所示:

      [alias]
      shortlog = log --template '{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n'
      

      安装别名后,您现在可以输入hg shortlog、hg short 甚至hg shor(以唯一标识hg shortlog 而不是hg showconfig)和所有常用的“日志”命令选项。例如,现在应该可以输入:

      $ hg short -r 100:103
      db9f8efcf689 | 1990-09-14 19:07:14 +0000 | jimb: *** empty log message ***
      5874bf15e07d | 1990-09-19 18:22:41 +0000 | gnulists: Initial revision
      797d304414fd | 1990-09-27 21:17:59 +0000 | mtr: Initial revision
      b2656b7830e4 | 1990-10-09 02:52:33 +0000 | rms: *** empty log message ***
      $
      

      甚至是使用标签名称的东西(例如来自 mercurial 船员存储库本身):

      keramida@kobe:/hg/mercurial/crew$ hg short -r 1.4 -r 1.5 -r 1.6
      31ec469f9b55 | 2009-11-16 21:25:36 +0100 | mg: i18n-ja: fixed bad indentation
      ff2704a8ded3 | 2010-03-05 17:24:52 -0600 | mpm: mq: drop -Q in favor of --mq only
      f786fc4b8764 | 2010-06-29 12:12:34 +0200 | mads: log: follow filenames through renames (issue647)
      keramida@kobe:/hg/mercurial/crew$
      

      【讨论】:

      • 更多信息见this guide,还有hg help templates。
      猜你喜欢
      • 2011-03-24
      • 2022-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-03
      • 2022-07-22
      相关资源
      最近更新 更多