As you saw in «Путешествие во времени вместе с Subversion», revision numbers in Subversion are pretty straightforward—integers that keep getting larger as you commit more changes to your versioned data. Still, it doesn't take long before you can no longer remember exactly what happened in each and every revision. Fortunately, the typical Subversion workflow doesn't often demand that you supply arbitrary revisions to the Subversion operations you perform. For operations that do require a revision specifier, you generally supply a revision number that you saw in a commit email, in the output of some other Subversion operation, or in some other context that would yield meaning to that particular number.
But occasionally, you need to pinpoint a moment in time for which you don't already have a revision number memorized or handy. So besides the integer revision numbers, svn allows as input some additional forms of revision specifiers—revision keywords, and revision dates.
The various forms of Subversion revision specifiers can be
mixed and matched when used to specify revision ranges. For
example, you can use -r
where REV1
:REV2
REV1
is a revision keyword
and REV2
is a revision number, or
where REV1
is a date and
REV2
is a revision keyword, and so
on. The individual revision specifiers are independently
evaluated, so you can put whatever you want on the opposite
sides of that colon.
The Subversion client understands a number of
revision keywords. These keywords can
be used instead of integer arguments to the
--revision
switch, and are resolved into
specific revision numbers by Subversion:
Последняя (или «самая новая») правка хранилища
Номер правки элемента рабочей копии. Если элемент редактировался, то «BASE версия» соответствует тому, как элемент выглядел до редактирования.
Правка, в которой элемент последний раз редактировался
(предшествующая либо равная BASE
).
Правка, предшествующая последней
правке, в которой элемент был изменен. (Технически,
COMMITTED
- 1.)
As can be derived from their descriptions, the
PREV
, BASE
, and
COMMITTED
revision keywords are used only
when referring to a working copy path—they don't apply
to repository URLs. HEAD
, on the other
hand, can be used in conjuction with both of these path
types.
Ниже приведено несколько примеров использования ключевых слов правок:
$ svn diff --revision PREV:COMMITTED foo.c
# показать последнее изменение зафиксированное для foo.c
$ svn log --revision HEAD
# показать лог для последней фиксации хранилища
$ svn diff --revision HEAD
# сравнить ваш рабочый файл (с учетом локальных изменений)
# с последней правкой в хранилище
$ svn diff --revision BASE:HEAD foo.c
# сравнить ваш «исходный» foo.c (без учета локальных
# изменений) с последней версией в хранилище
$ svn log --revision BASE:HEAD
# показать все логи фиксаций со времени вашего последнего обновления
$ svn update --revision PREV foo.c
# отменить последние изменения в foo.c, рабочая правка foo.c понижается
$ svn diff -r BASE:14 foo.c
# compares the unmodified version of foo.c with the way foo.c looked
# in revision 14
Revision numbers reveal nothing about the world outside
the version control system, but sometimes you need to
correlate a moment in real time with a moment in version
history. To facilitate this, the --revision
option can also accept as input date specifiers wrapped in
curly braces ({
and }
).
Subversion accepts the standard ISO-8601 date and time
formats, plus a few others. Here are some examples.
(Remember to use quotes around any date that contains
spaces.)
$ svn checkout -r {2006-02-17} $ svn checkout -r {15:30} $ svn checkout -r {15:30:00.200000} $ svn checkout -r {"2006-02-17 15:30"} $ svn checkout -r {"2006-02-17 15:30 +0230"} $ svn checkout -r {2006-02-17T15:30} $ svn checkout -r {2006-02-17T15:30Z} $ svn checkout -r {2006-02-17T15:30-04:00} $ svn checkout -r {20060217T1530} $ svn checkout -r {20060217T1530Z} $ svn checkout -r {20060217T1530-0500} …
When you specify a date, Subversion resolves that date to the most recent revision of the repository as of that date, and then continues to operate against that resolved revision number:
$ svn log -r {2006-11-28} ------------------------------------------------------------------------ r12 | ira | 2006-11-27 12:31:51 -0600 (Mon, 27 Nov 2006) | 6 lines …
Кроме того, вы можете использовать диапазоны дат. Subversion найдет все правки между обеими датами включительно:
$ svn log -r {2006-11-20}:{2006-11-29} …
Since the timestamp of a revision is stored as an unversioned, modifiable property of the revision (see «Свойства», revision timestamps can be changed to represent complete falsifications of true chronology, or even removed altogether. This will wreak havoc on the internal date-to-revision conversion that Subversion performs.