HG(GREP)
π NAME π
hg grep β bestie, it's literally search for a pattern in specified files. That's it. That's the whole gig. β¨
πΈ SYNOPSIS πΈ
hg grep [--diff] [OPTION]... PATTERN [FILE]...
π¦ DESCRIPTION π¦
Okay so picture this: you wanna hunt down a regular expression across the files you picked, and you can do it in your working directory or in your revision history β and yes, for the entire repository. π
By default, grep searches the repo files sitting in your working directory and just prints the files where it found a match. Want historical revisions instead of the working directory? That's what the --rev flag is for, no cap.
Wanna search historical revision differences instead β the ones where the match status actually changed? Use the --diff flag. The tea: a - means a match that becomes a non-match, and a + means a non-match that becomes a match. It's giving glow-up vs. glow-down. π
PATTERN can be any Python (roughly Perl-compatible) regular expression. Slay.
If you don't specify any FILEs and you didn't supply the --rev flag, then every file in the working directory gets searched. And if you are using --rev and you're specifying FILEs, use the --follow argument so it also follows those FILEs across renames and copies. That part matters, don't skip it. π«Ά
β¨ Template β¨
These keywords are supported in addition to the common template keywords and functions. Also peek at hg help templates, bestie.
changeβ String. Character denoting insertion+or removal-. Only available if--diffis specified.linenoβ Integer. Line number of the match.pathβ String. Repository-absolute path of the file.textsβ List of text chunks.
And each entry of {texts} provides these sub-keywords, iykyk:
matchedβ Boolean.Trueif the chunk matches the specified pattern.textβ String. Chunk content.
See hg help templates.operators for the list expansion syntax.
Returns 0 if a match is found, 1 otherwise. Periodt. π
π OPTIONS π
-0,--print0β end fields with NUL. (yes, the null byte, iconic)--allβ an alias to--diff(DEPRECATED). β οΈ It's giving legacy, bestie.--diffβ search revision differences for when the pattern was added or removed-a,--textβ treat all files as text-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 <REV[+]>β search files changed within revision range--all-filesβ include all files in the changeset while grepping (DEPRECATED). β οΈ Also legacy, also still real.-u,--userβ list the author (long with-v)-d,--dateβ list the date (short with-q)-T,--template <TEMPLATE>β display with template-I,--include <PATTERN[+]>β include names matching the given patterns-X,--exclude <PATTERN[+]>β exclude names matching the given patterns
[+] marked option can be specified multiple times. So go off, stack 'em up. π
Okay so that's the whole hg grep manual β every flag, every keyword, every deprecated lil relic, all accounted for, fr fr. It's from the HG(GREP) page, and yeah the footer says the same thing: HG(GREP). Go search something and make it everyone's problem. π§ββοΈπ
π¦ where this page comes from
- arch rolling: mercurial 7.2.4-1 Β· GPL
- fedora 43: mercurial 7.1.1-1.fc43 Β· GPL-2.0-or-later
- fedora 43: mercurial 7.1.1-2.fc43 Β· GPL-2.0-or-later
- fedora 44: mercurial 7.2-1.fc44 Β· GPL-2.0-or-later
- fedora 44: mercurial 7.2.4-1.fc44 Β· GPL-2.0-or-later
- nixos 26.05: mercurial 7.1.2
- nixos 26.05: mercurial-full 7.1.2
- nixpkgs unstable: mercurial 7.2.2
- nixpkgs unstable: mercurial-full 7.2.2
- opensuse-leap 16.0: mercurial 7.0.1-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: mercurial 7.0.1-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: mercurial 7.0.1-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: mercurial 7.0.1-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms