0
import sys, commands, os, tempfile, filecmp
0
+import thread, threading
0
from optparse import OptionParser
0
gToolName = "git-bbdiff"
0
-gdiffVersion = gToolName + " version 1.2"
0
+gdiffVersion = gToolName + " version 1.3"
0
gConflictMarker = ".CONFLICT"
0
gTheirsMarker = ".THEIRS"
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def performDiff(compareFile, revision, chatty=True):
0
- # Check that we have enough arguments.
0
+def performDiff(compareFile, revision, condition, diffsLeft, chatty=True):
0
revision, _, revision2 = revision.partition("..")
0
realpath = os.path.abspath( compareFile )
0
print "\tThe file \"" + fileName + "\" has no differences."
0
# Escape the files with quotes to allow for files with spaces.
0
- command = 'bbdiff "%s" "%s"' % ( file2, file1 )
0
+ # Escape the files with quotes to allow for files with spaces.
0
+ command = 'bbdiff "%s" "%s" --wait' % ( file2, file1 )
0
status, output = commands.getstatusoutput( command )
0
+ diffsLeft[0] = diffsLeft[0] - 1
0
+ while diffsLeft[0] > 0:
0
#----------------------------------------------------------------------------------------------------------------------------
0
-#----------------------------------------------------------------------------------------------------------------------------
0
-def cleanTmpDirectory(chatty=True):
0
- tempContents = os.listdir( gTempDir )
0
- for tmpFile in tempContents:
0
- if tmpFile.startswith( gToolName + "-" ):
0
- filePath = gTempDir + tmpFile
0
- print "\tRemoving temp file:\"%s\"" % filePath
0
-#----------------------------------------------------------------------------------------------------------------------------
0
#----------------------------------------------------------------------------------------------------------------------------
0
# Set up options for the command line that we support.
0
description="A utility to compare files in a git repository using bbedit."
0
- usage = "usage: %prog [--version] | [-h | --help] | [-q | --quiet] [--clean] [[-c | --conflict] | [-r | --revision <revision(s)>]] file1 [file2 ...]"
0
+ usage = "usage: %prog [--version] | [-h | --help] | [-q | --quiet] [--clean file1 [file2 ...]] [[-c | --conflict] | [-r | --revision <revision(s)>]] file1 [file2 ...]"
0
parser = OptionParser(version=gdiffVersion, description=description, usage=usage)
0
parser.add_option("-r", "--revision", dest="revision", help="Pass a revision or a revision range using the git syntax (ie: 98d4cf..bfced5) for " + gToolName + " to compare. This option is mutually exclusive to the '-c' option.")
0
- parser.add_option("--clean", action="store_true", dest="cleanUp", default=False, help="Delete all of the temp files that " + gToolName + " has created. If any files are passed as arguments, their --conflict related files (\"" + gConflictMarker + "\", \"" + gTheirsMarker + "\") will be deleted.")
0
+ parser.add_option("--clean", action="store_true", dest="cleanUp", default=False, help="Conflict (--conflict) related files (\"" + gConflictMarker + "\", \"" + gTheirsMarker + "\") will be deleted for any files that are passed as arguments. Requires at least one file path as an argument.")
0
parser.add_option("-q", "--quiet", action="store_false", dest="chatty", default=True, help="Reduce the chatter of " + gToolName + ".")
0
parser.add_option("-c", "--conflict", action="store_true", dest="conflict", default=False, help="The files being diffed have conflict markers that need to be resolved. This option is mutually exclusive to the '-r' option.")
0
(options, args) = parser.parse_args(argv[1:])
0
- cleanTmpDirectory(options.chatty)
0
- cleanConflictRelatedFiles(gitFile, options.chatty)
0
+ cleanConflictRelatedFiles(gitFile, options.chatty)
0
+ diffsLeft = [len( args )];
0
+ # Create a condition lock to ensure that we wait until all the diffs are done since we use the --wait option
0
+ condition = threading.Condition()
0
print "Comparing \"%s\"." % gitFile
0
- performDiff(gitFile, rev, options.chatty)
0
+ thread.start_new_thread( performDiff, (gitFile, rev, condition, diffsLeft, options.chatty) )
0
+ while diffsLeft[0] > 0:
0
if __name__ == "__main__":
Comments
No one has commented yet.