def modify(modaction, paths): F1 = paths["F1"] # existing file to copy from F = paths["F"] # target file F2 = paths["F2"] # non-existing file to copy/move to D1 = paths["D1"] # existing dir to copy from D = paths["D"] # target dir D2 = paths["D2"] # non-existing dir to copy/move to # print " Mod: '" + modaction + "' '" + P + "'" if modaction == "ft": # file text-mod assert os.path.exists(F) main.file_append(F, "This is a text-mod of file F.\n") elif modaction == "fP": # file Prop-mod assert os.path.exists(F) main.run_svn(None, "pset", "fprop1", "A prop set on file F.", F) elif modaction == "dP": # dir Prop-mod assert os.path.exists(D) main.run_svn(None, "pset", "dprop1", "A prop set on dir D.", D) elif modaction == "fD": # file Delete assert os.path.exists(F) main.run_svn(None, "del", F) elif modaction == "dD": # dir Delete assert os.path.exists(D) main.run_svn(None, "del", D) elif modaction == "fA": # file Add (new) assert os.path.exists(F) main.run_svn(None, "add", F) main.run_svn(None, "pset", "fprop2", "A prop of added file F.", F) elif modaction == "dA": # dir Add (new) assert os.path.exists(D) main.run_svn(None, "add", D) main.run_svn(None, "pset", "dprop2", "A prop of added dir D.", D) elif modaction == "fC": # file Copy (from F1) main.run_svn(None, "copy", F1, F) elif modaction == "dC": # dir Copy (from D1) main.run_svn(None, "copy", D1, D) elif modaction == "fM": # file Move (to F2) main.run_svn(None, "rename", F, F2) elif modaction == "dM": # dir Move (to D2) main.run_svn(None, "rename", D, D2) elif modaction == "fa": # file add (new) on disk assert not os.path.exists(F) main.file_write(F, "This is file F.\n") elif modaction == "da": # dir add (new) on disk assert not os.path.exists(D) os.mkdir(D) elif modaction == "fd": # file delete from disk assert os.path.exists(F) os.remove(F) elif modaction == "dd": # dir delete from disk assert os.path.exists(D) os.remove(D) else: raise Exception("unknown modaction: '" + modaction + "'")
def modify(modaction, paths): F1 = paths['F1'] # existing file to copy from F = paths['F'] # target file F2 = paths['F2'] # non-existing file to copy/move to D1 = paths['D1'] # existing dir to copy from D = paths['D'] # target dir D2 = paths['D2'] # non-existing dir to copy/move to # print " Mod: '" + modaction + "' '" + P + "'" if modaction == 'ft': # file text-mod assert os.path.exists(F) main.file_append(F, "This is a text-mod of file F.\n") elif modaction == 'fP': # file Prop-mod assert os.path.exists(F) main.run_svn(None, 'pset', 'fprop1', 'A prop set on file F.', F) elif modaction == 'dP': # dir Prop-mod assert os.path.exists(D) main.run_svn(None, 'pset', 'dprop1', 'A prop set on dir D.', D) elif modaction == 'fD': # file Delete assert os.path.exists(F) main.run_svn(None, 'del', F) elif modaction == 'dD': # dir Delete assert os.path.exists(D) main.run_svn(None, 'del', D) elif modaction == 'fA': # file Add (new) assert os.path.exists(F) main.run_svn(None, 'add', F) main.run_svn(None, 'pset', 'fprop2', 'A prop of added file F.', F) elif modaction == 'dA': # dir Add (new) assert os.path.exists(D) main.run_svn(None, 'add', D) main.run_svn(None, 'pset', 'dprop2', 'A prop of added dir D.', D) elif modaction == 'fC': # file Copy (from F1) main.run_svn(None, 'copy', F1, F) elif modaction == 'dC': # dir Copy (from D1) main.run_svn(None, 'copy', D1, D) elif modaction == 'fM': # file Move (to F2) main.run_svn(None, 'rename', F, F2) elif modaction == 'dM': # dir Move (to D2) main.run_svn(None, 'rename', D, D2) elif modaction == 'fa': # file add (new) on disk assert not os.path.exists(F) main.file_write(F, "This is file F.\n") elif modaction == 'da': # dir add (new) on disk assert not os.path.exists(D) os.mkdir(D) elif modaction == 'fd': # file delete from disk assert os.path.exists(F) os.remove(F) elif modaction == 'dd': # dir delete from disk assert os.path.exists(D) os.remove(D) else: raise Exception("unknown modaction: '" + modaction + "'")
def dump(self, output_dir): """Dump the repository into the directory OUTPUT_DIR""" ldir = local_path(output_dir) os.mkdir(ldir) """Run a BDB dump on the repository""" if self.db_dump_name != 'none': dump_bdb(self.db_dump_name, self.repo_absdir, ldir) """Run 'svnadmin dump' on the repository.""" exit_code, stdout, stderr = \ actions.run_and_verify_svnadmin(None, None, 'dump', self.repo_absdir) ldumpfile = local_path(output_dir + "/svnadmin.dump") main.file_write(ldumpfile, ''.join(stderr)) main.file_append(ldumpfile, ''.join(stdout))
def dump(self, output_dir): """Dump the repository into the directory OUTPUT_DIR""" ldir = local_path(output_dir) os.mkdir(ldir) """Run a BDB dump on the repository""" if self.db_dump_name != 'none': dump_bdb(self.db_dump_name, self.repo_absdir, ldir) """Run 'svnadmin dump' on the repository.""" exit_code, stdout, stderr = \ actions.run_and_verify_svnadmin(None, None, None, 'dump', self.repo_absdir) ldumpfile = local_path(output_dir + "/svnadmin.dump") main.file_write(ldumpfile, ''.join(stderr)) main.file_append(ldumpfile, ''.join(stdout))
def make_deep_trees(base): """Helper function for deep trees conflicts. Create a set of trees, each in its own "container" dir. Any conflicts can be tested separately in each container. """ j = os.path.join # Create the container dirs. F = j(base, 'F') D = j(base, 'D') DF = j(base, 'DF') DD = j(base, 'DD') DDF = j(base, 'DDF') DDD = j(base, 'DDD') os.makedirs(F) os.makedirs(j(D, 'D1')) os.makedirs(j(DF, 'D1')) os.makedirs(j(DD, 'D1', 'D2')) os.makedirs(j(DDF, 'D1', 'D2')) os.makedirs(j(DDD, 'D1', 'D2', 'D3')) # Create their files. alpha = j(F, 'alpha') beta = j(DF, 'D1', 'beta') gamma = j(DDF, 'D1', 'D2', 'gamma') main.file_append(alpha, "This is the file 'alpha'.\n") main.file_append(beta, "This is the file 'beta'.\n") main.file_append(gamma, "This is the file 'gamma'.\n")
def deep_trees_leaf_edit(base): """Helper function for deep trees test cases. Append text to files, create new files in empty directories, and change leaf node properties.""" j = os.path.join F = j(base, 'F', 'alpha') DF = j(base, 'DF', 'D1', 'beta') DDF = j(base, 'DDF', 'D1', 'D2', 'gamma') main.file_append(F, "More text for file alpha.\n") main.file_append(DF, "More text for file beta.\n") main.file_append(DDF, "More text for file gamma.\n") run_and_verify_svn(verify.AnyOutput, [], 'propset', 'prop1', '1', F, DF, DDF) D = j(base, 'D', 'D1') DD = j(base, 'DD', 'D1', 'D2') DDD = j(base, 'DDD', 'D1', 'D2', 'D3') run_and_verify_svn(verify.AnyOutput, [], 'propset', 'prop1', '1', D, DD, DDD) D = j(base, 'D', 'D1', 'delta') DD = j(base, 'DD', 'D1', 'D2', 'epsilon') DDD = j(base, 'DDD', 'D1', 'D2', 'D3', 'zeta') main.file_append(D, "This is the file 'delta'.\n") main.file_append(DD, "This is the file 'epsilon'.\n") main.file_append(DDD, "This is the file 'zeta'.\n") run_and_verify_svn(verify.AnyOutput, [], 'add', D, DD, DDD)
def deep_trees_leaf_edit(base): """Helper function for deep trees test cases. Append text to files, create new files in empty directories, and change leaf node properties.""" j = os.path.join F = j(base, 'F', 'alpha') DF = j(base, 'DF', 'D1', 'beta') DDF = j(base, 'DDF', 'D1', 'D2', 'gamma') main.file_append(F, "More text for file alpha.\n") main.file_append(DF, "More text for file beta.\n") main.file_append(DDF, "More text for file gamma.\n") run_and_verify_svn(None, verify.AnyOutput, [], 'propset', 'prop1', '1', F, DF, DDF) D = j(base, 'D', 'D1') DD = j(base, 'DD', 'D1', 'D2') DDD = j(base, 'DDD', 'D1', 'D2', 'D3') run_and_verify_svn(None, verify.AnyOutput, [], 'propset', 'prop1', '1', D, DD, DDD) D = j(base, 'D', 'D1', 'delta') DD = j(base, 'DD', 'D1', 'D2', 'epsilon') DDD = j(base, 'DDD', 'D1', 'D2', 'D3', 'zeta') main.file_append(D, "This is the file 'delta'.\n") main.file_append(DD, "This is the file 'epsilon'.\n") main.file_append(DDD, "This is the file 'zeta'.\n") run_and_verify_svn(None, verify.AnyOutput, [], 'add', D, DD, DDD)
def svn_modfile(path): "Make text and property mods to a WC file." path = local_path(path) main.file_append(path, "An extra line.\n") actions.run_and_verify_svn(None, [], 'propset', 'newprop', 'v', path)
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_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)