Подтвердить что ты не робот

Как просмотреть предыдущую версию файла в Mercurial

Я использую mercurial для управления версиями нескольких файлов в каталоге. Предположим, что у меня есть 10 коммитов (10 изменений или ревизий). Я хочу просто посмотреть, как определенный файл, скажем, thisFile.py, просмотрел в 7-й версии. Я не хочу возвращаться к этой старой версии. Я не хочу идти и вносить какие-либо изменения или исправлять ошибки в этой предыдущей версии. Я просто хочу это увидеть, не влияя ни на какую последнюю версию файла, ни на меркуриальную историю. Есть ли простой способ сделать это?

4b9b3361

Ответ 1

Используйте команду hg cat с аргументом -r (revision).

hg cat path_to/myfile.cpp -r 46

где 46 - номер ревизии (используйте hg log для просмотра истории изменений)

Ответ 2

hg cat [OPTION]... FILE...

Print the specified files as they were at the given revision. 
If no revision is given, the parent of the working directory is used, 
or tip if no revision is checked out.

Output may be to a file, in which case the name of the file is given 
using a format string. The formatting rules are the same as for the 
export command, with the following additions:
%s: basename of file being printed
%d: dirname of file being printed, or '.' if in repository root
%p: root-relative path name of file being printed

Returns 0 on success.

options:
-o, --output    print output to file with formatted name
-r, --rev   print the given revision
--decode    apply any matching decode filter
-I, --include   include names matching the given patterns
-X, --exclude   exclude names matching the given patterns

Ответ 3

Чтобы извлечь конкретную ревизию определенного файла, вы можете сделать это в Windows:

hg cat "<FileToBeExtractedPath>" -r 9 > "<ExtractionPath>"

Здесь 9 - номер ревизии.

Или даже лучше:

hg cat "<FileToBeExtractedPath>" -r 9 -o "<ExtractionPath>"