提交 0267a645 编写于 作者: F Fatih Acet

Remove CS MergeConflictResolver class.

上级 4d8b0293
#= require lib/vue
class window.MergeConflictResolver extends Vue
constructor: (options = {}) ->
options.el = '#conflicts'
options.data = @getInitialData()
options.name = 'MergeConflictResolver'
options.created = -> @fetchData()
options.computed =
conflictsCount : -> @getConflictsCount()
resolvedCount : -> @getResolvedCount()
allResolved : -> @isAllResolved()
super options
window.v = this
fetchData: ->
$.ajax
url : './conflicts.json'
success: (response) =>
@handleResponse response
handleResponse: (data) ->
@isLoading = no
@conflictsData = @decorateData data
handleViewTypeChange: (newType) ->
return if newType is @diffView
return unless newType in [ 'parallel', 'inline' ]
@diffView = newType
$.cookie 'diff_view', newType
@isParallel = @diffView is 'parallel'
# FIXME: Maybe even better with vue.js
$('.container-fluid').toggleClass 'container-limited'
handleSelected: (sectionId, selection) ->
@resolutionData[sectionId] = selection
#FIXME: Dry!!
for file in @conflictsData.files
for line in file.inlineLines
if line.id is sectionId and (line.conflict or line.isHeader)
if selection is 'head' and line.isHead
line.isSelected = yes
line.isUnselected = no
else if selection is 'origin' and line.isOrigin
line.isSelected = yes
line.isUnselected = no
else
line.isUnselected = yes
line.isSelected = no
for section, lines of file.parallelLines
for line in lines
if line.id is sectionId and (line.lineType is 'conflict' or line.isHeader)
if selection is 'head' and line.isHead
line.isSelected = yes
line.isUnselected = no
else if selection is 'origin' and line.isOrigin
line.isSelected = yes
line.isUnselected = no
else
line.isUnselected = yes
line.isSelected = no
decorateData: (data) ->
headHeaderText = 'HEAD//our changes'
originHeaderText = 'origin//their changes'
data.shortCommitSha = data.commit_sha.slice 0, 7
data.commitMessage = data.commit_message
@updateResolutionsData data
# FIXME: Add comments and separate parallel and inline data decoration
for file in data.files
file.parallelLines = { left: [], right: [] }
file.inlineLines = []
currentLineType = 'old'
for section in file.sections
{ conflict, lines, id } = section
if conflict
# FIXME: Make these lines better
file.parallelLines.left.push { isHeader: yes, id, richText: headHeaderText, section: 'head', isHead: yes, isSelected: no, isUnselected: no }
file.parallelLines.right.push { isHeader: yes, id, richText: originHeaderText, section: 'origin', isOrigin: yes, isSelected: no, isUnselected: no }
file.inlineLines.push { isHeader: yes, id, richText: headHeaderText, type: 'old', section: 'head', isHead: yes, isSelected: no, isUnselected: no }
for line in lines
if line.type in ['new', 'old'] and currentLineType isnt line.type
currentLineType = line.type
# FIXME: Find a better way to add a new line
file.inlineLines.push { lineType: 'emptyLine', richText: '<span> </span>' }
# FIXME: Make these lines better
line.conflict = conflict
line.id = id
line.isHead = line.type is 'new'
line.isOrigin = line.type is 'old'
line.isSelected = no
line.isUnselected = no
line.richText = line.rich_text
file.inlineLines.push line
if conflict
if line.type is 'old'
line = { lineType: 'conflict', lineNumber: line.old_line, richText: line.rich_text, section: 'head', id, isSelected: no, isUnselected: no, isHead: yes }
file.parallelLines.left.push line
else if line.type is 'new'
line = { lineType: 'conflict', lineNumber: line.new_line, richText: line.rich_text, section: 'origin', id, isSelected: no, isUnselected: no, isOrigin: yes }
file.parallelLines.right.push line
else
console.log 'unhandled line type...', line
else
file.parallelLines.left.push { lineType: 'context', lineNumber: line.old_line, richText: line.rich_text }
file.parallelLines.right.push { lineType: 'context', lineNumber: line.new_line, richText: line.rich_text }
if conflict
file.inlineLines.push { isHeader: yes, id, type: 'new', richText: originHeaderText, section: 'origin', isOrigin: yes, isSelected: no, isUnselected: no }
return data
getConflictsCount: -> return Object.keys(@resolutionData).length
getResolvedCount: ->
count = 0
count++ for id, resolution of @resolutionData when resolution
return count
isAllResolved: -> return @resolvedCount is @conflictsCount
updateResolutionsData: (data) ->
for file in data.files
for section in file.sections when section.conflict
@$set "resolutionData['#{section.id}']", no
getInitialData: ->
diffViewType = $.cookie 'diff_view'
return {
isLoading : yes
isParallel : diffViewType is 'parallel'
diffView : diffViewType
conflictsData : {}
resolutionData : {}
}
window.mergeConflictsData = {
"target_branch": "master",
"source_branch": "mc-ui",
"commit_sha": "b5fa56eb3f2cea5e21c68b43c7c22b5b96e0e7b3",
"files": [
{
"old_path": "lib/component.js",
"new_path": "lib/component.js",
"sections": [
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 206,
"new_line": 206,
"text": ""
},
{
"type": null,
"old_line": 207,
"new_line": 207,
"text": "var options = utils.merge.apply(utils, args);"
}
]
},
{
"conflict": true,
"id": "section123",
"lines": [
{
"type": "old",
"old_line": 208,
"new_line": null,
"text": "$(selector).each(function(i, rawNode) {"
},
{
"type": "old",
"old_line": 209,
"new_line": null,
"text": "var componentInfo = registry.findComponentInfo(this)"
},
{
"type": "old",
"old_line": 210,
"new_line": null,
"text": "if (componentInfo && componentInfo.isAttachedTo(rawNode)) {"
},
{
"type": "new",
"old_line": null,
"new_line": 208,
"text": "$(selector).each(function(i, node) {"
},
{
"type": "new",
"old_line": null,
"new_line": 209,
"text": "if (componentInfo && componentInfo.isAttachedTo(node)) {"
}
]
},
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 211,
"new_line": 210,
"text": "return;"
},
{
"type": null,
"old_line": 212,
"new_line": 211,
"text": "}"
},
{
"type": null,
"old_line": null,
"new_line": 212,
"text": ""
},
{
"type": null,
"old_line": 213,
"new_line": 213,
"text": ""
}
]
}
]
},
{
"commit_sha": "b5fa56eb3f2cea5e21c68b43c7c22b5b96e0e7b3",
"old_path": "lib/component.js",
"new_path": "lib/component.js",
"sections": [
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 62,
"new_line": 62,
"text": " (new this).initialize(node, options);"
},
{
"type": null,
"old_line": 63,
"new_line": 63,
"text": " }.bind(this));"
},
{
"type": null,
"old_line": 64,
"new_line": 64,
"text": " }"
},
{
"type": null,
"old_line": 65,
"new_line": 65,
"text": ""
}
]
},
{
"conflict": true,
"id": "section124",
"lines": [
{
"type": "old",
"old_line": 67,
"new_line": null,
"text": " function removeFrom(selector) {"
},
{
"type": "old",
"old_line": 68,
"new_line": null,
"text": " if (!selector) {"
},
{
"type": "old",
"old_line": 69,
"new_line": null,
"text": " throw new Error(\"Component needs to be removeFrom'd a jQuery object, native node or selector string\");"
},
{
"type": "old",
"old_line": 70,
"new_line": null,
"text": " }"
},
{
"type": "old",
"old_line": 71,
"new_line": null,
"text": " "
},
{
"type": "old",
"old_line": 72,
"new_line": null,
"text": " $(selector).each(function(i, rawNode) {"
},
{
"type": "old",
"old_line": 73,
"new_line": null,
"text": " var componentInfo = registry.findComponentInfo(this)"
},
{
"type": "old",
"old_line": 74,
"new_line": null,
"text": " if (componentInfo && componentInfo.isAttachedTo(rawNode)) {"
},
{
"type": "old",
"old_line": 75,
"new_line": null,
"text": " Object.keys(componentInfo.instances).forEach(function(index) {"
},
{
"type": "old",
"old_line": 76,
"new_line": null,
"text": " var instance = componentInfo.instances[index].instance;"
},
{
"type": "old",
"old_line": 77,
"new_line": null,
"text": " if (instance.node === rawNode) {"
},
{
"type": "old",
"old_line": 78,
"new_line": null,
"text": " instance.teardown();"
},
{
"type": "old",
"old_line": 79,
"new_line": null,
"text": " }"
},
{
"type": "old",
"old_line": 80,
"new_line": null,
"text": " });"
},
{
"type": "old",
"old_line": 81,
"new_line": null,
"text": " }"
},
{
"type": "old",
"old_line": 82,
"new_line": null,
"text": " }.bind(this));"
},
{
"type": "old",
"old_line": 83,
"new_line": null,
"text": " }"
},
{
"type": "new",
"old_line": null,
"new_line": 67,
"text": " function prettyPrintMixins() {"
},
{
"type": "new",
"old_line": null,
"new_line": 68,
"text": " //could be called from constructor or constructor.prototype"
},
{
"type": "new",
"old_line": null,
"new_line": 69,
"text": " var mixedIn = this.mixedIn || this.prototype.mixedIn || [];"
},
{
"type": "new",
"old_line": null,
"new_line": 70,
"text": " return mixedIn.map(function(mixin) {"
},
{
"type": "new",
"old_line": null,
"new_line": 71,
"text": " if (mixin.name == null) {"
},
{
"type": "new",
"old_line": null,
"new_line": 72,
"text": " // function name property not supported by this browser, use regex"
},
{
"type": "new",
"old_line": null,
"new_line": 73,
"text": " var m = mixin.toString().match(functionNameRegEx);"
},
{
"type": "new",
"old_line": null,
"new_line": 74,
"text": " return (m && m[1]) ? m[1] : '';"
},
{
"type": "new",
"old_line": null,
"new_line": 75,
"text": " } else {"
},
{
"type": "new",
"old_line": null,
"new_line": 76,
"text": " return (mixin.name != 'withBase') ? mixin.name : '';"
},
{
"type": "new",
"old_line": null,
"new_line": 77,
"text": " }"
},
{
"type": "new",
"old_line": null,
"new_line": 78,
"text": " }).filter(Boolean).join(', ');"
},
{
"type": "new",
"old_line": null,
"new_line": 79,
"text": " };"
},
{
"type": "new",
"old_line": null,
"new_line": 80,
"text": ""
}
]
},
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 84,
"new_line": 81,
"text": ""
},
{
"type": null,
"old_line": 85,
"new_line": 82,
"text": " // define the constructor for a custom component type"
},
{
"type": null,
"old_line": 86,
"new_line": 83,
"text": " // takes an unlimited number of mixin functions as arguments"
},
{
"type": null,
"old_line": 87,
"new_line": 84,
"text": " // typical api call with 3 mixins: define(timeline, withTweetCapability, withScrollCapability);"
}
]
}
]
},
{
"commit_sha": "c68b43c7c22b5b96e0e7b3b5fa56eb3f2cea5e21",
"old_path": "lib/registry.js",
"new_path": "lib/registry.js",
"sections": [
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 159,
"new_line": 159,
"text": ""
},
{
"type": null,
"old_line": 160,
"new_line": 160,
"text": "var thisInstanceInfo = this.allInstances[k]"
}
]
},
{
"conflict": true,
"id": "section125",
"lines": [
{
"type": "old",
"old_line": 161,
"new_line": null,
"text": "if(thisInstanceInfo.instance.node == node){"
},
{
"type": "new",
"old_line": null,
"new_line": 161,
"text": "if (thisInstanceInfo.instance.node === node) {"
}
]
},
{
"conflict": false,
"lines": [
{
"type": null,
"old_line": 162,
"new_line": 162,
"text": "result.push(thisInstanceInfo);"
}
]
}
]
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册