Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find what mercurial commit changed the executable bit on a file

I know how to use hg blame to find what exact commit changed a line in a file, but I can't find a similar way to find when the executable bit on a file was changed.

like image 800
postfuturist Avatar asked Nov 30 '22 07:11

postfuturist


1 Answers

First note that as changes in the exec bit don't affect the file contents, like deletions, they will not necessarily be shown by 'hg log filename'. (Unix nerds can compare the ctime/mtime rules for files and directories with respect to rm/chmod to understand this distinction.) So you will need to use something like:

$ hg log --deleted file

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

Finding exec bits while perusing the log will also mean looking at git-style patches as standard patch(1)-compatible patches don't know about exec bits. So the total command might look something like:

$ hg log --removed -pg contrib/simplemerge | grep "^new mode" -B 10
+    import os
     sys.exit(main(sys.argv))

changeset:   4363:2e3c54fb79a3
user:        Alexis S. L. Carvalho <[email protected]>
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

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

Another alternative is to use bisect. This can be used for finding basically any sort of change you can test for. For instance, if you're looking for where the X bit 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 S. L. Carvalho <[email protected]>
date:        Mon Apr 16 20:17:39 2007 -0300
summary:     actually port simplemerge to hg

Here we've automated the test with a standard Bourne shell expression to check a file's exec bit and Mercurial then runs through checking out revisions and testing them for us.

like image 123
mpm Avatar answered Dec 04 '22 05:12

mpm