Replace local function with its canonical implementation in some cases.

Correct file permission modification and the corresponding repair logic.

(0) -2 +2 +10 tip

mercurial