D778: merge: backup conflicting directories when getting files
This revision was automatically updated to reflect the committed changes. Closed by commit rHGbb8928212e3a: merge: backup conflicting directories when getting files (authored by mbthomas, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D778?vs=2355=2549 REVISION DETAIL https://phab.mercurial-scm.org/D778 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1167,14 +1167,18 @@ repo.ui.note(_("getting %s\n") % f) if backup: +# If a file or directory exists with the same name, back that +# up. Otherwise, look to see if there is a file that conflicts +# with a directory this file is in, and if so, back that up. absf = repo.wjoin(f) +if not repo.wvfs.lexists(f): +for p in util.finddirs(f): +if repo.wvfs.isfileorlink(p): +absf = repo.wjoin(p) +break orig = scmutil.origpath(ui, repo, absf) -try: -if repo.wvfs.isfileorlink(f): -util.rename(absf, orig) -except OSError as e: -if e.errno != errno.ENOENT: -raise +if repo.wvfs.lexists(absf): +util.rename(absf, orig) wctx[f].clearunknown() wctx[f].write(fctx(f).data(), flags, backgroundclose=True) if i == 100: To: mbthomas, #hg-reviewers, ryanmce Cc: kiilerix, ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
ryanmce accepted this revision. ryanmce added a comment. lgtm INLINE COMMENTS > kiilerix wrote in merge.py:1175 > 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? > 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 To: mbthomas, #hg-reviewers, ryanmce Cc: kiilerix, ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
mbthomas updated this revision to Diff 2355. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D778?vs=2214=2355 REVISION DETAIL https://phab.mercurial-scm.org/D778 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1167,14 +1167,18 @@ repo.ui.note(_("getting %s\n") % f) if backup: +# If a file or directory exists with the same name, back that +# up. Otherwise, look to see if there is a file that conflicts +# with a directory this file is in, and if so, back that up. absf = repo.wjoin(f) +if not repo.wvfs.lexists(f): +for p in util.finddirs(f): +if repo.wvfs.isfileorlink(p): +absf = repo.wjoin(p) +break orig = scmutil.origpath(ui, repo, absf) -try: -if repo.wvfs.isfileorlink(f): -util.rename(absf, orig) -except OSError as e: -if e.errno != errno.ENOENT: -raise +if repo.wvfs.lexists(absf): +util.rename(absf, orig) wctx[f].clearunknown() wctx[f].write(fctx(f).data(), flags, backgroundclose=True) if i == 100: To: mbthomas, #hg-reviewers, ryanmce Cc: kiilerix, ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
mbthomas added inline comments. INLINE COMMENTS > kiilerix wrote in merge.py:1175 > 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? 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 To: mbthomas, #hg-reviewers, ryanmce Cc: kiilerix, ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
kiilerix added inline comments. INLINE COMMENTS > merge.py:1175 > +absf = repo.wjoin(p) > +break > orig = scmutil.origpath(ui, repo, absf) 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? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 To: mbthomas, #hg-reviewers, ryanmce Cc: kiilerix, ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
mbthomas updated this revision to Diff 2214. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D778?vs=1996=2214 REVISION DETAIL https://phab.mercurial-scm.org/D778 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1164,14 +1164,18 @@ repo.ui.note(_("getting %s\n") % f) if backup: +# If a file or directory exists with the same name, back that +# up. Otherwise, look to see if there is a file that conflicts +# with a directory this file is in, and if so, back that up. absf = repo.wjoin(f) +if not repo.wvfs.lexists(f): +for p in util.finddirs(f): +if repo.wvfs.isfileorlink(p): +absf = repo.wjoin(p) +break orig = scmutil.origpath(ui, repo, absf) -try: -if repo.wvfs.isfileorlink(f): -util.rename(absf, orig) -except OSError as e: -if e.errno != errno.ENOENT: -raise +if repo.wvfs.lexists(absf): +util.rename(absf, orig) wctx[f].clearunknown() wctx[f].write(fctx(f).data(), flags, backgroundclose=True) if i == 100: To: mbthomas, #hg-reviewers, ryanmce Cc: ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
mbthomas added a comment. This doesn't actually become a problem until https://phab.mercurial-scm.org/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 https://phab.mercurial-scm.org/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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 To: mbthomas, #hg-reviewers, ryanmce Cc: ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
ryanmce requested changes to this revision. ryanmce added a comment. This revision now requires changes to proceed. 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? REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 To: mbthomas, #hg-reviewers, ryanmce Cc: ryanmce, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D778: merge: backup conflicting directories when getting files
mbthomas created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D778 AFFECTED FILES mercurial/merge.py CHANGE DETAILS diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -1163,14 +1163,18 @@ repo.ui.note(_("getting %s\n") % f) if backup: +# If a file or directory exists with the same name, back that +# up. Otherwise, look to see if there is a file that conflicts +# with a directory this file is in, and if so, back that up. absf = repo.wjoin(f) +if not repo.wvfs.lexists(f): +for p in util.finddirs(f): +if repo.wvfs.isfileorlink(p): +absf = repo.wjoin(p) +break orig = scmutil.origpath(ui, repo, absf) -try: -if repo.wvfs.isfileorlink(f): -util.rename(absf, orig) -except OSError as e: -if e.errno != errno.ENOENT: -raise +if repo.wvfs.lexists(absf): +util.rename(absf, orig) wctx[f].clearunknown() wctx[f].write(fctx(f).data(), flags, backgroundclose=True) if i == 100: To: mbthomas, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel