mercurial,tortoisehg,file-search , Searching for the change history of partial file or path in Mercurial or TortoiseHg

Searching for the change history of partial file or path in Mercurial or TortoiseHg


Tag: mercurial,tortoisehg,file-search

Each time I need anything beyond the standard search, I find myself trying several things, searching Google and in the end terribly failing. Apparently, the Hg search syntax is pretty extensive and I would like to use its power, but I don't seem to be able to find a good reference.

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


But I would like to search for files by partial match, and neither 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 see that there are a gazillion options, but no hint on how to use them (the help link shows a little bit more, but nothing on what a pattern should look like in file(pattern)):

enter image description here

In the end I usually find what I want using other ways of searching, but it would be so nice to be able to use this power of expression, and it's quite a shame that after so many years, I've never found out how to leverage this.


I can very much advise using the hg help system for this. The most useful pages to look at (in my view):

hg help revsets
hg help filesets
hg help patterns

In the page about patterns, you can find about '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. Slightly 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 the pattern file('glob:**jquery*'). In fact, the above pattern would also work without the glob prefix, so: file('**jquery*'). See part of the page about revsets:

  Changesets affecting files matched by pattern.

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

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


Mercurial - merging last three unpushed commits

I have (locally) three hg commits. As two of them are basically but a couple of minor corrections, I would like to merge them into a single commit prior to pushing. Any way to do that (with TortoiseHg or console)?...

Can I tell MacHG to use a specific version of Mercurial?

I would like to use a specific version of Mercurial for plugin reasons. Is there a way I can tell MacHG to use a specific Mercurial version. I know that it comes with its own, but I would like it to use 'mine', basically.

Why i can't see new branch in tortoiseHG?

I create a new branch and commit it. But my team can't see this branch in their tortoise, why?

Display untracked files in Mercurial commit message

When you do an hg commit, you get a list of the files that will be added. Is it possible to append a list of untracked files to the bottom of this list? I keep finding that I am forgetting to commit newly created files.

Mercurial: are pre-commit hooks run for other committing commands than “hg ci”

Are mercurial's pre-commit hooks also run for other committing commands, e.g. hg backout or hg graft? Since these commands do a commit themselves, I'd like to think this is the case but I cannot find it in the documentation anywhere.

How to properly push to a repository with a newer revision number?

Please help. I'm always having a difficulty with pushing my changes to an existing remote repository where the revision number is newer. i.e. someone has pushed to that repository after I last pull. I'm using ubuntu 14.04, and netbeans and mercurial and meld and my project is a php application...

How to restore deleted unversioned files in mercurial

I have just deleted all my unversioned files in mercurial thinking they were all .origs It turns out my test classes were in there which i had been working on. Is it possible to restore these in anyway? I am guessing the answer is no, I hope the answer is...

How Jenkins is passing username and password credentials for checkout pull operations

I have Jenkins / Mercurial latest versions. Machine is Red Hat Linux 6.6. I'm using Release plugin in Jenkins. Maven plugins (maven-scm-plugin, maven-version-plugin and maven-enforcer-plugin) for doing release process on a project. All of these versions are using latest available versions and configuration is setup correctly. In Jenkins job, I'm...

What does it mean to “commit” changes to a “local repo”? [duplicate]

This question already has an answer here: What are the differences between “git commit” and “git push”? 7 answers I understand that "commit" is sort of like "updating" the "local repo" and "pushing" copies the local repo changes over to the remote / online repo, right? But if I...

how to “propertly” not commit changes on mercurial?

Accidentally i hg added several binary compiled files from a project along with tons of little changes on several files. my hg status now show that i have a dozen files modified (correctly) and two dozen files added (mistake). how do i undo that? Most answers here tell me to...

Change upstream of local (hg-git) clone from (github) original to fork

I discovered an OSS project I've contributed to had moved to github. I installed hg-git and cloned a local repo from the git:// URL; then I made changes. I then realized I really wanted my own github fork, so I made one; but I haven't been able to figure out...

Mercurial get branch name by changeset

