3

1

I'm trying to track down how I can see the history of a file that shows mode changes. Someone keeps ripping off the exectuable bit of one of my scripts when they commit/push. But i can't find a history of the file changes that reveal whose commit is changing this.

flag

1 Answer

2

It's unfortunately a little bit messy to try to track down that information, for two reasons:

First, there is no easy way in Mercurial to ask for a list of when a file's mode has changed. Even with the new revspecs in Mercurial 1.6, I don't know of a way to say, "Show me when this file's mode was changed, regardless of what else might have happened."

Second, to increase compatibility with diff tools, Mercurial's diff command defaults to showing normal patch(1)-style diffs, which do not contain mode change information. That means that even if you look at the diffs for those changesets, you won't, by default, see that the mode changed.

The good news is that you can work around these issues easily. Since it's happening to one of your files repeatedly, you won't have to look at much history to find a bad revision. And Mercurial can output mode change information by asking it to output Git-style diffs, which will let you easily see what's wrong.

If you're on the command line: get a list of when the file was changed with hg log <path to file>, and then look at the diff for what changed with hg diff -g -c <a revision where it changed> <path to file>. The extra -g will make Mercurial output Git-style diffs. You're looking for a line near the top of the diff that reads something like

diff --git a/some/file b/some/file
old mode 100755
new mode 100644

When you find it, you've got your culprit.

If you're using TortoiseHg: Enable Git-style diffs by going to ToolsSettings, flipping down to User global settings, going to the Diff pane, and setting, Git Format: to True. Next, find any changeset that touches the file you want, then right-click the file and choose File History. From there, you can easily just walk the file history, paying attention for the mode line above.

link|flag
This is very promising. I'm having a little trouble, tho: 1. my hg diff doesn't have a -c switch 2. according to usage: hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE] but specifying more than one changeset produces the following error: ]$ hg diff -g -r 788:d5830b75aeed -r 835:989d17f99d0e ./editorial-update-20100701.sh abort: too many revisions specified 3. Running the command with just one revision specified produces no output. – T Collins Jul 14 2010 at 14:43
hg diff has had a -c switch for a very long time; can you run hg version and tell me what you see? – Benjamin Pollack Jul 15 2010 at 17:42

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.