Find mercurial commit to change executable bit in file

I know how to use hg blame to find that the exact commit changed the line in the file, but I cannot find a similar way to find when the executable bit in the file was changed.

+4
source share
2 answers

First of all, note that since changes to the exec bit do not affect the contents of the file, such as deletions, they will not necessarily be displayed by the name hg log filename. (Unix nerds can compare ctime / mtime rules for files and directories with respect to rm / chmod to understand this difference.) So you will need to use something like:

 $ hg log --deleted file 

to show all changes that relate to the file, include changes, deletions and duplicates of exec. This is not enabled by default for various reasons, including the fact that it can be an order of magnitude slower.

Finding the exec bits while looking at the log also means looking at the git patches, since the standard patches (1) -packages of the patches do not know about the exec bits. Thus, a general command might look something like this:

 $ hg log --removed -pg contrib/simplemerge | grep "^new mode" -B 10 + import os sys.exit(main(sys.argv)) changeset: 4363:2e3c54fb79a3 user: Alexis SL Carvalho < alexis@cecm.usp.br > date: Mon Apr 16 20:17:39 2007 -0300 summary: actually port simplemerge to hg diff --git a/contrib/simplemerge b/contrib/simplemerge old mode 100644 new mode 100755 

It reads: "Find all git patches on simplemerge for lines starting with" new mode "and show the previous 10 lines."

Another option is to use bisect. This can be used to search for basically any changes you can check. For example, if you are looking for where bit X is set:

 $ hg bisect -g 1000 # some past revision without the X bit $ hg bisect -b tip # some recent revision with the X bit Testing changeset 8114:ad3ba2de2cba (14179 changesets remaining, ~13 tests) 993 files updated, 0 files merged, 716 files removed, 0 files unresolved $ hg bisect -c "[ ! -x contrib/simplemerge ]" # shell expression returns 0 (good) if no x bit Changeset 8114:ad3ba2de2cba: bad Changeset 4566:087b3ae4f08a: bad Changeset 2797:a3c6e7888abf: good Changeset 3678:7e622c9a9707: good Changeset 4121:d250076824e3: good Changeset 4345:ec64f263e49a: good Changeset 4454:28778dc77a4b: bad Changeset 4403:15289406f89c: bad Changeset 4371:d7ad1e42a368: bad Changeset 4355:10edaed7f909: good Changeset 4366:390d110a57b8: bad Changeset 4363:2e3c54fb79a3: bad Changeset 4361:99c853a1408c: good Changeset 4362:465b9ea02868: good The first bad revision is: changeset: 4363:2e3c54fb79a3 user: Alexis SL Carvalho < alexis@cecm.usp.br > date: Mon Apr 16 20:17:39 2007 -0300 summary: actually port simplemerge to hg 

Here we automated the test with the standard Bourne shell expression to check the bit of the exec file, and Mercurial then looks at the revisions and tests them for us.

+16
source

There may not be a simple assembly method a la hg blame (or maybe there is, and I just don't know that!), But you should be able to use brute force to search for a set of changes by looking at the differences.

First, you need to enable git-style diffs because hg normal diff output does not show changes in file modes. To do this, add the following to hgrc :

 [diff] git = True 

Then you can look at all the differences for the file you are interested in and find the commit that changed the mode by running:

 hg log -p file_of_interest 

If you are on a * nix system, this helps connect to less or grep to easily find results. The mode changes should appear just below the beginning of the patch line, which starts with:

 diff --git a/file_of_interest b/file_of_interest old mode .... new mode .... 

So, for example, you can look for a mode change from 644 (no exec) to 755 (the exec bit is set), in which case you will see something like:

 old mode 100644 new mode 100755 

After you find out which diff you are after, change the mode you need, you can search back to get the commit hash code.

Not as simple as hg blame , but it should work to some extent. Hope this helps.

+4
source

All Articles