Differences between revisions 5 and 6
Revision 5 as of 2007-05-14 05:53:09
Size: 6216
Editor: 221
Comment:
Revision 6 as of 2007-10-21 15:01:45
Size: 6277
Editor: BenLuo
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
现在我们已经参照 ChineseTutorialClone 克隆了一个 [:Repository:仓库]; 我们仓库的本地拷贝叫 {{{my-hello}}}. 现在我们已经参照 [:ChineseTutorialClone:教程 - 克隆仓库] 克隆了一个 [:Repository:仓库]; 我们仓库的本地拷贝叫 {{{my-hello}}}.
Line 133: Line 133:
Now that we have some slight idea of what has happened, let's jump in and make some changes! Onwards, to ChineseTutorialFirstChange! Now that we have some slight idea of what has happened, let's jump in and make some changes! Onwards, to [:ChineseTutorialFirstChange:教程 - 生成第一个[变更]]!

教程 - 检查仓库历史

现在我们已经参照 [: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.

    • 冒号前面的数字代表版本号; it is a local short-hand way of identifying the ChangeSet. It is only valid within this ["Repository"].

    • 冒号后面的那个很长的十六进制串是 ChangeSetID; it uniquely identifies the ChangeSet, and is the same in all repositories that contain this ChangeSet. If you are ever discussing a ChangeSet with someone else, use the ChangeSetID, not the RevisionNumber.

  • tag is a ["Tag"], an arbitrary symbolic name for a ChangeSet.

    • You can assign one or more ["Tag"]s to any ChangeSet. Actually, not that many ["ChangeSet"]s will have ["Tag"]s associated with them, so the tag line will seldom be present.

    • The special ["Tag"] named tip always identifies the ["Tip"], which is the most recent ChangeSet in the ["Repository"]. If you create another ChangeSet (and we will, soon), that will become the ["Tip"].

  • user identifies the person who created the ChangeSet. This is a free-form string; it usually contains an email address, and sometimes a person's name, too.

  • date describes when the ChangeSet was created. These dates are printed in the local time zone the creator of the ChangeSet was in.

  • summary gives the first line of the description of the ChangeSet. This was entered by the creator of the ChangeSet at the time they created it, to help themselves and others understand the purpose of the ChangeSet.

  • parent identifies the parent ["ChangeSet"]s, in case there are more than one, which happens when you merge changes from several repositories.

    • Most of the times there is only one parent, which is the one changeset older than itself. This is the case in our example above.

We can get more detailed history information by asking for verbose output with the -v option, or the --debug global option for everything under the sun:

$ 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

(...)

Verbose output contains a few more fields than the default output.

  • changeset now gives the unabbreviated ChangeSetID.

  • files lists the files modified in this 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.

The log command comes with a -r option to view specific changesets.

$ 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.

The log command also comes with a -p option to show the patches associated with the changesets:

$ 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

We can also use the tip command to show info of the tip, i.e. the latest, changeset. The tip command may be considered a shortcut to log -r tip, except that it does not support the -p option.

$ 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

Now that we have some slight idea of what has happened, let's jump in and make some changes! Onwards, to [:ChineseTutorialFirstChange:教程 - 生成第一个[变更]]!

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