Question about mergeinfo and 2-url merge
I recently saw some mergeinfo that I can explain but still look wrong to me. Not sure if it’s a wrong usage of svn, or possibly a defect, and so far I have not seen any post about this. Here is the scenario (I have a script, batch file for windows, if needed): Seen first using svn 1.6.17, confirmed with with svn 1.14.2 Here is the setup: * Create repo with trunk and branches * Add a file to trunk * Create 2 branches from trunk, foo and bar (at this point, neither branch has mergeinfo for trunk) * In foo, edit the existing file * Make some changes in trunk (I added a file) * Merge trunk to foo (this bring the new file in and adds mergeinfo for trunk, including the revision where the new file was added) Now the fun part: * Do a 2-url merge to merge the changes solely made in foo, and apply them to bar The diff between trunk and foo shows only one file was edited (the second file does not show, since merge made it the same in trunk and foo). But the diff also shows mergeinfo changed between trunk and foo, so those get merged to bar, which seem appropriate. However, it follows that bar now indicates that it has those changes from trunk (esp. the one revision where the file was added in trunk) but of course that file is not in bar…And this occurs whether or not I use –ignore-ancestry. I could use cherrypicking instead, but I did not want to have to pick specific changes (I really want all the changes made in foo, but only those changes) So, 1)is that a misuse of svn, an unsupported scenario?. Or is there room for improvement to the mergeinfo management? 2)should I manually delete those “unwanted” mergeinfo? If I don’t, I have an idea of the issues I can run into. But I am afraid to miss something here, and removing them would cause other issues. Thanks Christophe
Re: Question about mergeinfo and 2-url merge
Thank you Daniel, below is the script I used (line wrapping might mess up a few lines, sorry) As I was cleaning it up, I realized that in 1.6.17 (yes, still using it, and where I saw the issue first) the behavior is different (2-url merge gives me a tree conflict). I am really tempted to delete the extra merginfo-that is my biggest concern at this time. - start of script (dos cmd) @ECHO off REM -- Script to test handling of merge info during a 2-url merge ECHO. ECHO -- Create empty repo in current folder md repo svnadmin create --fs-type fsfs repo\testRepo SET repoRoot=file:///%CD:\=/%/repo ECHO. ECHO -- Create sructure to import in repo md WC md WC\trunk md WC\branches svn import WC %repoRoot%/testRepo -m"Importing" rd /s /Q WC ECHO. ECHO -- Check out working copy of the entire repo svn co %repoRoot%/testRepo workingCopy ECHO. ECHO -- Play in trunk, adding one file pushd workingCopy\trunk echo Adding fileA in trunk>FileA.txt svn add FileA.txt svn commit . -m"Adding first file to trunk" popd ECHO. ECHO -- Create 2 branches from trunk. This does not create any mergeinfo svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo -m"branching to foo" --parents svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/bar -m"branching to bar" --parents ECHO. ECHO -- Add a file to trunk pushd workingCopy\trunk echo Adding fileB in trunk>FileB.txt svn add FileB.txt svn commit . -m"Adding second file to trunk" popd ECHO. ECHO -- Edit file in foo svn update workingCopy pushd workingCopy\branches\foo echo Editing first file in foo>>fileA.txt svn commit . -m"Editing file in foo" popd svn update workingCopy ECHO. ECHO -- Merge latest from trunk to foo. This creates mergeinfo in foo and brings FileB svn merge %repoRoot%/testRepo/trunk workingCopy\branches\foo svn commit workingCopy\branches\foo -m"Merging latest from trunk to foo" svn update workingCopy ECHO. ECHO -- Perform 2-URL merge to get diff between trunk and foo and apply to bar ECHO. ECHO -- Showing the diff first: fileB is not listed svn diff %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo ECHO. ECHO -- Now merging. svn 1.6.17 shows tree conflict on FileB. svn 1.14.2 shows no conflict svn merge %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo workingCopy\branches\bar REM next line is for 1.6.17 only REM : svn resolve workingCopy\branches\bar\FileB.txt --accept working svn commit workingCopy\branches\bar -m"Merging diff from trunk to foo into bar" ECHO. ECHO -- In bar, mergeinfo shows that part of trunk was merged in bar, but this is not correct ECHO -- For instance, mergeinfo shows Trunk 4-6, but the file added in trunk at r5 is not bar svn update workingCopy ECHO. ECHO. No fileB in here dir workingCopy\branches\bar ECHO. ECHO. svn pg svn:mergeinfo workingCopy\branches\bar svn mergeinfo workingCopy\trunk workingCopy\branches\bar -- end of script Christophe On 5/12/2022 10:52 AM, Daniel Shahaf wrote: Could you post the script, please? It's hard to answer your question when it describes the details verbally rather than machine-readably. It sounds like a supported scenario. Cheers, Daniel Christophe Royer wrote on Fri, 06 May 2022 21:46 +00:00: I recently saw some mergeinfo that I can explain but still look wrong to me. Not sure if it’s a wrong usage of svn, or possibly a defect, and so far I have not seen any post about this. Here is the scenario (I have a script, batch file for windows, if needed): Seen first using svn 1.6.17, confirmed with with svn 1.14.2 Here is the setup: * Create repo with trunk and branches * Add a file to trunk * Create 2 branches from trunk, foo and bar (at this point, neither branch has mergeinfo for trunk) * In foo, edit the existing file * Make some changes in trunk (I added a file) * Merge trunk to foo (this bring the new file in and adds mergeinfo for trunk, including the revision where the new file was added) Now the fun part: * Do a 2-url merge to merge the changes solely made in foo, and apply them to bar The diff between trunk and foo shows only one file was edited (the second file does not show, since merge made it the same in trunk and foo). But the diff also shows mergeinfo changed between trunk and foo, so those get merged to bar, which seem appropriate. However, it follows that bar now indicates that it has those changes from trunk (esp. the one revision where the file was added in trunk) but of course that file is not in bar…And this occurs whether or not I use –ignore-ancestry. I could use cherrypicking instead, but I did not want to have to pick specific changes (I really want all the changes made in foo, but only those changes) So, 1)is that a misuse of svn, an unsupported scenario?. Or is there room for improvement to the mergeinfo management? 2)should I manually delete tho
Re: Question about mergeinfo and 2-url merge
Daniel, the first script I sent may confuse things a little, because of the tree conflict. Here is another script that avoid that issue. The problem is the same: it looks like the mergeinfo does not match the state of the branch. -start of 2nd script @ECHO off REM -- Script to test handling of merge info during a 2-url merge REM -- this time, we setup to avoid tree conflict: we don't add file after the branches are created, REM -- we just update them REM *** REM 2 files in trunk: fileA and fileB REM 2 branches REM edit fileA in trunk, merge to foo REM edit fileB in foo REM diff between trunk and foo do NOT show fileA (merged, same im both) REM 2-url merge trunk to foo into bar: should bring changes to fileB only REM *** ECHO. ECHO -- Create empty repo in current folder md repo svnadmin create --fs-type fsfs repo\testRepo SET repoRoot=file:///%CD:\=/%/repo ECHO. ECHO -- Create sructure to import in repo md WC md WC\trunk md WC\branches svn import WC %repoRoot%/testRepo -m"Importing" rd /s /Q WC ECHO. ECHO -- Check out working copy of the entire repo svn co %repoRoot%/testRepo workingCopy ECHO. ECHO -- Play in trunk, adding two files pushd workingCopy\trunk echo Adding fileA in trunk>FileA.txt echo Adding fileB in trunk>FileB.txt svn add FileA.txt FileB.txt svn commit . -m"Adding 2 files to trunk" popd ECHO. ECHO -- Create 2 branches from trunk. This does not create any mergeinfo svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo -m"branching to foo" --parents svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/bar -m"branching to bar" --parents ECHO. ECHO -- Edit fileA in trunk svn update workingCopy pushd workingCopy\trunk echo Editing fileA in trunk>>fileA.txt svn commit . -m"Editing fileA in trunk" popd svn update workingCopy ECHO. ECHO -- Merge latest from trunk to foo. This creates mergeinfo in foo and brings fileA changes svn merge %repoRoot%/testRepo/trunk workingCopy\branches\foo svn commit workingCopy\branches\foo -m"Merging latest from trunk to foo" svn update workingCopy ECHO. ECHO -- Edit fileB in foo svn update workingCopy pushd workingCopy\branches\foo echo Editing fileB in foo>>fileB.txt svn commit . -m"Editing fileB in foo" popd svn update workingCopy ECHO. ECHO -- Perform 2-URL merge to get diff between trunk and foo and apply to bar ECHO. ECHO -- Showing the diff first: fileA is not listed (only fileB) svn diff %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo ECHO. ECHO -- Now merging svn merge %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo workingCopy\branches\bar svn commit workingCopy\branches\bar -m"Merging diff from trunk to foo into bar" svn update workingCopy ECHO. ECHO -- In bar, fileA does not have the trunk changes, good TYPE workingCopy\branches\bar\FileA.txt ECHO. ECHO -- But the trunk revision where fileA was changed (r5) shows as merged in bar ECHO -- rev5 of fileA in the trunk svn cat %repoRoot%/testRepo/trunk/FileA.txt@5 ECHO. ECHO -- mergeinfo porperty for bar svn pg svn:mergeinfo workingCopy\branches\bar ECHO. ECHO -- svn mergeinfo between trunk and bar svn mergeinfo workingCopy\trunk workingCopy\branches\bar -end of 2nd script Christophe On 5/12/2022 4:41 PM, Christophe Royer wrote: Thank you Daniel, below is the script I used (line wrapping might mess up a few lines, sorry) As I was cleaning it up, I realized that in 1.6.17 (yes, still using it, and where I saw the issue first) the behavior is different (2-url merge gives me a tree conflict). I am really tempted to delete the extra merginfo-that is my biggest concern at this time. - start of script (dos cmd) @ECHO off REM -- Script to test handling of merge info during a 2-url merge ECHO. ECHO -- Create empty repo in current folder md repo svnadmin create --fs-type fsfs repo\testRepo SET repoRoot=file:///%CD:\=/%/repo ECHO. ECHO -- Create sructure to import in repo md WC md WC\trunk md WC\branches svn import WC %repoRoot%/testRepo -m"Importing" rd /s /Q WC ECHO. ECHO -- Check out working copy of the entire repo svn co %repoRoot%/testRepo workingCopy ECHO. ECHO -- Play in trunk, adding one file pushd workingCopy\trunk echo Adding fileA in trunk>FileA.txt svn add FileA.txt svn commit . -m"Adding first file to trunk" popd ECHO. ECHO -- Create 2 branches from trunk. This does not create any mergeinfo svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/foo -m"branching to foo" --parents svn copy %repoRoot%/testRepo/trunk %repoRoot%/testRepo/branches/bar -m"branching to bar" --parents ECHO. ECHO -- Add a file to trunk pushd workingCopy\trunk echo Adding fileB in trunk>FileB.txt svn add FileB.txt svn commit . -m"Adding second file to trunk" popd ECHO. ECHO -- Edit file in foo svn update wo
Re: Question about mergeinfo and 2-url merge
Thank you for looking into this, taking the time to clean up the script and share your comments. Lessons learnt. I will likely revert (maybe manually) those invalid mergeinfo. Still not quite sure of the consequences, and if this situation could be detected. Maybe a defect or enhancement should be logged - but I am not familiar how this done. Thanks again. Christophe On 5/14/2022 5:39 AM, Daniel Shahaf wrote: Christophe Royer wrote on Fri, May 13, 2022 at 10:45:14 -0700: Daniel, the first script I sent may confuse things a little, because of the tree conflict. Here is another script that avoid that issue. The problem is the same: it looks like the mergeinfo does not match the state of the branch. [ There's a longish preface here about the reproduction script and its output. For Christophe's mergeinfo-related question, skip the triple-braced part. ] {{{ Here's a Unix version of your script: [[[ #!/usr/bin/env zsh alias '@ECHO'=: REM=: ECHO.=echo ECHO=echo md=mkdir SET='() { repoRoot=file://$PWD/repo }' TYPE=cat rd() { rm -rf -- ${argv:#/*} } s="$(< script.bat tr '\\' '/' | sed -e 's/%repoRoot%/$repoRoot/g' -e 's/FileA/fileA/g' -e 's/FileB/fileB/g' | perl -C -Mutf8 -pE $'y/()\'"/{}’”/ if /ECHO|REM/')" setopt ignorebraces set -ex eval "$s" ]]] That assumes ./script.bat contains the script you posted, without the delimiter lines. It's written as a dense multilingual mix because it doesn't need to be team-maintained indefinitely going forward, so I optimized for whatever was fastest to implement. It'd be fairly easy to port that to sh if need be. Also, it would also have been helpful if you hadn't used different letter cases to refer to a single on-disk file, to make it easier to port the script; if the script began by deleting ./repo ./WC ./workingCopy, so it would be easier to re-run it; and if the script had been attached rather than inlined, because long lines were hard-wrapped along the way; and if you'd posted your script's _output_ as well as its code, so those of us on other platforms would be able to analyze the script without porting it first. Anyway, no harm done. Here's the script's output: +(eval):1> : off +(eval):2> : -- Script to test handling of merge info during a 2-url merge +(eval):3> : -- this time, we setup to avoid tree conflict: we don’t add file after the branches are created, +(eval):4> : -- we just update them +(eval):7> : script.bat script.zsh +(eval):8> : 2 files in trunk: fileA and fileB +(eval):9> : 2 branches +(eval):10> : edit fileA in trunk, merge to foo +(eval):11> : edit fileB in foo +(eval):12> : diff between trunk and foo do NOT show fileA '{merged,' same im 'both}' +(eval):13> : 2-url merge trunk to foo into bar: should bring changes to fileB only +(eval):14> : script.bat script.zsh +(eval):17> echo +(eval):18> echo -- Create empty repo in current folder -- Create empty repo in current folder +(eval):19> mkdir repo +(eval):20> svnadmin create --fs-type fsfs repo/testRepo +(eval):22> '(anon)' 'repoRoot=file:///%CD:/=/%/repo' +(anon):0> repoRoot=file:///scratch/tmp.9SbJ9D2q2o/repo +(eval):24> echo +(eval):25> echo -- Create sructure to import in repo -- Create sructure to import in repo +(eval):26> mkdir WC +(eval):27> mkdir WC/trunk +(eval):28> mkdir WC/branches +(eval):29> svn import WC file:///scratch/tmp.9SbJ9D2q2o/repo/testRepo -mImporting Adding WC/branches Adding WC/trunk Committing transaction... Committed revision 1. +(eval):30> rd /s /Q WC +rd:0> rm -rf -- WC +(eval):32> echo +(eval):33> echo -- Check out working copy of the entire repo -- Check out working copy of the entire repo +(eval):34> svn co file:///scratch/tmp.9SbJ9D2q2o/repo/testRepo workingCopy AworkingCopy/branches AworkingCopy/trunk Checked out revision 1. +(eval):36> echo +(eval):37> echo -- Play in trunk, adding two files -- Play in trunk, adding two files +(eval):38> pushd workingCopy/trunk +(eval):39> echo Adding fileA in trunk +(eval):40> echo Adding fileB in trunk +(eval):41> svn add fileA.txt fileB.txt A fileA.txt A fileB.txt +(eval):42> svn commit . '-mAdding 2 files to trunk' Adding fileA.txt Adding fileB.txt Transmitting file data ..done Committing transaction... Committed revision 2. +(eval):43> popd +(eval):45> echo +(eval):46> echo -- Create 2 branches from trunk. This does not create any mergeinfo -- Create 2 branches from trunk. This does not create any mergeinfo +(eval):47> svn copy file:///scratch/tmp.9SbJ9D2q2o/repo/testRepo/trunk file:///scratch/tmp.9SbJ9D2q2o/repo/testRepo/branches/foo '-mbranching to foo' --parents Committing transaction...