def checkout_with_obstructions(sbox): """co with obstructions conflicts without --force""" make_local_tree(sbox, False, False) #svntest.factory.make(sbox, # """# Checkout with unversioned obstructions lying around. # svn co url wc_dir # svn status""") #svntest.factory.make(sbox, # """# Now see to it that we can recover from the obstructions. # rm -rf A iota # svn up""") #exit(0) wc_dir = sbox.wc_dir url = sbox.repo_url # Checkout with unversioned obstructions causes tree conflicts. # svn co url wc_dir expected_output = svntest.wc.State( wc_dir, { 'iota': Item(status=' ', treeconflict='C'), 'A': Item(status=' ', treeconflict='C'), # And the updates below the tree conflict 'A/D': Item(status=' ', treeconflict='A'), 'A/D/gamma': Item(status=' ', treeconflict='A'), 'A/D/G': Item(status=' ', treeconflict='A'), 'A/D/G/rho': Item(status=' ', treeconflict='A'), 'A/D/G/pi': Item(status=' ', treeconflict='A'), 'A/D/G/tau': Item(status=' ', treeconflict='A'), 'A/D/H': Item(status=' ', treeconflict='A'), 'A/D/H/chi': Item(status=' ', treeconflict='A'), 'A/D/H/omega': Item(status=' ', treeconflict='A'), 'A/D/H/psi': Item(status=' ', treeconflict='A'), 'A/B': Item(status=' ', treeconflict='A'), 'A/B/E': Item(status=' ', treeconflict='A'), 'A/B/E/beta': Item(status=' ', treeconflict='A'), 'A/B/E/alpha': Item(status=' ', treeconflict='A'), 'A/B/F': Item(status=' ', treeconflict='A'), 'A/B/lambda': Item(status=' ', treeconflict='A'), 'A/C': Item(status=' ', treeconflict='A'), 'A/mu': Item(status=' ', treeconflict='A'), }) expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/psi', 'A/D/H/omega', 'A/D/H/chi', 'A/D/gamma', 'A/C') actions.run_and_verify_checkout2(False, url, wc_dir, expected_output, expected_disk, None, None, None, None) # svn status expected_status = actions.get_virginal_state(wc_dir, 1) # A and iota are tree conflicted and obstructed expected_status.tweak('A', 'iota', status='D ', wc_rev=1, treeconflict='C') expected_status.tweak('A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma', 'A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/C', status='D ') # A/mu exists on disk, but is deleted expected_status.tweak('A/mu', status='D ') actions.run_and_verify_unquiet_status(wc_dir, expected_status) # Now see to it that we can recover from the obstructions. # rm -rf A iota svntest.main.safe_rmtree(os.path.join(wc_dir, 'A')) os.remove(os.path.join(wc_dir, 'iota')) svntest.main.run_svn(None, 'revert', '-R', os.path.join(wc_dir, 'A'), os.path.join(wc_dir, 'iota')) # svn up expected_output = svntest.wc.State(wc_dir, {}) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir, 1) actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status, None, None, None, None, None, False, wc_dir)
def forced_checkout_of_dir_with_file_obstructions(sbox): """forced co flags conflict if a file obstructs a dir""" make_local_tree(sbox, False, False) #svntest.factory.make(sbox,""" # mkdir wc_dir_other # echo "The file A" > wc_dir_other/A # svn co --force url wc_dir_other # """) #svntest.factory.make(sbox,""" # # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A # svn up wc_dir_other""") #exit(0) url = sbox.repo_url wc_dir_other = sbox.add_wc_path('other') other_A = os.path.join(wc_dir_other, 'A') # mkdir wc_dir_other os.makedirs(wc_dir_other) # echo "The file A" > wc_dir_other/A svntest.main.file_write(other_A, 'The file A\n') # svn co --force url wc_dir_other expected_output = svntest.wc.State( wc_dir_other, { 'iota': Item(status='A '), 'A': Item(status=' ', treeconflict='C'), # And what happens below A 'A/mu': Item(status=' ', treeconflict='A'), 'A/D': Item(status=' ', treeconflict='A'), 'A/D/G': Item(status=' ', treeconflict='A'), 'A/D/G/tau': Item(status=' ', treeconflict='A'), 'A/D/G/pi': Item(status=' ', treeconflict='A'), 'A/D/G/rho': Item(status=' ', treeconflict='A'), 'A/D/H': Item(status=' ', treeconflict='A'), 'A/D/H/psi': Item(status=' ', treeconflict='A'), 'A/D/H/omega': Item(status=' ', treeconflict='A'), 'A/D/H/chi': Item(status=' ', treeconflict='A'), 'A/D/gamma': Item(status=' ', treeconflict='A'), 'A/C': Item(status=' ', treeconflict='A'), 'A/B': Item(status=' ', treeconflict='A'), 'A/B/E': Item(status=' ', treeconflict='A'), 'A/B/E/beta': Item(status=' ', treeconflict='A'), 'A/B/E/alpha': Item(status=' ', treeconflict='A'), 'A/B/F': Item(status=' ', treeconflict='A'), 'A/B/lambda': Item(status=' ', treeconflict='A'), }) expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/psi', 'A/D/H/omega', 'A/D/H/chi', 'A/D/gamma', 'A/mu', 'A/C') expected_disk.tweak('A', contents='The file A\n') actions.run_and_verify_checkout(url, wc_dir_other, expected_output, expected_disk, None, None, None, None, '--force') # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A os.remove(other_A) # svn up wc_dir_other expected_output = svntest.wc.State(wc_dir_other, {}) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir_other, 1) svntest.main.run_svn(None, 'revert', '-R', os.path.join(wc_dir_other, 'A')) actions.run_and_verify_update(wc_dir_other, expected_output, expected_disk, expected_status, None, None, None, None, None, False, wc_dir_other)
def forced_checkout_of_dir_with_file_obstructions(sbox): """forced co flags conflict if a file obstructs a dir""" make_local_tree(sbox, False, False) #svntest.factory.make(sbox,""" # mkdir wc_dir_other # echo "The file A" > wc_dir_other/A # svn co --force url wc_dir_other # """) #svntest.factory.make(sbox,""" # # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A # svn up wc_dir_other""") #exit(0) url = sbox.repo_url wc_dir_other = sbox.add_wc_path('other') other_A = os.path.join(wc_dir_other, 'A') # mkdir wc_dir_other os.makedirs(wc_dir_other) # echo "The file A" > wc_dir_other/A svntest.main.file_write(other_A, 'The file A\n') # svn co --force url wc_dir_other expected_output = svntest.wc.State(wc_dir_other, { 'iota' : Item(status='A '), 'A' : Item(status=' ', treeconflict='C'), # And what happens below A 'A/mu' : Item(status=' ', treeconflict='A'), 'A/D' : Item(status=' ', treeconflict='A'), 'A/D/G' : Item(status=' ', treeconflict='A'), 'A/D/G/tau' : Item(status=' ', treeconflict='A'), 'A/D/G/pi' : Item(status=' ', treeconflict='A'), 'A/D/G/rho' : Item(status=' ', treeconflict='A'), 'A/D/H' : Item(status=' ', treeconflict='A'), 'A/D/H/psi' : Item(status=' ', treeconflict='A'), 'A/D/H/omega' : Item(status=' ', treeconflict='A'), 'A/D/H/chi' : Item(status=' ', treeconflict='A'), 'A/D/gamma' : Item(status=' ', treeconflict='A'), 'A/C' : Item(status=' ', treeconflict='A'), 'A/B' : Item(status=' ', treeconflict='A'), 'A/B/E' : Item(status=' ', treeconflict='A'), 'A/B/E/beta' : Item(status=' ', treeconflict='A'), 'A/B/E/alpha' : Item(status=' ', treeconflict='A'), 'A/B/F' : Item(status=' ', treeconflict='A'), 'A/B/lambda' : Item(status=' ', treeconflict='A'), }) expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/psi', 'A/D/H/omega', 'A/D/H/chi', 'A/D/gamma', 'A/mu', 'A/C') expected_disk.tweak('A', contents='The file A\n') actions.run_and_verify_checkout(url, wc_dir_other, expected_output, expected_disk, [], '--force') # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A os.remove(other_A) # svn up wc_dir_other expected_output = svntest.wc.State(wc_dir_other, { }) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir_other, 1) svntest.main.run_svn(None, 'revert', '-R', os.path.join(wc_dir_other, 'A')) actions.run_and_verify_update(wc_dir_other, expected_output, expected_disk, expected_status)
def get_trojan_virginal_state(sbox): return actions.get_virginal_state(sbox.wc_dir, '1', tree='trojan')
def set_up_branch(sbox, branch_only=False, nbr_of_branches=1): '''Starting with standard greek tree, copy 'A' NBR_OF_BRANCHES times to A_COPY, A_COPY_2, A_COPY_3, and so on. Then, unless BRANCH_ONLY is true, make four modifications (setting file contents to "New content") under A: r(2 + NBR_OF_BRANCHES) - A/D/H/psi r(3 + NBR_OF_BRANCHES) - A/D/G/rho r(4 + NBR_OF_BRANCHES) - A/B/E/beta r(5 + NBR_OF_BRANCHES) - A/D/H/omega Return (expected_disk, expected_status).''' # With the default parameters, the branching looks like this: # # A -1-----3-4-5-6-- # \ # A_COPY 2----------- wc_dir = sbox.wc_dir expected_status = actions.get_virginal_state(wc_dir, 1) expected_disk = main.greek_state.copy() def path_join(head, tail): if not head: return tail if not tail: return head return head + '/' + tail def greek_file_item(path): if path[-1:].islower(): basename = re.sub('.*/', '', path) return Item("This is the file '" + basename + "'.\n") return Item() A_paths = [ "", "B", "B/lambda", "B/E", "B/E/alpha", "B/E/beta", "B/F", "mu", "C", "D", "D/gamma", "D/G", "D/G/pi", "D/G/rho", "D/G/tau", "D/H", "D/H/chi", "D/H/omega", "D/H/psi", ] def copy_A(dest_name, rev): expected = verify.UnorderedOutput([ "A " + sbox.ospath(path_join(dest_name, p)) + "\n" for p in A_paths ]) expected_status.add({ path_join(dest_name, p): Item(status=' ', wc_rev=rev) for p in A_paths }) expected_disk.add( {path_join(dest_name, p): greek_file_item(p) for p in A_paths}) # Make a branch A_COPY to merge into. actions.run_and_verify_svn(expected, [], 'copy', sbox.repo_url + "/A", os.path.join(wc_dir, dest_name)) expected_output = wc.State(wc_dir, {dest_name: Item(verb='Adding')}) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) for i in range(nbr_of_branches): if i == 0: copy_A('A_COPY', i + 2) else: copy_A('A_COPY_' + str(i + 1), i + 2) if branch_only: return expected_disk, expected_status # Make some changes under A which we'll later merge under A_COPY: # r(nbr_of_branches + 2) - modify and commit A/D/H/psi main.file_write(sbox.ospath('A/D/H/psi'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/psi': Item(verb='Sending')}) expected_status.tweak('A/D/H/psi', wc_rev=nbr_of_branches + 2) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/psi', contents="New content") # r(nbr_of_branches + 3) - modify and commit A/D/G/rho main.file_write(sbox.ospath('A/D/G/rho'), "New content") expected_output = wc.State(wc_dir, {'A/D/G/rho': Item(verb='Sending')}) expected_status.tweak('A/D/G/rho', wc_rev=nbr_of_branches + 3) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/G/rho', contents="New content") # r(nbr_of_branches + 4) - modify and commit A/B/E/beta main.file_write(sbox.ospath('A/B/E/beta'), "New content") expected_output = wc.State(wc_dir, {'A/B/E/beta': Item(verb='Sending')}) expected_status.tweak('A/B/E/beta', wc_rev=nbr_of_branches + 4) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/B/E/beta', contents="New content") # r(nbr_of_branches + 5) - modify and commit A/D/H/omega main.file_write(sbox.ospath('A/D/H/omega'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/omega': Item(verb='Sending')}) expected_status.tweak('A/D/H/omega', wc_rev=nbr_of_branches + 5) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/omega', contents="New content") return expected_disk, expected_status
def checkout_with_obstructions(sbox): """co with obstructions conflicts without --force""" make_local_tree(sbox, False, False) #svntest.factory.make(sbox, # """# Checkout with unversioned obstructions lying around. # svn co url wc_dir # svn status""") #svntest.factory.make(sbox, # """# Now see to it that we can recover from the obstructions. # rm -rf A iota # svn up""") #exit(0) wc_dir = sbox.wc_dir url = sbox.repo_url # Checkout with unversioned obstructions causes tree conflicts. # svn co url wc_dir expected_output = svntest.wc.State(wc_dir, { 'iota' : Item(status=' ', treeconflict='C'), 'A' : Item(status=' ', treeconflict='C'), # And the updates below the tree conflict 'A/D' : Item(status=' ', treeconflict='A'), 'A/D/gamma' : Item(status=' ', treeconflict='A'), 'A/D/G' : Item(status=' ', treeconflict='A'), 'A/D/G/rho' : Item(status=' ', treeconflict='A'), 'A/D/G/pi' : Item(status=' ', treeconflict='A'), 'A/D/G/tau' : Item(status=' ', treeconflict='A'), 'A/D/H' : Item(status=' ', treeconflict='A'), 'A/D/H/chi' : Item(status=' ', treeconflict='A'), 'A/D/H/omega' : Item(status=' ', treeconflict='A'), 'A/D/H/psi' : Item(status=' ', treeconflict='A'), 'A/B' : Item(status=' ', treeconflict='A'), 'A/B/E' : Item(status=' ', treeconflict='A'), 'A/B/E/beta' : Item(status=' ', treeconflict='A'), 'A/B/E/alpha' : Item(status=' ', treeconflict='A'), 'A/B/F' : Item(status=' ', treeconflict='A'), 'A/B/lambda' : Item(status=' ', treeconflict='A'), 'A/C' : Item(status=' ', treeconflict='A'), 'A/mu' : Item(status=' ', treeconflict='A'), }) expected_disk = svntest.main.greek_state.copy() expected_disk.remove('A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/psi', 'A/D/H/omega', 'A/D/H/chi', 'A/D/gamma', 'A/C') actions.run_and_verify_checkout(url, wc_dir, expected_output, expected_disk) # svn status expected_status = actions.get_virginal_state(wc_dir, 1) # A and iota are tree conflicted and obstructed expected_status.tweak('A', 'iota', status='D ', wc_rev=1, treeconflict='C') expected_status.tweak('A/D', 'A/D/G', 'A/D/G/rho', 'A/D/G/pi', 'A/D/G/tau', 'A/D/H', 'A/D/H/chi', 'A/D/H/omega', 'A/D/H/psi', 'A/D/gamma', 'A/B', 'A/B/E', 'A/B/E/beta', 'A/B/E/alpha', 'A/B/F', 'A/B/lambda', 'A/C', status='D ') # A/mu exists on disk, but is deleted expected_status.tweak('A/mu', status='D ') actions.run_and_verify_unquiet_status(wc_dir, expected_status) # Now see to it that we can recover from the obstructions. # rm -rf A iota svntest.main.safe_rmtree( os.path.join(wc_dir, 'A') ) os.remove( os.path.join(wc_dir, 'iota') ) svntest.main.run_svn(None, 'revert', '-R', os.path.join(wc_dir, 'A'), os.path.join(wc_dir, 'iota')) # svn up expected_output = svntest.wc.State(wc_dir, { }) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir, 1) actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status,)
def set_up_dir_replace(sbox): """Set up the working copy for directory replace tests, creating directory 'A/B/F/foo' with files 'new file' and 'new file2' within it (r2), and merging 'foo' onto 'C' (r3), then deleting 'A/B/F/foo' (r4).""" sbox.build() wc_dir = sbox.wc_dir C_path = sbox.ospath('A/C') F_path = sbox.ospath('A/B/F') F_url = sbox.repo_url + '/A/B/F' foo_path = os.path.join(F_path, 'foo') new_file = os.path.join(foo_path, "new file") new_file2 = os.path.join(foo_path, "new file 2") # Make directory foo in F, and add some files within it. actions.run_and_verify_svn(None, [], 'mkdir', foo_path) main.file_append(new_file, "Initial text in new file.\n") main.file_append(new_file2, "Initial text in new file 2.\n") main.run_svn(None, "add", new_file) main.run_svn(None, "add", new_file2) # Commit all the new content, creating r2. expected_output = wc.State( wc_dir, { 'A/B/F/foo': Item(verb='Adding'), 'A/B/F/foo/new file': Item(verb='Adding'), 'A/B/F/foo/new file 2': Item(verb='Adding'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/B/F/foo': Item(status=' ', wc_rev=2), 'A/B/F/foo/new file': Item(status=' ', wc_rev=2), 'A/B/F/foo/new file 2': Item(status=' ', wc_rev=2), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) # Merge foo onto C expected_output = wc.State( C_path, { 'foo': Item(status='A '), 'foo/new file': Item(status='A '), 'foo/new file 2': Item(status='A '), }) expected_mergeinfo_output = wc.State(C_path, { '': Item(status=' U'), }) expected_elision_output = wc.State(C_path, {}) expected_disk = wc.State( '', { '': Item(props={SVN_PROP_MERGEINFO: '/A/B/F:2'}), 'foo': Item(), 'foo/new file': Item("Initial text in new file.\n"), 'foo/new file 2': Item("Initial text in new file 2.\n"), }) expected_status = wc.State( C_path, { '': Item(status=' M', wc_rev=1), 'foo': Item(status='A ', wc_rev='-', copied='+'), 'foo/new file': Item(status=' ', wc_rev='-', copied='+'), 'foo/new file 2': Item(status=' ', wc_rev='-', copied='+'), }) expected_skip = wc.State(C_path, {}) actions.run_and_verify_merge(C_path, '1', '2', F_url, None, expected_output, expected_mergeinfo_output, expected_elision_output, expected_disk, expected_status, expected_skip, check_props=True) # Commit merge of foo onto C, creating r3. expected_output = wc.State(wc_dir, { 'A/C': Item(verb='Sending'), 'A/C/foo': Item(verb='Adding'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/B/F/foo': Item(status=' ', wc_rev=2), 'A/C': Item(status=' ', wc_rev=3), 'A/B/F/foo/new file': Item(status=' ', wc_rev=2), 'A/B/F/foo/new file 2': Item(status=' ', wc_rev=2), 'A/C/foo': Item(status=' ', wc_rev=3), 'A/C/foo/new file': Item(status=' ', wc_rev=3), 'A/C/foo/new file 2': Item(status=' ', wc_rev=3), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) # Delete foo on F, creating r4. actions.run_and_verify_svn(None, [], 'rm', foo_path) expected_output = wc.State(wc_dir, { 'A/B/F/foo': Item(verb='Deleting'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/C': Item(status=' ', wc_rev=3), 'A/C/foo': Item(status=' ', wc_rev=3), 'A/C/foo/new file': Item(status=' ', wc_rev=3), 'A/C/foo/new file 2': Item(status=' ', wc_rev=3), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status)
def set_up_branch(sbox, branch_only=False, nbr_of_branches=1): '''Starting with standard greek tree, copy 'A' NBR_OF_BRANCHES times to A_COPY, A_COPY_2, A_COPY_3, and so on. Then, unless BRANCH_ONLY is true, make four modifications (setting file contents to "New content") under A: r(2 + NBR_OF_BRANCHES) - A/D/H/psi r(3 + NBR_OF_BRANCHES) - A/D/G/rho r(4 + NBR_OF_BRANCHES) - A/B/E/beta r(5 + NBR_OF_BRANCHES) - A/D/H/omega Return (expected_disk, expected_status).''' # With the default parameters, the branching looks like this: # # A -1-----3-4-5-6-- # \ # A_COPY 2----------- wc_dir = sbox.wc_dir expected_status = actions.get_virginal_state(wc_dir, 1) expected_disk = main.greek_state.copy() def copy_A(dest_name, rev): expected = verify.UnorderedOutput([ "A " + os.path.join(wc_dir, dest_name, "B") + "\n", "A " + os.path.join(wc_dir, dest_name, "B", "lambda") + "\n", "A " + os.path.join(wc_dir, dest_name, "B", "E") + "\n", "A " + os.path.join(wc_dir, dest_name, "B", "E", "alpha") + "\n", "A " + os.path.join(wc_dir, dest_name, "B", "E", "beta") + "\n", "A " + os.path.join(wc_dir, dest_name, "B", "F") + "\n", "A " + os.path.join(wc_dir, dest_name, "mu") + "\n", "A " + os.path.join(wc_dir, dest_name, "C") + "\n", "A " + os.path.join(wc_dir, dest_name, "D") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "gamma") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "G") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "G", "pi") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "G", "rho") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "G", "tau") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "H") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "H", "chi") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "H", "omega") + "\n", "A " + os.path.join(wc_dir, dest_name, "D", "H", "psi") + "\n", "Checked out revision " + str(rev - 1) + ".\n", "A " + os.path.join(wc_dir, dest_name) + "\n" ]) expected_status.add({ dest_name + "/B": Item(status=' ', wc_rev=rev), dest_name + "/B/lambda": Item(status=' ', wc_rev=rev), dest_name + "/B/E": Item(status=' ', wc_rev=rev), dest_name + "/B/E/alpha": Item(status=' ', wc_rev=rev), dest_name + "/B/E/beta": Item(status=' ', wc_rev=rev), dest_name + "/B/F": Item(status=' ', wc_rev=rev), dest_name + "/mu": Item(status=' ', wc_rev=rev), dest_name + "/C": Item(status=' ', wc_rev=rev), dest_name + "/D": Item(status=' ', wc_rev=rev), dest_name + "/D/gamma": Item(status=' ', wc_rev=rev), dest_name + "/D/G": Item(status=' ', wc_rev=rev), dest_name + "/D/G/pi": Item(status=' ', wc_rev=rev), dest_name + "/D/G/rho": Item(status=' ', wc_rev=rev), dest_name + "/D/G/tau": Item(status=' ', wc_rev=rev), dest_name + "/D/H": Item(status=' ', wc_rev=rev), dest_name + "/D/H/chi": Item(status=' ', wc_rev=rev), dest_name + "/D/H/omega": Item(status=' ', wc_rev=rev), dest_name + "/D/H/psi": Item(status=' ', wc_rev=rev), dest_name: Item(status=' ', wc_rev=rev) }) expected_disk.add({ dest_name: Item(), dest_name + '/B': Item(), dest_name + '/B/lambda': Item("This is the file 'lambda'.\n"), dest_name + '/B/E': Item(), dest_name + '/B/E/alpha': Item("This is the file 'alpha'.\n"), dest_name + '/B/E/beta': Item("This is the file 'beta'.\n"), dest_name + '/B/F': Item(), dest_name + '/mu': Item("This is the file 'mu'.\n"), dest_name + '/C': Item(), dest_name + '/D': Item(), dest_name + '/D/gamma': Item("This is the file 'gamma'.\n"), dest_name + '/D/G': Item(), dest_name + '/D/G/pi': Item("This is the file 'pi'.\n"), dest_name + '/D/G/rho': Item("This is the file 'rho'.\n"), dest_name + '/D/G/tau': Item("This is the file 'tau'.\n"), dest_name + '/D/H': Item(), dest_name + '/D/H/chi': Item("This is the file 'chi'.\n"), dest_name + '/D/H/omega': Item("This is the file 'omega'.\n"), dest_name + '/D/H/psi': Item("This is the file 'psi'.\n"), }) # Make a branch A_COPY to merge into. actions.run_and_verify_svn(expected, [], 'copy', sbox.repo_url + "/A", os.path.join(wc_dir, dest_name)) expected_output = wc.State(wc_dir, {dest_name: Item(verb='Adding')}) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) for i in range(nbr_of_branches): if i == 0: copy_A('A_COPY', i + 2) else: copy_A('A_COPY_' + str(i + 1), i + 2) if branch_only: return expected_disk, expected_status # Make some changes under A which we'll later merge under A_COPY: # r(nbr_of_branches + 2) - modify and commit A/D/H/psi main.file_write(sbox.ospath('A/D/H/psi'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/psi': Item(verb='Sending')}) expected_status.tweak('A/D/H/psi', wc_rev=nbr_of_branches + 2) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/psi', contents="New content") # r(nbr_of_branches + 3) - modify and commit A/D/G/rho main.file_write(sbox.ospath('A/D/G/rho'), "New content") expected_output = wc.State(wc_dir, {'A/D/G/rho': Item(verb='Sending')}) expected_status.tweak('A/D/G/rho', wc_rev=nbr_of_branches + 3) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/G/rho', contents="New content") # r(nbr_of_branches + 4) - modify and commit A/B/E/beta main.file_write(sbox.ospath('A/B/E/beta'), "New content") expected_output = wc.State(wc_dir, {'A/B/E/beta': Item(verb='Sending')}) expected_status.tweak('A/B/E/beta', wc_rev=nbr_of_branches + 4) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/B/E/beta', contents="New content") # r(nbr_of_branches + 5) - modify and commit A/D/H/omega main.file_write(sbox.ospath('A/D/H/omega'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/omega': Item(verb='Sending')}) expected_status.tweak('A/D/H/omega', wc_rev=nbr_of_branches + 5) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/omega', contents="New content") return expected_disk, expected_status
def set_up_branch(sbox, branch_only = False, nbr_of_branches = 1): '''Starting with standard greek tree, copy 'A' NBR_OF_BRANCHES times to A_COPY, A_COPY_2, A_COPY_3, and so on. Then, unless BRANCH_ONLY is true, make four modifications (setting file contents to "New content") under A: r(2 + NBR_OF_BRANCHES) - A/D/H/psi r(3 + NBR_OF_BRANCHES) - A/D/G/rho r(4 + NBR_OF_BRANCHES) - A/B/E/beta r(5 + NBR_OF_BRANCHES) - A/D/H/omega Return (expected_disk, expected_status).''' # With the default parameters, the branching looks like this: # # A -1-----3-4-5-6-- # \ # A_COPY 2----------- wc_dir = sbox.wc_dir expected_status = actions.get_virginal_state(wc_dir, 1) expected_disk = main.greek_state.copy() def path_join(head, tail): if not head: return tail if not tail: return head return head + '/' + tail def greek_file_item(path): if path[-1:].islower(): basename = re.sub('.*/', '', path) return Item("This is the file '" + basename + "'.\n") return Item() A_paths = [ "", "B", "B/lambda", "B/E", "B/E/alpha", "B/E/beta", "B/F", "mu", "C", "D", "D/gamma", "D/G", "D/G/pi", "D/G/rho", "D/G/tau", "D/H", "D/H/chi", "D/H/omega", "D/H/psi", ] def copy_A(dest_name, rev): expected = verify.UnorderedOutput( [ "A " + sbox.ospath(path_join(dest_name, p)) + "\n" for p in A_paths ]) expected_status.add( { path_join(dest_name, p) : Item(status=' ', wc_rev=rev) for p in A_paths }) expected_disk.add( { path_join(dest_name, p) : greek_file_item(p) for p in A_paths }) # Make a branch A_COPY to merge into. actions.run_and_verify_svn(expected, [], 'copy', sbox.repo_url + "/A", os.path.join(wc_dir, dest_name)) expected_output = wc.State(wc_dir, {dest_name : Item(verb='Adding')}) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) for i in range(nbr_of_branches): if i == 0: copy_A('A_COPY', i + 2) else: copy_A('A_COPY_' + str(i + 1), i + 2) if branch_only: return expected_disk, expected_status # Make some changes under A which we'll later merge under A_COPY: # r(nbr_of_branches + 2) - modify and commit A/D/H/psi main.file_write(sbox.ospath('A/D/H/psi'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/psi' : Item(verb='Sending')}) expected_status.tweak('A/D/H/psi', wc_rev=nbr_of_branches + 2) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/psi', contents="New content") # r(nbr_of_branches + 3) - modify and commit A/D/G/rho main.file_write(sbox.ospath('A/D/G/rho'), "New content") expected_output = wc.State(wc_dir, {'A/D/G/rho' : Item(verb='Sending')}) expected_status.tweak('A/D/G/rho', wc_rev=nbr_of_branches + 3) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/G/rho', contents="New content") # r(nbr_of_branches + 4) - modify and commit A/B/E/beta main.file_write(sbox.ospath('A/B/E/beta'), "New content") expected_output = wc.State(wc_dir, {'A/B/E/beta' : Item(verb='Sending')}) expected_status.tweak('A/B/E/beta', wc_rev=nbr_of_branches + 4) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/B/E/beta', contents="New content") # r(nbr_of_branches + 5) - modify and commit A/D/H/omega main.file_write(sbox.ospath('A/D/H/omega'), "New content") expected_output = wc.State(wc_dir, {'A/D/H/omega' : Item(verb='Sending')}) expected_status.tweak('A/D/H/omega', wc_rev=nbr_of_branches + 5) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) expected_disk.tweak('A/D/H/omega', contents="New content") return expected_disk, expected_status
def set_up_dir_replace(sbox): """Set up the working copy for directory replace tests, creating directory 'A/B/F/foo' with files 'new file' and 'new file2' within it (r2), and merging 'foo' onto 'C' (r3), then deleting 'A/B/F/foo' (r4).""" sbox.build() wc_dir = sbox.wc_dir C_path = sbox.ospath('A/C') F_path = sbox.ospath('A/B/F') F_url = sbox.repo_url + '/A/B/F' foo_path = os.path.join(F_path, 'foo') new_file = os.path.join(foo_path, "new file") new_file2 = os.path.join(foo_path, "new file 2") # Make directory foo in F, and add some files within it. actions.run_and_verify_svn(None, [], 'mkdir', foo_path) main.file_append(new_file, "Initial text in new file.\n") main.file_append(new_file2, "Initial text in new file 2.\n") main.run_svn(None, "add", new_file) main.run_svn(None, "add", new_file2) # Commit all the new content, creating r2. expected_output = wc.State(wc_dir, { 'A/B/F/foo' : Item(verb='Adding'), 'A/B/F/foo/new file' : Item(verb='Adding'), 'A/B/F/foo/new file 2' : Item(verb='Adding'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/B/F/foo' : Item(status=' ', wc_rev=2), 'A/B/F/foo/new file' : Item(status=' ', wc_rev=2), 'A/B/F/foo/new file 2' : Item(status=' ', wc_rev=2), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) # Merge foo onto C expected_output = wc.State(C_path, { 'foo' : Item(status='A '), 'foo/new file' : Item(status='A '), 'foo/new file 2' : Item(status='A '), }) expected_mergeinfo_output = wc.State(C_path, { '' : Item(status=' U'), }) expected_elision_output = wc.State(C_path, { }) expected_disk = wc.State('', { '' : Item(props={SVN_PROP_MERGEINFO : '/A/B/F:2'}), 'foo' : Item(), 'foo/new file' : Item("Initial text in new file.\n"), 'foo/new file 2' : Item("Initial text in new file 2.\n"), }) expected_status = wc.State(C_path, { '' : Item(status=' M', wc_rev=1), 'foo' : Item(status='A ', wc_rev='-', copied='+'), 'foo/new file' : Item(status=' ', wc_rev='-', copied='+'), 'foo/new file 2' : Item(status=' ', wc_rev='-', copied='+'), }) expected_skip = wc.State(C_path, { }) actions.run_and_verify_merge(C_path, '1', '2', F_url, None, expected_output, expected_mergeinfo_output, expected_elision_output, expected_disk, expected_status, expected_skip, check_props=True) # Commit merge of foo onto C, creating r3. expected_output = wc.State(wc_dir, { 'A/C' : Item(verb='Sending'), 'A/C/foo' : Item(verb='Adding'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/B/F/foo' : Item(status=' ', wc_rev=2), 'A/C' : Item(status=' ', wc_rev=3), 'A/B/F/foo/new file' : Item(status=' ', wc_rev=2), 'A/B/F/foo/new file 2' : Item(status=' ', wc_rev=2), 'A/C/foo' : Item(status=' ', wc_rev=3), 'A/C/foo/new file' : Item(status=' ', wc_rev=3), 'A/C/foo/new file 2' : Item(status=' ', wc_rev=3), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status) # Delete foo on F, creating r4. actions.run_and_verify_svn(None, [], 'rm', foo_path) expected_output = wc.State(wc_dir, { 'A/B/F/foo' : Item(verb='Deleting'), }) expected_status = actions.get_virginal_state(wc_dir, 1) expected_status.add({ 'A/C' : Item(status=' ', wc_rev=3), 'A/C/foo' : Item(status=' ', wc_rev=3), 'A/C/foo/new file' : Item(status=' ', wc_rev=3), 'A/C/foo/new file 2' : Item(status=' ', wc_rev=3), }) actions.run_and_verify_commit(wc_dir, expected_output, expected_status)
def forced_checkout_of_dir_with_file_obstructions(sbox): """forced co flags conflict if a file obstructs a dir""" make_local_tree(sbox, False, False) # svntest.factory.make(sbox,""" # mkdir wc_dir_other # echo "The file A" > wc_dir_other/A # svn co --force url wc_dir_other # """) # svntest.factory.make(sbox,""" # # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A # svn up wc_dir_other""") # exit(0) url = sbox.repo_url wc_dir_other = sbox.add_wc_path("other") other_A = os.path.join(wc_dir_other, "A") # mkdir wc_dir_other os.makedirs(wc_dir_other) # echo "The file A" > wc_dir_other/A svntest.main.file_write(other_A, "The file A\n") # svn co --force url wc_dir_other expected_output = svntest.wc.State( wc_dir_other, { "iota": Item(status="A "), "A": Item(status=" ", treeconflict="C"), # And what happens below A "A/mu": Item(status=" ", treeconflict="A"), "A/D": Item(status=" ", treeconflict="A"), "A/D/G": Item(status=" ", treeconflict="A"), "A/D/G/tau": Item(status=" ", treeconflict="A"), "A/D/G/pi": Item(status=" ", treeconflict="A"), "A/D/G/rho": Item(status=" ", treeconflict="A"), "A/D/H": Item(status=" ", treeconflict="A"), "A/D/H/psi": Item(status=" ", treeconflict="A"), "A/D/H/omega": Item(status=" ", treeconflict="A"), "A/D/H/chi": Item(status=" ", treeconflict="A"), "A/D/gamma": Item(status=" ", treeconflict="A"), "A/C": Item(status=" ", treeconflict="A"), "A/B": Item(status=" ", treeconflict="A"), "A/B/E": Item(status=" ", treeconflict="A"), "A/B/E/beta": Item(status=" ", treeconflict="A"), "A/B/E/alpha": Item(status=" ", treeconflict="A"), "A/B/F": Item(status=" ", treeconflict="A"), "A/B/lambda": Item(status=" ", treeconflict="A"), }, ) expected_disk = svntest.main.greek_state.copy() expected_disk.remove( "A/B", "A/B/E", "A/B/E/beta", "A/B/E/alpha", "A/B/F", "A/B/lambda", "A/D", "A/D/G", "A/D/G/rho", "A/D/G/pi", "A/D/G/tau", "A/D/H", "A/D/H/psi", "A/D/H/omega", "A/D/H/chi", "A/D/gamma", "A/mu", "A/C", ) expected_disk.tweak("A", contents="The file A\n") actions.run_and_verify_checkout(url, wc_dir_other, expected_output, expected_disk, [], "--force") # Now see to it that we can recover from the obstructions. # rm wc_dir_other/A os.remove(other_A) # svn up wc_dir_other expected_output = svntest.wc.State(wc_dir_other, {}) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir_other, 1) svntest.main.run_svn(None, "revert", "-R", os.path.join(wc_dir_other, "A")) actions.run_and_verify_update(wc_dir_other, expected_output, expected_disk, expected_status)
def checkout_with_obstructions(sbox): """co with obstructions conflicts without --force""" make_local_tree(sbox, False, False) # svntest.factory.make(sbox, # """# Checkout with unversioned obstructions lying around. # svn co url wc_dir # svn status""") # svntest.factory.make(sbox, # """# Now see to it that we can recover from the obstructions. # rm -rf A iota # svn up""") # exit(0) wc_dir = sbox.wc_dir url = sbox.repo_url # Checkout with unversioned obstructions causes tree conflicts. # svn co url wc_dir expected_output = svntest.wc.State( wc_dir, { "iota": Item(status=" ", treeconflict="C"), "A": Item(status=" ", treeconflict="C"), # And the updates below the tree conflict "A/D": Item(status=" ", treeconflict="A"), "A/D/gamma": Item(status=" ", treeconflict="A"), "A/D/G": Item(status=" ", treeconflict="A"), "A/D/G/rho": Item(status=" ", treeconflict="A"), "A/D/G/pi": Item(status=" ", treeconflict="A"), "A/D/G/tau": Item(status=" ", treeconflict="A"), "A/D/H": Item(status=" ", treeconflict="A"), "A/D/H/chi": Item(status=" ", treeconflict="A"), "A/D/H/omega": Item(status=" ", treeconflict="A"), "A/D/H/psi": Item(status=" ", treeconflict="A"), "A/B": Item(status=" ", treeconflict="A"), "A/B/E": Item(status=" ", treeconflict="A"), "A/B/E/beta": Item(status=" ", treeconflict="A"), "A/B/E/alpha": Item(status=" ", treeconflict="A"), "A/B/F": Item(status=" ", treeconflict="A"), "A/B/lambda": Item(status=" ", treeconflict="A"), "A/C": Item(status=" ", treeconflict="A"), "A/mu": Item(status=" ", treeconflict="A"), }, ) expected_disk = svntest.main.greek_state.copy() expected_disk.remove( "A/B", "A/B/E", "A/B/E/beta", "A/B/E/alpha", "A/B/F", "A/B/lambda", "A/D", "A/D/G", "A/D/G/rho", "A/D/G/pi", "A/D/G/tau", "A/D/H", "A/D/H/psi", "A/D/H/omega", "A/D/H/chi", "A/D/gamma", "A/C", ) actions.run_and_verify_checkout(url, wc_dir, expected_output, expected_disk) # svn status expected_status = actions.get_virginal_state(wc_dir, 1) # A and iota are tree conflicted and obstructed expected_status.tweak("A", "iota", status="D ", wc_rev=1, treeconflict="C") expected_status.tweak( "A/D", "A/D/G", "A/D/G/rho", "A/D/G/pi", "A/D/G/tau", "A/D/H", "A/D/H/chi", "A/D/H/omega", "A/D/H/psi", "A/D/gamma", "A/B", "A/B/E", "A/B/E/beta", "A/B/E/alpha", "A/B/F", "A/B/lambda", "A/C", status="D ", ) # A/mu exists on disk, but is deleted expected_status.tweak("A/mu", status="D ") actions.run_and_verify_unquiet_status(wc_dir, expected_status) # Now see to it that we can recover from the obstructions. # rm -rf A iota svntest.main.safe_rmtree(os.path.join(wc_dir, "A")) os.remove(os.path.join(wc_dir, "iota")) svntest.main.run_svn(None, "revert", "-R", os.path.join(wc_dir, "A"), os.path.join(wc_dir, "iota")) # svn up expected_output = svntest.wc.State(wc_dir, {}) expected_disk = svntest.main.greek_state.copy() expected_status = actions.get_virginal_state(wc_dir, 1) actions.run_and_verify_update(wc_dir, expected_output, expected_disk, expected_status)