約 800 の変更セットを含む Mercurial リポジトリがあり、Exampleという単語が最初に表示された変更セットを見つける必要があります。この単語は、コミット コメントなどではなく、.php ファイル内に表示されます。
それを行うための最も迅速で簡単な方法は何ですか?
試すhg grep Example *.php
hg grep [OPTION]... PATTERN [FILE]...
search for a pattern in specified files and revisions
Search revisions of files for a regular expression.
This command behaves differently than Unix grep. It only
accepts Python/Perl regexps. It searches repository
history, not the working directory. It always prints the
revision number in which a match appears.
By default, grep only prints output for the first
revision of a file in which it finds a match. To get it
to print every revision that contains a change in match
status ("-" for a match that becomes a non-match, or "+"
for a non-match that becomes a match), use the --all
flag.
options:
-0 --print0 end fields with NUL
--all print all revisions that match
-f --follow follow changeset history, or file
history across copies and renames
-i --ignore-case ignore case when matching
-l --files-with-matches print only filenames and revisions
that match
-n --line-number print matching line numbers
-r --rev search in given revision range
-u --user list the author (long with -v)
-d --date list the date (short with -q)
-I --include include names matching the given
patterns
-X --exclude exclude names matching the given
patterns
use "hg -v help grep" to show global options
選択した回答は不完全です:
hg grep --all --files-with-matches 'PATTERN' [FILES]
通常、あなたが望むものです。
hg help filesets
...
"grep(regex)"
File contains the given regular expression.
hg locate "set:grep(Example) and **.php"
また
hg locate "set:**.php and (**Example*)"
hg grepの--diff
( is deprecated) フラグを使用することをお勧めします。--all
ファイルの内容自体ではなく差分を検索します。これにより、例という単語が表示または削除されたすべての変更セット/リビジョンが取得されます。
最初のヒットを取得するには、これをフラグを介して revlog の順序で渡す必要があります-r
。つまり、リビジョンは 0 からヒントまで検索されます。( -r 0:ヒント)
-I
.php ファイルの場合は、ファイル名パターン用のフラグを渡します。
したがって、コマンドは次のようになります。
hg grep --all -r 0:tip "Example" -I "*.php"