This is an archive of the discontinued Mercurial Phabricator instance.

merge: add _checkunknowndirs function for detecting path conflicts
ClosedPublic

Authored by mbthomas on Sep 22 2017, 5:28 AM.

Details

Summary

Add a new function which, given a file name, finds the shortest path for which
there is a conflicting file or directory in the working directory.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

mbthomas created this revision.Sep 22 2017, 5:28 AM
ryanmce added inline comments.
mercurial/merge.py
654

Why do we need to audit this path first? If we fail the audit, what happens? This looks weird to me.

mbthomas added inline comments.Sep 26 2017, 12:22 PM
mercurial/merge.py
654

As in _checkunknownfile, this is to avoid symlink traversal while checking these files.

Consider:

$ ln -s bar foo
$ hg add foo
$ hg up <some revision where foo is a directory containing directories>

When checking foo/dir1/file1, we will go through foo then foo/dir1 in this loop. The first case doesn't trigger the rule, as although foo is a link, it's in the dirstate, so should have been resolved by the merge. The second loop will dereference foo and look at bar/dir1, which we don't want it to do.

Doing nothing is the right thing here - we will resolve the pathconflict via the merge resolution (there will be a 'pr' action for this link).

mbthomas updated this revision to Diff 2215.Oct 1 2017, 5:32 AM
mbthomas updated this revision to Diff 2356.Oct 2 2017, 5:15 PM
ryanmce accepted this revision.Oct 5 2017, 12:28 PM

Would love to see the comment added, but the code looks good to me.

mercurial/merge.py
654

This should be turned into a comment in the code. It's super useful to have this concrete example so future readers don't have the same question I did here.

This revision was automatically updated to reflect the committed changes.