Mercurial 中的 `git log --graph --decorate --oneline --all` 是什么?
What is the Mercurial equivalent to `git log --graph --decorate --oneline --all`?
我该怎么做
git log --graph --decorate --oneline --all
在 mercurial 中?
- 我想要
--graph
,所以我可以看到提交之间的关系
- 我想要
--decorate
以便它在每次提交时为每个提示 and/or 打印分支名称,包括本地远程跟踪分支,它准确显示任何已配置远程的情况(我有两个遥控器);它还显示了像HEAD这样的特价商品,我也想看
- 我想要
--oneline
,这样我就可以在屏幕上看到很多节点
- 我想要
--all
,这样我就可以看到所有分支,而不仅仅是我签出的那一个
- 包括书签
- 包括遥控器上的情况(对比本地情况)
没有直接的等价物(或者,如果有,我想知道 :-))。
其中一些仅仅是因为某些事情不适用于 Mercurial,其中任何给定的提交都在一个且只有一个分支上,并且 hg log
默认显示所有分支上的所有提交。类似地,没有 HEAD
这样的东西:有一个当前分支和一个当前提交,您可以将其命名为分支 .
或修订 .
。这些功能类似于 HEAD
,只是它们不能是匿名分支。
无法单独查看远程,因为没有远程跟踪分支。要么你有任何传入的提交(hg incoming
什么都不打印)所以它已经在日志输出中,要么你没有(所以你必须 运行 hg pull
,通常没有 -u
,得到,1才能看到).
当前提交在 hg log -G
(又名 hg glog
)中显示为 @
而不是 o
,因此这就是您识别它的方式。
这是我用的(不是很满意,我总是怀念拓扑排序):
[alias]
# lga comes from
# http://jamie-wong.com/2012/07/11/my-mercurial-setup-and-workflow-at-khan-academy/
lga = glog --style ~/.hgstuff/map-cmdline.lg
URL 目前仍然有效,但这是我的 map-cmdline.lg
文件的内容。请注意,颜色是硬编码的;在我写这篇文章的时候,hg
没有命名颜色词(可能仍然没有,我对最新的汞更新已经过时了):
changeset = '3[0;31m{rev}:{node|short}:{phase} {branches}{bookmarks}{tags} 3[0;34m{author|person}3[0m\n{desc|firstline|strip} 3[0;32m({date|age})3[0m\n\n'
changeset_verbose = '3[0;31m{rev}:{node}:{phase} 3[0;34m{author|person}3[0m {desc|firstline|strip} 3[0;32m({date|age}) {branches}{bookmarks}{tags}\n\n'
start_branches = ' '
branch = '3[0;32m{branch}3[0m'
start_bookmarks = ' '
bookmark = '3[0;32m[{bookmark}]3[0m '
last_bookmark = '3[0;31m[{bookmark}]3[0m'
start_tags = ' '
tag = '3[0;32m{tag}3[0m, '
last_tag = '3[0;32m{tag}3[0m'
1请注意,如果您尝试将某些 Hg 工作流程等同于 Git 等价物,则此处存在一个小缺陷,反之亦然。特别是,hg incoming
可以列出 5 个提交,然后 hg pull
可以获取这 5 个中的 12 个,因为有人在这两个步骤之间又推送了 7 个。 Git 单独的 fetch
步骤和远程跟踪分支为您解决了这个问题。另一种处理它的方法,我出于其他原因使用了一段时间,是保留一个本地中间 Mercurial 存储库,用于从共享存储库中拉取和推送。
也就是说,如果我们指定repo U作为上游共享仓库,我们在本地克隆一个I,然后克隆一个I in W 用于工作。然后我们更新I(使用hg pull -u
),然后在W中查看hg incoming
(和hg outgoing
)为了速度和一致性。最好直接从 W 推送到 U 以避免不得不对提交阶段大惊小怪,但由于其他原因这很痛苦。我从来没有找到一个真正令人满意的设置,并且在现场工作时放弃了中间存储库:它更多地用于处理慢速网络。
使用 Mercurial 3.8 只需将 .hgrc
配置为
[experimental]
graphstyle.parent = |
graphstyle.grandparent = '
graphstyle.missing =
graphshorten = true
与适当的template会得到
$ hg log --graph --template "{rev}{ifeq(branch,'default','',' {branch}')}{if(bookmarks,' {bookmarks}')}{if(tags,' {tags}')} - {desc|firstline}"
...
| o 20881 - transaction: add onclose/onabort hook for pre-close logic
| o 20880 - clone: put streaming clones in a transaction
| o 20879 - fncache: remove the rewriting logic
| o 20878 - pull: prevent duplicated entry in `op.pulledsubset`
| o 20877 - bundle2: part params
| o 20876 - bundle2: support for bundling and unbundling payload
| o 20875 - merge with stable
|/|
o | 20874 stable - Added signature for changeset 3f83fc5cfe71
o | 20873 stable - Added tag 2.9.2 for changeset 3f83fc5cfe71
o | 20872 stable 2.9.2 - backout: correct commit status of no changes made (BC)
o | 20871 stable - backout: document return code of merge conflict
| o 20870 - merge with stable
|/|
o | 20869 stable - i18n: fix "% inside _()" problems
o | 20868 stable - i18n: fix "% inside _()" problems
o | 20867 stable - merge: fix lack of "%s" in format string causing TypeError a
o | 20866 stable - i18n-pt_BR: synchronized with c57c9cece645
o | 20865 stable - i18n-ja: synchronized with e259d4c462b5
| o 20864 - bundle2: support unbundling empty part
| o 20863 - revset: raise ValueError when calling min or max on empty smartset
| o 20862 - revpair: smartset compatibility
| o 20861 - revsetbenchmark: add entry for ::rev::
:
我用这个别名
[alias]
ll = log -l 12 --graph --template "{rev}{ifeq(branch,'default','',' {branch}')}{if(bookmarks,' {bookmarks}')}{if(tags,' {tags}')} - {desc|firstline}"
所以
$ hg ll
o 29100 @default tip - templater: add separate() template function
o 29099 - bookmarks: jettison bmstore's write() method per deprecation policy
o 29098 - merge with stable
|\
| o 29097 stable - deprecation: gate deprecation warning behind devel configurn
| |
| ~
o 29096 - crecord: update downarrowshiftevent() docstring, remove todo
o 29095 - crecord: remove things that don't happen in functions from their docs
o 29094 - crecord: remove skipfolded keyword argument from patchnode.previtem()
o 29093 - crecord: update a copy-pasted comment in downarrowshiftevent()
o 29092 - crecord: drop the version condition for amend
o 29091 - crecord: add/remove blank lines (coding style)
o 29090 - localrepo: jettison parents() method per deprecation policy (API)
o 29089 - revset: define _parsealias() in _aliasrules class
|
~
我觉得很像Git
$ git log --graph --decorate --oneline --all
* d32f204 (origin/master, origin/HEAD) ; Remove instrumentation of tramp.el
* 4c7f329 ; Remove instrumentation of tramp-tests.el
* 51c816b Fix a problem of tramp-tests on hydra.
* 62d7aca Pacify byte-compiler in lisp/vc
* 9e6302c ; Merge from origin/emacs-25
|\
* \ 6d0703a Merge from origin/emacs-25
|\ \
* | | 433d366 'text-quoting-style' now affects only ` and '
* | | 8939ae6 Revert "Fix spurious fontification of "for (; a * b;)" in CC Mod"
* | | cfa59d6 ; Instrument tramp-tests.el
* | | c20cc09 Move "Recent messages" earlier in report-emacs-bug
* | | a88f22b Pacify byte compiler in tramp.el
* | | c8b7a6a Merge from origin/emacs-25
|\ \ \
* \ \ \ 9418ab3 ; Merge from origin/emacs-25
|\ \ \ \
* | | | | d6dac36 ; Instrument tramp.el
* | | | | a8231e0 CC Mode now uses the new :after-hook feature of define-deriv-e
* | | | | 608f2bd ; Instrument tramp-tests.el
* | | | | fd45b52 Fix the jit-lock-fontify-now test names
:
第三次尝试,跟进@santiagopim。
是的,Mercurial 和 Git 使用了很多不同的概念(没有远程跟踪,默认拉|推转移所有分支),但是:如果你想看到|在更多方面使用 Mercurial Git-style 具有许多具有不同历史的远程回购,您可以:
- 使用 santiagopim 的优秀模板(或使用 torek 的提示将其扩展为全功能样式)
- 添加了 hgremotenames or remotebranches 扩展(简而言之,为每个提取的远程名称添加描述性书签)
获取类似于 Git 的日志。
试试 TortoiseHg。不是命令行,但是满足要求
它还突出显示了每个分支的提示(在 mercurial 中称为“heads”)。简单地显示分支名称不会突出显示它们,因为每个提交都有一个分支名称。
--graph
是 --graph
的汞。而--all
的效果是默认的
对于 --decorate
和 --oneline
我的 .hgrc
:
[alias]
la = log --graph --template {oneline}
[templatealias]
oneline = '{hash}{myBranch}{myBookmarks}{myTags} {name} {commitMsg}\n'
hash = "{label(ifeq(phase, 'secret', 'yellow', ifeq(phase, 'draft', 'blue', 'red')), node|short)}"
myBranch = "{ifeq(branch, 'default', '', label('green', ' ({branch})'))}"
myBookmarks = "{bookmarks % ' {bookmark}{ifeq(bookmark, active, '*')}{bookmark}'}"
myTags = "{label('yellow', tags % ' {tag}')}"
name = '{label('blue', author|person)}'
commitMsg = '{desc|firstline|strip}'
[experimental]
graphshorten = true
此解决方案不使用已弃用的 --style
参数。相反,正如您在别名部分中看到的那样,它是由 hg la
通过 --template
选项激活的。由于模板可以嵌套,oneline的名字会显示哈希、分支、书签、标签、提交者和提交信息。
在此示例中,哈希将根据提交的阶段改变颜色。
即使模板只是建议每行的最后一个换行符,hg 也会在每次提交之间放置一个额外的空行。 graphshorten = true
选项避免了这种情况。
你需要一个扩展来拥有类似于远程跟踪分支概念的东西。
这里是结果(缺少很棒的颜色):
| o 821ee2270f00 (lowercase_eats_whitespace) Robert Siemer add 'lowercase_eats_whitespace' directive
| o 9a86b49dc3ba (settings_passing) Robert Siemer restructure settings-passing in parsers and grako
|/
o 31664ddc943b Juancarlo Añez Merged in siemer/grako/siemer_fixup_regex (pull request #43)
|\
| o 317cea8eba42 (siemer_fixup_regex) Robert Siemer buffering.py: remove a superfluous regexp.DOTALL from a '[...]+' pattern
|/
o 31641ef78ba8 apalala Added tag 3.9.1 for changeset f33a2e80bb7d
o f33a2e80bb7d 3.9.1 apalala Getting ready for release 3.9.1
我该怎么做
git log --graph --decorate --oneline --all
在 mercurial 中?
- 我想要
--graph
,所以我可以看到提交之间的关系 - 我想要
--decorate
以便它在每次提交时为每个提示 and/or 打印分支名称,包括本地远程跟踪分支,它准确显示任何已配置远程的情况(我有两个遥控器);它还显示了像HEAD这样的特价商品,我也想看 - 我想要
--oneline
,这样我就可以在屏幕上看到很多节点 - 我想要
--all
,这样我就可以看到所有分支,而不仅仅是我签出的那一个- 包括书签
- 包括遥控器上的情况(对比本地情况)
没有直接的等价物(或者,如果有,我想知道 :-))。
其中一些仅仅是因为某些事情不适用于 Mercurial,其中任何给定的提交都在一个且只有一个分支上,并且 hg log
默认显示所有分支上的所有提交。类似地,没有 HEAD
这样的东西:有一个当前分支和一个当前提交,您可以将其命名为分支 .
或修订 .
。这些功能类似于 HEAD
,只是它们不能是匿名分支。
无法单独查看远程,因为没有远程跟踪分支。要么你有任何传入的提交(hg incoming
什么都不打印)所以它已经在日志输出中,要么你没有(所以你必须 运行 hg pull
,通常没有 -u
,得到,1才能看到).
当前提交在 hg log -G
(又名 hg glog
)中显示为 @
而不是 o
,因此这就是您识别它的方式。
这是我用的(不是很满意,我总是怀念拓扑排序):
[alias]
# lga comes from
# http://jamie-wong.com/2012/07/11/my-mercurial-setup-and-workflow-at-khan-academy/
lga = glog --style ~/.hgstuff/map-cmdline.lg
URL 目前仍然有效,但这是我的 map-cmdline.lg
文件的内容。请注意,颜色是硬编码的;在我写这篇文章的时候,hg
没有命名颜色词(可能仍然没有,我对最新的汞更新已经过时了):
changeset = '3[0;31m{rev}:{node|short}:{phase} {branches}{bookmarks}{tags} 3[0;34m{author|person}3[0m\n{desc|firstline|strip} 3[0;32m({date|age})3[0m\n\n'
changeset_verbose = '3[0;31m{rev}:{node}:{phase} 3[0;34m{author|person}3[0m {desc|firstline|strip} 3[0;32m({date|age}) {branches}{bookmarks}{tags}\n\n'
start_branches = ' '
branch = '3[0;32m{branch}3[0m'
start_bookmarks = ' '
bookmark = '3[0;32m[{bookmark}]3[0m '
last_bookmark = '3[0;31m[{bookmark}]3[0m'
start_tags = ' '
tag = '3[0;32m{tag}3[0m, '
last_tag = '3[0;32m{tag}3[0m'
1请注意,如果您尝试将某些 Hg 工作流程等同于 Git 等价物,则此处存在一个小缺陷,反之亦然。特别是,hg incoming
可以列出 5 个提交,然后 hg pull
可以获取这 5 个中的 12 个,因为有人在这两个步骤之间又推送了 7 个。 Git 单独的 fetch
步骤和远程跟踪分支为您解决了这个问题。另一种处理它的方法,我出于其他原因使用了一段时间,是保留一个本地中间 Mercurial 存储库,用于从共享存储库中拉取和推送。
也就是说,如果我们指定repo U作为上游共享仓库,我们在本地克隆一个I,然后克隆一个I in W 用于工作。然后我们更新I(使用hg pull -u
),然后在W中查看hg incoming
(和hg outgoing
)为了速度和一致性。最好直接从 W 推送到 U 以避免不得不对提交阶段大惊小怪,但由于其他原因这很痛苦。我从来没有找到一个真正令人满意的设置,并且在现场工作时放弃了中间存储库:它更多地用于处理慢速网络。
使用 Mercurial 3.8 只需将 .hgrc
配置为
[experimental]
graphstyle.parent = |
graphstyle.grandparent = '
graphstyle.missing =
graphshorten = true
与适当的template会得到
$ hg log --graph --template "{rev}{ifeq(branch,'default','',' {branch}')}{if(bookmarks,' {bookmarks}')}{if(tags,' {tags}')} - {desc|firstline}"
...
| o 20881 - transaction: add onclose/onabort hook for pre-close logic
| o 20880 - clone: put streaming clones in a transaction
| o 20879 - fncache: remove the rewriting logic
| o 20878 - pull: prevent duplicated entry in `op.pulledsubset`
| o 20877 - bundle2: part params
| o 20876 - bundle2: support for bundling and unbundling payload
| o 20875 - merge with stable
|/|
o | 20874 stable - Added signature for changeset 3f83fc5cfe71
o | 20873 stable - Added tag 2.9.2 for changeset 3f83fc5cfe71
o | 20872 stable 2.9.2 - backout: correct commit status of no changes made (BC)
o | 20871 stable - backout: document return code of merge conflict
| o 20870 - merge with stable
|/|
o | 20869 stable - i18n: fix "% inside _()" problems
o | 20868 stable - i18n: fix "% inside _()" problems
o | 20867 stable - merge: fix lack of "%s" in format string causing TypeError a
o | 20866 stable - i18n-pt_BR: synchronized with c57c9cece645
o | 20865 stable - i18n-ja: synchronized with e259d4c462b5
| o 20864 - bundle2: support unbundling empty part
| o 20863 - revset: raise ValueError when calling min or max on empty smartset
| o 20862 - revpair: smartset compatibility
| o 20861 - revsetbenchmark: add entry for ::rev::
:
我用这个别名
[alias]
ll = log -l 12 --graph --template "{rev}{ifeq(branch,'default','',' {branch}')}{if(bookmarks,' {bookmarks}')}{if(tags,' {tags}')} - {desc|firstline}"
所以
$ hg ll
o 29100 @default tip - templater: add separate() template function
o 29099 - bookmarks: jettison bmstore's write() method per deprecation policy
o 29098 - merge with stable
|\
| o 29097 stable - deprecation: gate deprecation warning behind devel configurn
| |
| ~
o 29096 - crecord: update downarrowshiftevent() docstring, remove todo
o 29095 - crecord: remove things that don't happen in functions from their docs
o 29094 - crecord: remove skipfolded keyword argument from patchnode.previtem()
o 29093 - crecord: update a copy-pasted comment in downarrowshiftevent()
o 29092 - crecord: drop the version condition for amend
o 29091 - crecord: add/remove blank lines (coding style)
o 29090 - localrepo: jettison parents() method per deprecation policy (API)
o 29089 - revset: define _parsealias() in _aliasrules class
|
~
我觉得很像Git
$ git log --graph --decorate --oneline --all
* d32f204 (origin/master, origin/HEAD) ; Remove instrumentation of tramp.el
* 4c7f329 ; Remove instrumentation of tramp-tests.el
* 51c816b Fix a problem of tramp-tests on hydra.
* 62d7aca Pacify byte-compiler in lisp/vc
* 9e6302c ; Merge from origin/emacs-25
|\
* \ 6d0703a Merge from origin/emacs-25
|\ \
* | | 433d366 'text-quoting-style' now affects only ` and '
* | | 8939ae6 Revert "Fix spurious fontification of "for (; a * b;)" in CC Mod"
* | | cfa59d6 ; Instrument tramp-tests.el
* | | c20cc09 Move "Recent messages" earlier in report-emacs-bug
* | | a88f22b Pacify byte compiler in tramp.el
* | | c8b7a6a Merge from origin/emacs-25
|\ \ \
* \ \ \ 9418ab3 ; Merge from origin/emacs-25
|\ \ \ \
* | | | | d6dac36 ; Instrument tramp.el
* | | | | a8231e0 CC Mode now uses the new :after-hook feature of define-deriv-e
* | | | | 608f2bd ; Instrument tramp-tests.el
* | | | | fd45b52 Fix the jit-lock-fontify-now test names
:
第三次尝试,跟进@santiagopim。
是的,Mercurial 和 Git 使用了很多不同的概念(没有远程跟踪,默认拉|推转移所有分支),但是:如果你想看到|在更多方面使用 Mercurial Git-style 具有许多具有不同历史的远程回购,您可以:
- 使用 santiagopim 的优秀模板(或使用 torek 的提示将其扩展为全功能样式)
- 添加了 hgremotenames or remotebranches 扩展(简而言之,为每个提取的远程名称添加描述性书签)
获取类似于 Git 的日志。
试试 TortoiseHg。不是命令行,但是满足要求
它还突出显示了每个分支的提示(在 mercurial 中称为“heads”)。简单地显示分支名称不会突出显示它们,因为每个提交都有一个分支名称。
--graph
是 --graph
的汞。而--all
的效果是默认的
对于 --decorate
和 --oneline
我的 .hgrc
:
[alias]
la = log --graph --template {oneline}
[templatealias]
oneline = '{hash}{myBranch}{myBookmarks}{myTags} {name} {commitMsg}\n'
hash = "{label(ifeq(phase, 'secret', 'yellow', ifeq(phase, 'draft', 'blue', 'red')), node|short)}"
myBranch = "{ifeq(branch, 'default', '', label('green', ' ({branch})'))}"
myBookmarks = "{bookmarks % ' {bookmark}{ifeq(bookmark, active, '*')}{bookmark}'}"
myTags = "{label('yellow', tags % ' {tag}')}"
name = '{label('blue', author|person)}'
commitMsg = '{desc|firstline|strip}'
[experimental]
graphshorten = true
此解决方案不使用已弃用的 --style
参数。相反,正如您在别名部分中看到的那样,它是由 hg la
通过 --template
选项激活的。由于模板可以嵌套,oneline的名字会显示哈希、分支、书签、标签、提交者和提交信息。
在此示例中,哈希将根据提交的阶段改变颜色。
即使模板只是建议每行的最后一个换行符,hg 也会在每次提交之间放置一个额外的空行。 graphshorten = true
选项避免了这种情况。
你需要一个扩展来拥有类似于远程跟踪分支概念的东西。
这里是结果(缺少很棒的颜色):
| o 821ee2270f00 (lowercase_eats_whitespace) Robert Siemer add 'lowercase_eats_whitespace' directive
| o 9a86b49dc3ba (settings_passing) Robert Siemer restructure settings-passing in parsers and grako
|/
o 31664ddc943b Juancarlo Añez Merged in siemer/grako/siemer_fixup_regex (pull request #43)
|\
| o 317cea8eba42 (siemer_fixup_regex) Robert Siemer buffering.py: remove a superfluous regexp.DOTALL from a '[...]+' pattern
|/
o 31641ef78ba8 apalala Added tag 3.9.1 for changeset f33a2e80bb7d
o f33a2e80bb7d 3.9.1 apalala Getting ready for release 3.9.1