Anonymous avatar Anonymous committed cfa7952

Removed yaml dependency.

Comments (0)

Files changed (1)

distributed_version_control_system_test.py

 
 Ideas: Include bazaar, too. 
 
-TODO: for multiple file change tests: backup_repo_git(), restore_repo_git(), backup_repo_hg(), restore_repo_hg()
+TODO: for multiple file change tests: backup_repo_git(), undo_git(), backup_repo_hg(), undo_hg()
 
 This was inspired by the tests done at 
 http://sayspy.blogspot.com/2006/11/bazaar-vs-mercurial-unscientific.html
     # But first we need a backup. 
     backup_repo_git()
     backup_repo_hg()
-    results = armored_tests([commit_git, commit_hg], before=[restore_repo_git, restore_repo_hg], number_of_tests=number_of_tests)
+    results = armored_tests([commit_git, commit_hg], before=[undo_git, undo_hg], number_of_tests=number_of_tests)
     # Print the result
     print "Commit results after append: [git, hg]", mean(results)
     # And return it
     # But first we need a backup. 
     backup_repo_git()
     backup_repo_hg()
-    results = armored_tests([commit_git, commit_hg], before=[restore_repo_git, restore_repo_hg], number_of_tests=number_of_tests)
+    results = armored_tests([commit_git, commit_hg], before=[undo_git, undo_hg], number_of_tests=number_of_tests)
     # Print our result
     print "Commit results after append of same big data: [git, hg]", mean(results)
     # And return it
     # But first we need a backup. 
     backup_repo_git()
     backup_repo_hg()
-    results = armored_tests([commit_git, commit_hg], before=[restore_repo_git, restore_repo_hg], number_of_tests=number_of_tests)
+    results = armored_tests([commit_git, commit_hg], before=[undo_git, undo_hg], number_of_tests=number_of_tests)
     # Print our result
     print "Commit results after append of same big data: [git, hg]", mean(results)
     # And return it
     # copy the repo to the backup dir. 
     shellcall("cp -Rf .git .git.bak")
 
-def restore_repo_git(*args):
+def undo_git(*args):
     """Delete and then restore the git dir from backup. """
-    # Delete the repo
-    shellcall("rm -Rf .git")
-    # And copy it from the backup
-    shellcall("cp -Rf .git.bak .git")
+    # Reset the repo
+    shellcall("git reset")
 
 def init_hg(*args): 
     """Initialize a Mercurial repository."""
     """Commit to the Mercurial repository."""
     # Init the repo
     init_hg()
-    # Add all files
-    shellcall("hg add *")
     # And commit
     commit_hg()
 
 def commit_hg(*args): 
     """Commit to the Mercurial repository."""
+    # Add all untracked files
+    shellcall("hg add *")
     # And commit
     shellcall("hg commit -m 'test'")
     
     # copy the repo to the backup dir. 
     shellcall("cp -Rf .hg .hg.bak")
 
-def restore_repo_hg(*args):
+def undo_hg(*args):
     """Delete and then restore the hg dir from backup. """
-    # First delete the repo
-    shellcall("rm -Rf .hg")
-    # Then copy it from the backup
-    shellcall("cp -Rf .hg.bak .hg")
-
+    # Rollback the repo
+    shellcall("hg rollback")
+    
 
 #### Self-Test ####
 if __name__ == "__main__": 
-    # Get yaml to output the results nicely
-    from yaml import dump
-    # Get the command line args to get the number of files to test
     from sys import argv
     # If we got 2 additional command line arguments, the first is the number of files, the second the number of tests. 
     if len(argv) == 3: 
-        output = dump(test_dvcs(number_of_files=int(argv[1]), number_of_tests=int(argv[2])))
+        output = test_dvcs(number_of_files=int(argv[1]), number_of_tests=int(argv[2]))
     # If we got 1 arg, we just pass it as the number of files. 
     elif len(argv) == 2: 
-        output = dump(test_dvcs(number_of_files=int(argv[1])))
+        output = test_dvcs(number_of_files=int(argv[1]))
     # If we got no args, we just start it with default values. 
     elif len(argv) == 1: 
-        output = dump(test_dvcs())
+        output = test_dvcs()
     print "\n======\nStructure: [git, hg], time in seconds, mean value. \n"
-    print output
+    for i, j in output.items(): 
+        print i, j
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.