This is an archive of the discontinued Mercurial Phabricator instance.

merge: backup conflicting directories when getting files
ClosedPublic

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

Details

Summary

During batchget, if a target file conflicts with a directory, or if the
directory a target file is in conflicts with a file, backup and remove the
conflicting file or directory before performing the get.

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 requested changes to this revision.Sep 25 2017, 3:56 PM
ryanmce added a subscriber: ryanmce.

It seems like this one should have an externally-testable result. Could you adda test that shows the new behavior working better than it did before? If there a bug on bugzilla open that this solves?

This revision now requires changes to proceed.Sep 25 2017, 3:56 PM

This doesn't actually become a problem until D781. For now backup can only be true if f conflicts with a real file. If it has a path conflict then we fail earlier. In D781 I will add the possibility to detect path conflicts and mark them for backup, at which point we need this function to work for path conflicts as well as normal file conflicts.

mbthomas updated this revision to Diff 2214.Oct 1 2017, 5:32 AM
kiilerix added inline comments.
mercurial/merge.py
1174

This seems quite a bit slower. But I guess it never will happen in tight loops? If we have to backup a lot of files, then we have lost anyway?

mbthomas added inline comments.Oct 2 2017, 5:11 PM
mercurial/merge.py
1174

It will happen in batchget, which is for each file that is being created in the update. The new loop is O(path-length), which should be small. We should also only be touching things the OS needed to look at anyway to answer the original question, and which we looked at when we audited the path earlier on.

mbthomas updated this revision to Diff 2355.Oct 2 2017, 5:15 PM
ryanmce accepted this revision.Oct 5 2017, 12:22 PM

lgtm

mercurial/merge.py
1174

If we have to backup a lot of files, then we have lost anyway?

I think that's essentially the case. The other option here is to always rename conflcting files/directories, but then you end up with unbounded growth in the size of backup files (either in working copy or in some other dir), so that's not really awesome either.

This revision was automatically updated to reflect the committed changes.