Uploaded image for project: 'Subversion'
  1. Subversion
  2. SVN-756

Make "svn cp A B; svn mv B C" work, and be equal to "svn cp A C"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • all
    • 1.7.0
    • src

    Description

      >   svnadmin create repos
      >   svn co file:///`pwd`/repos -d r
      >   cd r
      >   mkdir 1
      >   touch 1/1
      >   svn add 1 1/1
      >   svn ci -F /dev/null
      >   svn mv 1 2
      >   svn mv 2/1 2/2
      >   svn ci -F /dev/null
      
      I see the bug, and I know what's wrong.
      
      The bug is that the second 'mv' command didn't just error out right
      there on the spot, as it should have.  
      
      Remember that a scheduled 'mv' is just a scheduled 'cp'
      (add-with-history) followed by a scheduled 'rm'.  And we *don't*
      allow something to be copied twice.  In other words:
      
         svn cp A B
         svn cp B C
      
      is illegal, and needs to be prevented by libsvn_wc... which it's
      apparently not doing anymore.  The second 'cp' is clobbering the
      entry's copyfrom-url field (which already existed from the first
      copy.)
      
      Here's a comment from our code, at the bottom of libsvn_wc/copy.c:
      
      /*
        Rabbinic Commentary
      
      
        Q:  Why can't we 'svn cp' something that we just copied?
            i.e.  'svn cp foo foo2;  svn cp foo2 foo3"
      
        A:  It leads to inconsistencies.
      
            In the example above, foo2 has no associated repository URL,
            because it hasn't been committed yet.  But suppose foo3 simply
            inherited foo's URL (i.e. foo3 'pointed' to foo as a copy
            ancestor by virtue of transitivity.)
       
            For one, this is not what the user would expect.  That's
            certainly not what the user typed!  Second, suppose that the
            user did a commit between the two 'svn cp' commands.  Now foo3
            really *would* point to foo2, but without that commit, it
            pointed to foo.  Ugly inconsistency, and the user has no idea
            that foo3's ancestor would be different in each case.
      
            And even if somehow we *could* make foo3 point to foo2 before
            foo2 existed in the repository... what's to prevent a user from
            committing foo3 first?  That would break.
      
      */
      

      Attachments

        1. 1_patch.txt
          3 kB
          Daniel Rall

        Issue Links

          Activity

            People

              Unassigned Unassigned
              blair Blair Zajac
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: