Differences between revisions 10 and 11
Revision 10 as of 2008-01-13 03:25:27
Size: 6299
Editor: BenLuo
Comment:
Revision 11 as of 2008-01-15 15:04:32
Size: 6322
Editor: abuehl
Comment: cat
Deletions are marked like this. Additions are marked like this.
Line 135: Line 135:
----
CategoryChinese

教程 - 检查仓库历史

现在我们已经参照 [:ChineseTutorialClone:教程 - 克隆仓库] 克隆了一个 [:Repository:仓库]; 我们仓库的本地拷贝叫 my-hello.

让我们看一看这个仓库的历史记录。我们用 log 命令来做这个事情。这个命令按时间顺序从近到远输出在[:Repository:仓库]中发生的每一个事件。

$ cd my-hello
$ hg log
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm@selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program

这些输出行的含义是这样的。

  • 每一段描述一个特定的改变集。一个或几个文件的改变集合在一起形成一个逻辑单元,称为改变集。
    • 在上面的例子中,我们可以看到该[:Repository:仓库] 的历史包括了两个[:"ChangeSet":改变集]。

  • changeset identifies a [:"ChangeSet":改变集].

    • 冒号前面的数字代表版本号; 它是一种标识[:"ChangeSet":改变集]的本地缩写.只是在你的本地[:Repository:仓库]中这个版本号才有意义.

    • 冒号后面的那个很长的十六进制串是 ChangeSetID; 它是标识[:"ChangeSet":改变集]的全局唯一标识符, 在所有包含这个[:"ChangeSet":改变集]的[:Repository:仓库]中都相同. 如果你正在和其他人讨论某个改变集,请使用这个 ChangeSetID,而不是上面说的版本号.

  • tag 是一个[:"Tag":标签],可以理解成为一个改变集指定的名字.

    • 你可以给任何改变集指定一个或者多个[:"Tag":标签]. 实际上, 许多[:"ChangeSet":改变集]都是没有[:"Tag":标签]的, 所以tag这一行很多时候都不存在.

    • 名叫tip 的特殊[:"Tag":标签]总是表示,它是[:Repository:仓库]中最后一个[:"ChangeSet":改变集]。 如果你创建另外的[:"ChangeSet":改变集](一会我们会看到),那么它将会变成 ["Tip"]。

  • user 确定了谁创建了本[:"ChangeSet":改变集]。这是一个无格式的字符串; 它通常包括电子邮件地址,个人姓名等。

  • date 描述了[:"ChangeSet":改变集]是什么时候创建的。这些时间是创建[:"ChangeSet":改变集]的人所在区域的当地时间。

  • summary 给出了[:"ChangeSet":改变集]描述的首行。它是在创建[:"ChangeSet":改变集]时进入的,它可以帮助创建者和其它人了解[:"ChangeSet":改变集]的目的。

  • parent 标志了[:"ChangeSet":改变集]的父辈,当你从几个仓库合并而来的情况下,父辈有多个。

    • 大多数情况只有一个父辈,它比目前的改变集旧。这是在我们例子中使用的。

我们可以通过指定-v诊断输出选项来获得更多更详细的历史信息, 或者指定--debug选项来获得历史信息中的一切细节:

$ hg log -v
changeset:   1:82e55d328c8ca4ee16520036c0aaace03a5beb65
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
files:       Makefile
description:
Create a makefile

(...)

$ hg log --debug
manifest:    1:0c7c1d435e6703e03ac6634a7c32da3a082d1600
changeset:   1:82e55d328c8ca4ee16520036c0aaace03a5beb65
tag:         tip
parent:      0:0a04b987be5ae354b710cefeba0e2d9de7ad41a9
parent:      -1:0000000000000000000000000000000000000000
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
files+:      Makefile
description:
Create a makefile

(...)

动词的输出比缺省输出要多。

  • changeset 给出不缩略的[:ChangSetID:改变集标号]。

  • files 列出在本[:"ChangeSet":改变集]中文件的改变。

  • description contains the complete multi-line description of the ChangeSet, rather than just the first line.

    • In our case, the descriptions are only one-line long, so there's not much difference.

The --debug output adds the following fields to the verbose output:

  • file+ lists the file added in this changeset.

  • file- lists the file removed in this changeset.

  • manifest gives the ["Manifest"] ID for this changeset.

  • two parent fields giving the changeset ID of both parents for this changeset, where -1:0000000000000000000000000000000000000000 refers to a non-existant parent.

log 命令与 -r 选项一起使用可以查看特定改变集。

$ hg log -r1
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

<!> The -r option actually supports a very flexible syntax to select range of changesets. However, due to limited number of changesets available in our sample repository, we are unable to provide a good demonstration. Please consult Mercurial's [http://www.selenic.com/mercurial/hg.1.html manpage] for more information.

log 命令与 -p 选项一起可以显示和此改变集相关联的补丁。

$ hg log -r1 -p
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

diff -r 0a04b987be5a -r 82e55d328c8c Makefile
--- /dev/null   Fri Aug 26 01:20:50 2005 -0700
+++ b/Makefile  Fri Aug 26 01:21:28 2005 -0700
@@ -0,0 +1,1 @@
+all: hello

我们也可以使用 tip 命令来显示 tip 的信息,如最后的改变集。 tip 命令除了不支持 -p 选项外,它可以当做 log -r tip 的快捷方式,

$ hg tip
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

$ hg log -r tip
changeset:   1:82e55d328c8c
tag:         tip
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

现在我们对发生了什么有了一点概念,现在让我们进入并做一些修改吧!进入 [:ChineseTutorialFirstChange:教程 - 生成第一个[变更]]!


CategoryChinese

ChineseTutorialHistory (last edited 2012-11-06 23:51:05 by abuehl)