Finding the change history of a partial file or path in Mercurial or TortoiseHg

Every time I need something other than a standard search, I try to find a few things, google it and end up failing terribly. Apparently the Hg search syntax is quite extensive and I'd like to use its power, but I can't seem to find a good link.

For example, quite often I want to find all the changes in a repository related to a partial path match. I know the following works:

file('path:full/path/file.txt')

      

But I would like to search for files by partial match, and none of the following worked:

jquery                  -- seems to find everything
file(jquery*)           -- finds nothing
file('jquery*')         -- finds nothing
file('path:jquery.*')   -- finds nothing
file('name:jquery.*')   -- finds nothing
file('path:jquery.js')  -- finds every revision, it seems

      

From the popup in TortoiseHg I can see there are gazillion options, but no hint on how to use them (the link to the link shows a little more, but nothing of how the template should look in file(pattern)

):

enter image description here

In the end I usually find what I want using other search methods, but it would be so nice to use that power of expression, and it's a shame that after so many years I still haven't found how to use it.

+3


source to share


1 answer


I can highly recommend using this hg help system. Most useful pages to browse (in my opinion):

hg help revsets
hg help filesets
hg help patterns

      

On the page about templates you can find about the "path:":

To use a plain path name without any pattern matching, start it with
"path:". These path names must completely match starting at the current
repository root.

      



In other words: using 'path:' is not suitable for this purpose. A little below, "glob:" is mentioned:

To use an extended glob, start a name with "glob:". Globs are rooted at
the current directory; a glob such as "*.c" will only match files in the
current directory ending with ".c".

The supported glob syntax extensions are "**" to match any string across
path separators and "{a,b}" to mean "a or b".

      

In other words, it should be possible to use a template file('glob:**jquery*')

. In fact, the above pattern would also work without prefix glob, therefore: file('**jquery*')

. See the part of the page about revsets:

  "file(pattern)"
  Changesets affecting files matched by pattern.

  For a faster but less accurate result, consider using "filelog()"
  instead.

  This predicate uses "glob:" as the default kind of pattern.

      

+4


source







All Articles