I have tried the hg log --rev "branch([changeset])" but what I got is a collection of all the changesets in this branch. What I do want to get is the name of the target branch (e.g. default) instead of the whole collection. Is there a way to achieve this goal?...

Automatic mercurial commit and push in build

I have a build process which includes making changes to files and committing them to source control. I am moving to use mercurial, and trying to figure out how to best do this. The problem is that the process pulls from the main repository at the start and pushes back...

Work on one commit while browsing another (Git/Mercurial)

Say I have a huge Git/Mercurial repository with commit/changeset A and B. Now say that there are two non overlapping sets of files, say set dir1 and set dir2. Set dir1 exists in commit/changeset A, and may exist in B, and vice versa (set dir2 exists in commit/changeset B, and...

How can I repair a repository broken by hg unshelve?

I used hg shelve in a repository, where I had some unfinished changes because I needed to switch to a different head and perform unrelated changes. Once my work on the other head was committed, I switched back to the head on which I had originally used hg shelve and...

HG clone - abort : HTTP Error 403: Forbidden/empty destination path not valid

Basically, I'm trying to serve (hg serve) my local repository and clone the same. When I gave "hg clone http://localhost:8000/" (the served URL), I got "abort: HTTP Error 403: Forbidden" When I did "unset http_proxy", tried again, abort: empty destination path is not valid popped up! Why does it happen?...

How can I commit/push changes to a “live” branch and then keep working on my “test/dev” branch?

I'm very new to working on larger projects and using any form of version control, so please bear with me. I have a project running on a local/intranet webserver. I'm using mercurial for version control with hgworkbench/turtoisehg as a GUI. So far I've simply commited and pushed my changes to...

Hg Mercurial - Upgrading code not in repository

I have a customized local repository of NopCommerce 3.5. The new version of NopCommerce (3.6) is out and I would like to try to update to it. I downloaded their source code and I would like to somehow replace all the files in my local repository with the new files...

Addremove after branch merge?

I work in an environment that has a lot of development across different branches. We use mercurial as source control and often merge branches which contain other features. I am wondering if it would ever be necessary to do hg addremove after a branch merge and before committing? e.g.: hg...

Mercurial - abandoning loose ends

Due to lack of attention, I have made a rollback ("backout") that I had forgot to merge back into the default branch - which I did not notice until a bit later, causing my local history to look like this: Which seems to disallow pushing ("new remote heads"). If I...

Phantom Mercurial, How to remove?

I'm trying to install TortoiseHg on Ubuntu 14.04. It went fine, but trying to open it complains about having an unsuported Mercurial version (3.4.1). I removed via: sudo apt-get remove mercurial sudo apt-get purge mercurial sudo dpkg -r mercurial sudo dpkg --purge mercurial It comes out as successful, but if...

Mercurial Queues: How to reorder patches efficiently

Suppose I have the follow patches in my mercurial queue: $ hg qser -v 0 A p1 1 A p2 2 A p3-StupidPatch 3 A p4 5 A p6 ... 15 A p15 Now suppose that I want to do is reorder the patches so that p3-Stupid patch is the...

ignore certain mercurial commands in mercurial hook

I have a mercurial hook like so: [hooks] pretxncommit.myhook = python:path/to/file:myhook with the code looking like this: def myhook(ui, repo, **kwargs): #do some stuff but this hook runs on commands that use the commit logic to do something else, in my case hg shelve. is there a way to get...

Mercurial - clone all remote branches at once

Wondering if Mercurial while cloning the repo includes all remote branches as well? Basically I have some proprietary / not used mercurial repository with many branches. I want to clone all of them at once and make backup out of it.

When does a new head is created in a repository?

I'm assuming this is kind of weird question, but I am not sure when exactly a new head is created to a repository, for example in this question : Explain which line(s) cause the number of heads to change in any of the referenced repositories 1: /home/user> hg clone http://remoteserver/mainrepository...

How to merge uncommitted changes in files from one local branch to another using mercurial

I am working on a local branch and made changes to a set of files : Now suddenly it was decided that changes in and is a new mini-feature which should be separately pushed to remote repo. The plan is to continue development for other...

How can I use a Maven project as a dependency to another Maven project?

I'm new to Maven, therefore, sorry in advance if my question is too general. I have a Maven project, call it projectA, which resides in my company's Mercurial repository (let's call it Recently, I built a separate Maven project, call it projectB in the same repository. I now want...

Mercurial undo a series of commits

I have a mercurial repo with the following history (most recent commit at the top) on a feature branch: mergeDefaultA | mergeDefaultB | C | mergeDefaultD mergeDefaultXXXX are merge commits that came as the result of merging the default branch into the feature branch. What has happened is commit C...

Searching for the change history of partial file or path in Mercurial or TortoiseHg

Each time I need anything beyond the standard search, I find myself trying several things, searching Google and in the end terribly failing. Apparently, the Hg search syntax is pretty extensive and I would like to use its power, but I don't seem to be able to find a good...

Remove a revision in TortoiseHG

I know this question has been asked and I know it´s against version control. But we have done some minor changes in the layout etc. and would like to remove the history of 30 revisions. Is it possible to just remove these 30 revisions or merge them into one revision?...

Paralell branches/clones in Mercurial?

This question is not only technical. I want to get into the concept itself, too. There is a foreign project on BitBucket (e.g. ObjectListView). And I need to work on two problems at the same time. In git I would just create to branches in my local repository after clonening....

Android build fails only in TeamCity server

I am using TeamCity as my CI server.When I run a build for an android studio project it is failing. But when I open the cloned repository in Android Studio in the build server itself it gives a successful build. Please help me out.. EDIT:: When the checkout directory from...

Mercurial difference between changesets and revisions

I'm new to Mercurial and trying to understand how things work. I wonder what is the difference between changesets and revisions ? Thanks....

How to set up default local push path in Mercurial?

I am trying to set default local push path for Mercurial. I do not need a remote server, instead I want to use my working directory as default path. How do I set it up? My hgrc file does not work and looks like this: [path] default = /home/user/myscript/ default-push...

Is there a mercurial command which can generate a clone without largefiles?

Since I believe there is no way to strip largefiles out of a repository, I'm looking for a way to either: clone to (create) a new repo that contains at least all the same files, even without history (export tip revision only) if necessary, deleting all largefiles. achieve similar results...

How do I make a revset alias for tags whose names follow a pattern?

In my repository, I have tags of the form version-1.2.3. I would like to make a revset alias new() that is called like this: hg log -r 'new(1.2.3, 1.2.4)' ...and expands to this: hg log -r '::version-1.2.4 - ::version-1.2.3' # What's new in 1.2.4? When I tried to do this:...

Cut off the “desc” at N characters in hg log output with templates

I'm trying to create a custom template for hg log with a part that shows the first N (e.g. 72) characters of the first line. Based off this answer to a different question I've gotten so far: hg log --template '{desc|strip|firstline}\n' Now I'm trying to limit that bit to a...

Nginx map client certificate to REMOTE_USER for uWSGI with fallback to basic auth?

I'm using Nginx with uWSGI to serve Mercurial; it does basic auth over SSL (Nginx is the SSL terminator; it doesn't get passed on to Hg), but due to the limited security of basic auth even over SSL, as discussed at various places including this site, I want to allow...

Why these commands in mercurial create a new head?

I was asked as an assignment to figure out which of the following lines causes the number of heads to change, now I checked and saw that lines 16 and 20 add new heads to their repository, but I'm not quite sure why.. I understand that the number is changed...

Why won't Hg let you push with patches applied?

I can't understand why Mercurial won't let me push when patches are applied. From my point of view, applied patches affect only the current workspace and pushing isn't influenced by the state of the current workspace. In other words, I would expect that if I made some commits, then started...

How to do hg revert --all with git?

When using Mercurial it is possible to issue the following command: hg revert --all --rev <revision> The content of the working directory is set to the specified <revision> but you stay where you are in the tree (same parent, branch, etc). How to do that in git? It should...

Mercurial revset selecting up to a bookmark

If I have this changesets in my repository A --> B --> C --> D * B is bookmarked and D is at the tip - how do I create a revset that will select everything between B and D but not B. Specifically I'm trying to squash C and...