0
#----------------------------------------------------------------------------------------------------------------------------
0
-def fileNotPresentError(
repositoryPath, revision, chatty=True):
0
+def fileNotPresentError(
repositoryPath, revision, chatty=True ):
0
- print "\tFile \"%s\" does not exist in repository at revision \"%s\"." % (
repositoryPath, revision)
0
+ print "\tFile \"%s\" does not exist in repository at revision \"%s\"." % (
repositoryPath, revision )
0
#----------------------------------------------------------------------------------------------------------------------------
0
# createTempFileForRevision
0
#----------------------------------------------------------------------------------------------------------------------------
0
+#----------------------------------------------------------------------------------------------------------------------------
0
+#----------------------------------------------------------------------------------------------------------------------------
0
+def signalDiffProcessed( condition, diffsLeft ):
0
+ diffsLeft[0] = diffsLeft[0] - 1
0
#----------------------------------------------------------------------------------------------------------------------------
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def performDiff(compareFile, revision, condition, diffsLeft, chatty=True):
0
- revision, _, revision2 = revision.partition("..")
0
+def performDiff( compareFile, revision, condition, diffsLeft, chatty=True ):
0
+ revision, _, revision2 = revision.partition( ".." )
0
realpath = os.path.abspath( compareFile )
0
if os.path.isdir( realpath ):
0
print "\t\"" + relativePath + "\" is a directory. " + gToolName + " only compares files."
0
+ signalDiffProcessed( condition, diffsLeft )
0
# Figure out what the relative path of the file is from the .git folder.
0
- while (
found == False) and (head != "/"):
0
+ while (
found == False ) and ( head != "/" ):
0
gitPath = os.path.join( head, ".git" )
0
found = os.path.exists( gitPath )
0
relativePath = os.path.join( tail, relativePath )
0
# Make sure we are actually in a git repository.
0
- if (
found == False) and (head == "/"):
0
+ if (
found == False ) and ( head == "/" ):
0
print "\tThat file is not in a git repository."
0
+ signalDiffProcessed( condition, diffsLeft )
0
file1 = createTempFileForRevision( revision, relativePath, chatty )
0
file2 = createTempFileForRevision( revision2, relativePath, chatty )
0
- if os.path.exists(
file2) == False:
0
+ if os.path.exists(
file2 ) == False:
0
fileNotPresentError( relativePath, "HEAD", chatty )
0
- if (file1 == None) or (file2 == None):
0
+ if ( file1 == None ) or ( file2 == None ):
0
+ signalDiffProcessed( condition, diffsLeft )
0
same = filecmp.cmp( file2, file1 )
0
print "\tThe file \"" + fileName + "\" has no differences."
0
# Escape the files with quotes to allow for files with spaces.
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
+ signalDiffProcessed( condition, diffsLeft )
0
#----------------------------------------------------------------------------------------------------------------------------
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def numConflicts(
conflictFile):
0
+def numConflicts(
conflictFile ):
0
- f = open(
conflictFile, "r")
0
+ f = open(
conflictFile, "r" )
0
- if line.startswith(
"<<<<<<<") and (foundStart == False) and (foundMiddle == False):
0
+ if line.startswith(
"<<<<<<<" ) and ( foundStart == False ) and ( foundMiddle == False ):
0
- if line.startswith(
"=======") and foundStart and (foundMiddle == False):
0
+ if line.startswith(
"=======" ) and foundStart and ( foundMiddle == False ):
0
- if line.startswith(
">>>>>>>") and foundStart and foundMiddle:
0
+ if line.startswith(
">>>>>>>" ) and foundStart and foundMiddle:
0
conflicts = conflicts + 1
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def uniqueName(path, uniqueLabel):
0
- base, extension = os.path.splitext(path)
0
+def uniqueName( path, uniqueLabel ):
0
+ base, extension = os.path.splitext( path )
0
- if os.path.exists(base + uniqueLabel + uniqueDigit + extension):
0
- uniqueDigit = str(digit)
0
+ if os.path.exists( base + uniqueLabel + uniqueDigit + extension ):
0
+ uniqueDigit = str( digit )
0
newPath = base + uniqueLabel + uniqueDigit + extension
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def createConflictFiles(minePath, theirPath, conflictFile):
0
- orig = open(conflictFile, "r")
0
- mine = open(minePath, "w")
0
- theirs = open(theirPath, "w")
0
+def createConflictFiles( minePath, theirPath, conflictFile ):
0
+ orig = open( conflictFile, "r" )
0
+ mine = open( minePath, "w" )
0
+ theirs = open( theirPath, "w" )
0
- if line.startswith(
"<<<<<<<") and placeInTheirs and placeInMine:
0
+ if line.startswith(
"<<<<<<<" ) and placeInTheirs and placeInMine:
0
- elif line.startswith(
"=======") and placeInTheirs and (placeInMine == False):
0
+ elif line.startswith(
"=======" ) and placeInTheirs and ( placeInMine == False ):
0
- elif line.startswith(
">>>>>>>") and (placeInTheirs == False) and placeInMine:
0
+ elif line.startswith(
">>>>>>>" ) and ( placeInTheirs == False ) and placeInMine:
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def diffConflict(conflictFile, chatty=True):
0
- conflicts = numConflicts(conflictFile)
0
- if (conflicts == 0) and chatty:
0
+def diffConflict( conflictFile, chatty=True ):
0
+ conflicts = numConflicts( conflictFile )
0
+ if ( conflicts == 0 ) and chatty:
0
basePath, fileName = os.path.split( conflictFile )
0
print "\tThe file \"%s\" does not contain any conflicts. SKIPPING." % fileName
0
- newConflictPath = uniqueName(conflictFile, gConflictMarker)
0
- os.rename(conflictFile, newConflictPath)
0
+ newConflictPath = uniqueName( conflictFile, gConflictMarker )
0
+ os.rename( conflictFile, newConflictPath )
0
- theirPath = uniqueName(
conflictFile, gTheirsMarker)
0
+ theirPath = uniqueName(
conflictFile, gTheirsMarker )
0
- createConflictFiles(
conflictFile, theirPath, newConflictPath)
0
+ createConflictFiles(
conflictFile, theirPath, newConflictPath )
0
command = 'bbdiff "%s" "%s"' % ( conflictFile, theirPath )
0
status, output = commands.getstatusoutput( command )
0
# cleanConflictRelatedFiles
0
#----------------------------------------------------------------------------------------------------------------------------
0
-def cleanConflictRelatedFiles(
conflictFile, chatty=True):
0
+def cleanConflictRelatedFiles(
conflictFile, chatty=True ):
0
filePath, extension = os.path.splitext( conflictFile )
0
# Remove .CONFLICT files.
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
+ (
options, args ) = parser.parse_args( argv[1:] )
0
- cleanConflictRelatedFiles(gitFile, options.chatty)
0
+ cleanConflictRelatedFiles( gitFile, options.chatty )
0
# These options are mutually exclusive.
0
print "Diffing Conflict \"%s\"." % gitFile
0
- diffConflict(
gitFile, options.chatty)
0
+ diffConflict(
gitFile, options.chatty )
0
thread.start_new_thread( performDiff, (gitFile, rev, condition, diffsLeft, options.chatty) )
0
while diffsLeft[0] > 0:
0
+ except KeyboardInterrupt, e:
0
+ print( "\nProcess terminated.")
Comments
No one has commented yet.