Online Book Reader

Home Category

Mercurial_ The Definitive Guide - Bryan O'Sullivan [14]

By Root 988 0
identifiers for the changeset. The hex string is a unique identifier: the same hex string will always refer to the same changeset in every copy of this repository. The number is shorter and easier to type than the hex string, but it isn’t unique: the same number in two different clones of a repository may identify different changesets.

user: The identity of the person who created the changeset. This is a free-form field, but it most often contains a person’s name and email address.

date: The date and time on which the changeset was created, and the timezone in which it was created. (The date and time are local to that timezone; they display what time and date it was for the person who created the changeset.)

summary: The first line of the text message that the creator of the changeset entered to describe the changeset.

tag: Some changesets, such as the first in the list above, have a tag field. A tag is another way to identify a changeset, by giving it an easy-to-remember name. (The tag named tip is special: it always refers to the newest change in a repository.)

The default output printed by hg log is purely a summary; it is missing a lot of detail.

Figure 2-1 provides a graphical representation of the history of the hello repository, to make it a little easier to see which direction history is “flowing” in. We’ll be returning to this figure several times in this chapter and the chapter that follows.

Figure 2-1. Graphical history of the hello repository

Changesets, Revisions, and Talking to Other People

As English is a notoriously sloppy language, and computer science has a hallowed history of terminological confusion (why use one term when four will do?), revision control has a variety of words and phrases that mean the same thing. If you are talking about Mercurial history with other people, you will find that the word “changeset” is often compressed to “change” or (when written) “cset”, and sometimes a changeset is referred to as a “revision” or a “rev”.

While it doesn’t matter what word you use to refer to the concept of a changeset, the identifier that you use to refer to a specific changeset is of great importance. Recall that the changeset field in the output from hg log identifies a changeset using both a number and a hexadecimal string:

The revision number is a handy notation that is only valid in that repository.

The hexadecimal string is the permanent, unchanging identifier that will always identify that exact changeset in every copy of the repository.

This distinction is important. If you send someone an email talking about “revision 33,” there’s a high likelihood that their revision 33 will not be the same as yours. The reason for this is that a revision number depends on the order in which changes arrived in a repository, and there is no guarantee that the same changes will happen in the same order in different repositories. Three changes a,b,c can easily appear in one repository as 0,1,2, while in another as 0,2,1.

Mercurial uses revision numbers purely as a convenient shorthand. If you need to discuss a changeset with someone, or make a record of a changeset for some other reason (for example, in a bug report), use the hexadecimal identifier.

Viewing Specific Revisions

To narrow the output of hg log down to a single revision, use the -r (or --rev) option. You can use either a revision number or a hexadecimal identifier, and you can provide as many revisions as you want.

$ hg log -r 3

changeset: 3:0272e0d5a517

user: Bryan O'Sullivan

date: Sat Aug 16 22:08:02 2008 +0200

summary: Get make to generate the final binary from a .o file.

$ hg log -r 0272e0d5a517

changeset: 3:0272e0d5a517

user: Bryan O'Sullivan

date: Sat Aug 16 22:08:02 2008 +0200

summary: Get make to generate the final binary from a .o file.

$ hg log -r 1 -r 4

changeset: 1:82e55d328c8c

user: mpm@selenic.com

date: Fri Aug 26 01:21:28 2005 -0700

summary: Create a makefile

changeset: 4:2278160e78d4

tag: tip

user: Bryan O'Sullivan

Return Main Page Previous Page Next Page

®Online Book Reader