From aeaf0902e1689a77ec42a33efaec00dfacb33184 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 22 Oct 2013 13:52:53 +0200 Subject: [PATCH] Migration scripts in somewhat better state now, main missing part is that statuses are not imported correctly, though there's a bunch of details to figure out. --- migration/adapt.php | 229 ++---------- migration/import_projects.php | 3 +- migration/import_task.php | 370 ++++++++++++++------ migration/phab.php | 66 ++-- src/infrastructure/storage/lisk/LiskDAO.php | 41 ++- 5 files changed, 364 insertions(+), 345 deletions(-) diff --git a/migration/adapt.php b/migration/adapt.php index 26eb0b595c..a4dee979d6 100644 --- a/migration/adapt.php +++ b/migration/adapt.php @@ -596,7 +596,7 @@ $migrate_dedup_users["omegafold"] = "None"; function dedup_user($name) { global $migrate_dedup_users; - if(array_key_exists($name, $migrate_dedup_users)) + if($name != null && array_key_exists($name, $migrate_dedup_users)) return $migrate_dedup_users[$name]; return $name; @@ -619,199 +619,40 @@ $spammails = array( "momalls.com", "bestguccibags.com"); -$active_projects = array(); -$active_projects["2005 Google Summer of Code Projects"] = array(false, null); -$active_projects["Blended Midi"] = array(false, null); -$active_projects["Blender 2.x BF release"] = array(true, "BF Blender"); -$active_projects["Blender Extensions"] = array(true, "Addons"); -$active_projects["Blender Functionality"] = array(false, null); -$active_projects["Blender UI Translations"] = array(true, "Translations"); -$active_projects["Blender to CrystalSpace converter"] = array(false, null); -$active_projects["BlenderCAD"] = array(false, null); -$active_projects["Documentación de Blender en Español"] = array(false, null); -$active_projects["Documentation board"] = array(false, null); -$active_projects["DrQueue"] = array(false, null); -$active_projects["GHOST"] = array(false, null); -$active_projects["MakeHuman"] = array(false, null); -$active_projects["Mechanical Blender"] = array(false, null); -$active_projects["Network Render"] = array(false, null); -$active_projects["Network SOAP renderer"] = array(false, null); -$active_projects["NeverBlender - Bioware MDL support"] = array(false, null); -$active_projects["OSG-Exporter"] = array(false, null); -$active_projects["Piovra - the italian renderfarm"] = array(false, null); -$active_projects["Procedural Modelling Techniques: Lsystem"] = array(false, null); -$active_projects["Renderman GUI"] = array(false, null); -$active_projects["Scol tools"] = array(false, null); -$active_projects["Skining Tools"] = array(false, null); -$active_projects["Spe Python IDE for Blender"] = array(false, null); -$active_projects["Torque Exporter Plugin"] = array(false, null); -$active_projects["Tuhopuu Blender"] = array(false, null); -$active_projects["TzuRay Blender"] = array(false, null); -$active_projects["VRML 97 import/export Python script"] = array(false, null); -$active_projects["Warblender - Blizzard MDX support"] = array(false, null); -$active_projects["YafRay"] = array(false, null); -$active_projects["Yo Frankie"] = array(false, null); -$active_projects["beast"] = array(false, null); -$active_projects["blend-doc"] = array(false, null); -$active_projects["projects.blender.org"] = array(false, null); -$active_projects["verse"] = array(false, null); - -$active_trackers = array(); -$active_trackers["Basic Utilities"] = array(true, null, null); -$active_trackers["Blender 2.4x Bug Tracker"] = array(true, null, "Bug"); -$active_trackers["Blender 2.6 Bug Tracker"] = array(true, null, "Bug"); -$active_trackers["Bug Reports"] = array(true, null, "Bug"); -$active_trackers["Bug reports"] = array(true, null, "Bug"); -$active_trackers["Bugs"] = array(true, null, "Bugs"); -$active_trackers["Drawing Tools"] = array(true, null, null); -$active_trackers["Electrical"] = array(true, null, null); -$active_trackers["Engineering"] = array(true, null, null); -$active_trackers["Feature Requests"] = array(true, null, "Feature Request"); -$active_trackers["Feature requests"] = array(true, null, "Feature Request"); -$active_trackers["Game Engine"] = array(true, null, "Bugs"); -$active_trackers["OpenGL errors"] = array(true, null, "OpenGL Error"); -$active_trackers["Patches"] = array(true, null, "Patch"); -$active_trackers["Plugins Contrib"] = array(true, "Addons", null); -$active_trackers["Plugins Upload"] = array(true, "Addons", null); -$active_trackers["Py Scripts Contrib"] = array(true, "Addons", null); -$active_trackers["Py Scripts Extern"] = array(true, "Addons", null); -$active_trackers["Py Scripts Release"] = array(true, "Addons", null); -$active_trackers["Py Scripts Upload"] = array(true, "Addons", null); -$active_trackers["Support Requests"] = array(true, null, null); -$active_trackers["Todo"] = array(true, null, "To Do"); -$active_trackers["User Interface"] = array(true, null, null); -$active_trackers["dev-tools"] = array(true, null, null); - -$active_categories = array(); -$active_categories["1 - Blender Integration"] = null; -$active_categories["2 - YafRay :: Core"] = null; -$active_categories["2.5 - Game Engine"] = null; -$active_categories["2.5 - I/O"] = null; -$active_categories["2.5 - addons"] = null; -$active_categories["3D View"] = null; -$active_categories["4 - YafRay :: Shaders"] = null; -$active_categories["5 - Other / I don't know"] = null; -$active_categories["Account"] = null; -$active_categories["Add Curve"] = null; -$active_categories["Add Mesh"] = null; -$active_categories["Animation system"] = null; -$active_categories["Animation"] = null; -$active_categories["Audio"] = null; -$active_categories["Bug submission"] = null; -$active_categories["Bug tracker"] = null; -$active_categories["Compositing"] = null; -$active_categories["Compositor"] = null; -$active_categories["Console-GUI"] = null; -$active_categories["Content"] = null; -$active_categories["Conversion"] = null; -$active_categories["Curve"] = null; -$active_categories["Depsgraph"] = null; -$active_categories["Development"] = null; -$active_categories["Documentation"] = null; -$active_categories["FFMPEG"] = null; -$active_categories["Forum"] = null; -$active_categories["FreeBSD related"] = null; -$active_categories["Freestyle"] = null; -$active_categories["Functionality"] = null; -$active_categories["Game Engine"] = null; -$active_categories["Game engine"] = null; -$active_categories["General (all versions)"] = null; -$active_categories["General"] = null; -$active_categories["HTML Version specific"] = null; -$active_categories["Help"] = null; -$active_categories["IRIX related"] = null; -$active_categories["Image & Movie I/O"] = null; -$active_categories["Image"] = null; -$active_categories["Import Export"] = null; -$active_categories["Import/Export"] = null; -$active_categories["Install Problem (example)"] = null; -$active_categories["Install Problem"] = null; -$active_categories["Interface "] = "User Interface"; -$active_categories["Interface (example)"] = null; -$active_categories["Interface Improvements (example)"] = null; -$active_categories["Interface"] = null; -$active_categories["International"] = "Translations"; -$active_categories["Layout"] = null; -$active_categories["Lighting"] = null; -$active_categories["Lighting,Render"] = null; -$active_categories["Link"] = null; -$active_categories["Linux related"] = null; -$active_categories["Logic"] = null; -$active_categories["Masking"] = null; -$active_categories["Materials"] = null; -$active_categories["Mesh Export"] = null; -$active_categories["Mesh Modeling"] = null; -$active_categories["Mesh topology-UV"] = null; -$active_categories["Mesh"] = null; -$active_categories["Misc"] = null; -$active_categories["Missing"] = null; -$active_categories["Modifiers"] = null; -$active_categories["Morphing"] = null; -$active_categories["Motion tracking"] = null; -$active_categories["Node Editor"] = null; -$active_categories["None"] = null; -$active_categories["OS related: FreeBSD"] = null; -$active_categories["OS related: Linux"] = null; -$active_categories["OS related: OSX"] = null; -$active_categories["OS related: Windows"] = null; -$active_categories["OSX related"] = null; -$active_categories["Object"] = null; -$active_categories["Opengl / Gfx"] = null; -$active_categories["PDF Version specific"] = null; -$active_categories["Physics"] = null; -$active_categories["Presets"] = null; -$active_categories["PyConstraint"] = null; -$active_categories["PyNode"] = null; -$active_categories["Python API"] = null; -$active_categories["Python"] = null; -$active_categories["Render (internal)"] = null; -$active_categories["Render"] = null; -$active_categories["Rendering (intern)"] = null; -$active_categories["Rendering"] = null; -$active_categories["Rendering: Cycles"] = "Cycles"; -$active_categories["Reporting"] = null; -$active_categories["Rigging"] = null; -$active_categories["Scripts"] = null; -$active_categories["Sculpting"] = null; -$active_categories["Sequence"] = null; -$active_categories["Sequencer"] = null; -$active_categories["Software"] = null; -$active_categories["Solaris related"] = null; -$active_categories["Subversion"] = null; -$active_categories["System"] = null; -$active_categories["Template"] = null; -$active_categories["Templates"] = null; -$active_categories["Text Editor"] = null; -$active_categories["Text editor"] = null; -$active_categories["Texture Paint"] = null; -$active_categories["Texture"] = null; -$active_categories["Themes"] = null; -$active_categories["Tools"] = null; -$active_categories["Tracker"] = null; -$active_categories["UI/Interface"] = null; -$active_categories["UV"] = null; -$active_categories["Unstable (example)"] = null; -$active_categories["User Interface"] = "User Interface"; -$active_categories["Vertex Paint"] = null; -$active_categories["Vertex Paint,Weight Paint"] = null; -$active_categories["Weight Paint"] = null; -$active_categories["Widget (example)"] = null; -$active_categories["Windows related"] = null; -$active_categories["YafRay"] = null; -$active_categories["blender.org"] = null; -$active_categories["m3dimport"] = null; -$active_categories["nodes and composting"] = null; -$active_categories["opengl"] = null; -$active_categories["pyapidoc-css"] = null; -$active_categories["wiki-mediawiki"] = null; -$active_categories["wiki-mediawiki-extensions"] = null; -$active_categories["wiki-server"] = null; -$active_categories["wiki-skin"] = null; -$active_categories["wiki-skin-images"] = null; -$active_categories["wiki-skin-navtree"] = null; -$active_categories["wiki-skin-search"] = null; -$active_categories["wiki-skin-sidebar"] = null; -$active_categories["wiki-templates"] = null; +$bf_blender_categories = array(); +$bf_blender_categories["None"] = null; +$bf_blender_categories["Animation system"] = "Animation"; +$bf_blender_categories["Audio"] = "Audio"; +$bf_blender_categories["Compositor"] = "Compositing"; +$bf_blender_categories["Depsgraph"] = "Dependency Graph"; +$bf_blender_categories["FFMPEG"] = "Images & Movies"; +$bf_blender_categories["Freestyle"] = "Freestyle"; +$bf_blender_categories["Image & Movie I/O"] = "Images & Movies"; +$bf_blender_categories["Import/Export"] = "Import/Export"; +$bf_blender_categories["Interface"] = "User Interface"; +$bf_blender_categories["International"] = "Translations"; +$bf_blender_categories["Masking"] = "Masking"; +$bf_blender_categories["Mesh Modeling"] = "Mesh Modeling"; +$bf_blender_categories["Modifiers"] = "Modifiers"; +$bf_blender_categories["Motion tracking"] = "Motion Tracking"; +$bf_blender_categories["Node Editor"] = "Nodes"; +$bf_blender_categories["OS related: FreeBSD"] = "FreeBSD"; +$bf_blender_categories["OS related: Linux"] = "Linux"; +$bf_blender_categories["OS related: OSX"] = "Mac OS X"; +$bf_blender_categories["OS related: Windows"] = "Windows"; +$bf_blender_categories["Opengl / Gfx"] = "OpenGL / Gfx"; +$bf_blender_categories["Physics"] = "Physics"; +$bf_blender_categories["Python"] = "Python"; +$bf_blender_categories["Rendering"] = "Rendering"; +$bf_blender_categories["Rendering: Cycles"] = "Cycles"; +$bf_blender_categories["Scripts"] = null; +$bf_blender_categories["Sculpting"] = "Sculpting"; +$bf_blender_categories["Sequencer"] = "Video Sequencer"; +$bf_blender_categories["Text editor"] = "Text Editor"; +$bf_blender_categories["Tools"] = null; +$bf_blender_categories["Game engine"] = "Game Engine"; +$bf_blender_categories["Python API"] = "Python"; +$bf_blender_categories["nodes and composting"] = "Nodes"; // 88 $bf_developers = array( diff --git a/migration/import_projects.php b/migration/import_projects.php index 69b1a9f677..dcc4f4eb5a 100755 --- a/migration/import_projects.php +++ b/migration/import_projects.php @@ -39,10 +39,11 @@ create_project("OpenGL / Gfx", "None", true, array(), "OpenGL and graphics drive create_project("Physics", "None", true, array(), "Physics simulation systems including rigid bodies, cloth, softbodies, smoke fluids and particles."); // Physics create_project("Python", "None", true, array(), "Python API for scripting."); // Python create_project("Rendering", "None", true, array(), "Blender internal renderer and general rendering pipeline."); // Rendering -create_project("Cycles", "None", true, array(), "Ray tracing based production renderer built into Blender."); // Rendering: Cycles +create_project("Cycles", "None", true, array(), "Raytracing based production renderer built into Blender."); // Rendering: Cycles //create_project("Scripts", "None", true, array(), ""); // Scripts create_project("Sculpting", "None", true, array(), "Mesh sculpting."); // Sculpting create_project("Video Sequencer", "None", true, array(), "Video editor built into Blender."); // Sequencer create_project("Text Editor", "None", true, array(), "Text editor built into Blender."); // Text editor //create_project("Tools", "None", true, array(), ""); // Tools +create_project("Game Engine", "None", true, array(), "Blender game engine."); diff --git a/migration/import_task.php b/migration/import_task.php index 2df6f0f3bb..68f1e5b33b 100755 --- a/migration/import_task.php +++ b/migration/import_task.php @@ -7,7 +7,7 @@ require_once 'storage.php'; require_once 'adapt.php'; require_once 'phab.php'; -for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick subset of tasks +for($id = intval($argv[1]); $id < intval($argv[2]); $id+=1) { /* unserialize */ $fname = "dump/task_" . $id; if(!file_exists($fname)) @@ -23,14 +23,11 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick sub $assign = lookup_user(dedup_user($mtask->assign)); $projects = array(); // 100 Unbreak Now!, 90 Needs Triage, 80 High, 50 Normal, 25 Low, 0, Wishlist - // TODO set feature request and todo priorities - $priority = 50; $status = ManiphestTaskStatus::STATUS_OPEN; $description = '%%%' . html_entity_decode($mtask->description) . '%%%'; // TODO replace urls $title = html_entity_decode($mtask->title); /* spam detection */ - // TODO: this only catches a small subet of spam if(($author == "None" || $author == null) && startsWith($description, "%%%project][1]) { - $projects[] = lookup_project($active_projects[$mtask->project][1])->getPHID(); + /* BF Blender tasks */ + if($mtask->project == "Blender 2.x BF release") { + $projects[] = lookup_project("BF Blender")->getPHID(); + $category = null; + $category_key = null; + $mstatus = null; + $mstatus_key = null; + $resolution = null; + $resolution_key = null; + $old_resolution = null; + $old_resolution_key = null; + $data_type = null; + $date_type_key = null; + + foreach($mtask->extra_fields as $key => $field) { + if($field['name'] == "Category") { + $category = $field['value']; + $category_key = $key; + } + else if($field['name'] == "Status") { + $mstatus = $field['value']; + $mstatus_key = $key; + } + else if($field['name'] == "Resolution") { + $resolution = $field['value']; + $resolution_key = $key; + } + else if($field['name'] == "Resolution(Old, use status)") { + $old_resolution = $field['value']; + $old_resolution_key = $key; + } + else if($field['name'] == "Data Type") { + $data_type = $field['value']; + $data_type_key = $key; + } + } + + if($mtask->tracker == "Blender 2.6 Bug Tracker") { + $close_as_archived = false; + $task_type = "Bug"; + $priority = 50; + + if($category) { + if($bf_blender_categories[$category]) + $projects[] = lookup_project($bf_blender_categories[$category])->getPHID(); + unset($mtask->extra_fields[$category_key]); + } + + // TODO: add more statuses or fields + switch($mstatus) { + case "New": + $priority = 90; + break; + case "Reopened": + break; + case "Investigate": + break; + case "Confirmed": + break; + case "Incomplete": + break; + case "Fixed / Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; + break; + case "Rejected / Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; + break; + case "Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; + break; + case "Todo / Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; + break; + case "Out of scope / Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; + break; + case "Ready": + break; + case "*RELEASE BLOCKER*": + $priority = 80; + break; + default: + echo "ERROR: unkown status \"" . $mstatus . "\" (" . $id . ")\n"; + break; + } + + unset($mtask->extra_fields[$mstatus_key]); + } + else if($mtask->tracker == "Blender 2.4x Bug Tracker") { + // TODO: handle status + $task_type = "Bug"; + $priority = 50; + $close_as_archived = true; + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; + } + else if($mtask->tracker == "Game Engine") { + // TODO: add more statuses or fields + switch($mstatus) { + case "None": + case "New": + case "Reopened": + case "Investigate": + case "Ready": + $status = ManiphestTaskStatus::STATUS_OPEN; + break; + case "Fixed": + $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; + break; + case "Duplicate": + $status = ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE; + break; + case "Rejected": + $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; + break; + case "Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; + break; + default: + echo "ERROR: unkown resolution \"" . $resolution . "\" (" . $id . ")\n"; + break; + } + + unset($mtask->extra_fields[$mstatus_key]); + + $projects[] = lookup_project("Game Engine")->getPHID(); + $task_type = "Bug"; + $priority = 50; + $close_as_archived = false; + $status = ManiphestTaskStatus::STATUS_OPEN; + } + else if($mtask->tracker == "Todo") { + $task_type = "To Do"; + $priority = 0; + $close_as_archived = false; + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; + } + else if($mtask->tracker == "OpenGL errors") { + $task_type = "OpenGL Error"; + $priority = 25; + $close_as_archived = false; + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; + } + else if($mtask->tracker == "Patches") { + $task_type = "Patch"; + $priority = 50; + $close_as_archived = false; + + if($category) { + if($bf_blender_categories[$category]) + $projects[] = lookup_project($bf_blender_categories[$category])->getPHID(); + unset($mtask->extra_fields[$category_key]); + } + + // TODO: add more statuses or fields + switch($resolution) { + case "None": + $status = ManiphestTaskStatus::STATUS_OPEN; + break; + case "Open": + $status = ManiphestTaskStatus::STATUS_OPEN; + break; + case "Investigate": + $status = ManiphestTaskStatus::STATUS_OPEN; + break; + case "Need updates": + $status = ManiphestTaskStatus::STATUS_OPEN; + break; + case "Applied": + $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; + break; + case "Closed": + $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; + break; + default: + echo "ERROR: unkown resolution \"" . $resolution . "\" (" . $id . ")\n"; + break; + } + + unset($mtask->extra_fields[$resolution_key]); + if($old_resolution) + unset($mtask->extra_fields[$old_resolution_key]); + } + else { + echo "ERROR: unknown BF Blender tracker " . $mtask->tracker . " (" . $id . ")\n"; + $priority = 50; + $close_as_archived = true; + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; + } + } + else if($mtask->project == "Blender Extensions") { + switch($mtask->tracker) { + case "Py Scripts Extern": + $extension_type = "Python Script Extern"; + break; + case "dev-tools": + break; + case "test-tracker": + break; + case "Plugins Release": + $extension_type = "Plugin Release"; + break; + case "Plugins Contrib": + $extension_type = "Plugin Contrib"; + break; + case "Plugins Upload": + $extension_type = "Plugin Upload"; + break; + case "Py Scripts Release": + $extension_type = "Pythin Script Release"; + break; + case "Py Scripts Contrib": + $extension_type = "Python Script Contrib"; + break; + case "Py Scripts Upload": + $extension_type = "Python Script Upload"; + break; + case "Bugs": + break; + default: + echo "ERROR: unkown extension tracker \"" . $mtask->tracker . "\" (" . $id . ")\n"; + break; + } + + // TODO: status! + + $projects[] = lookup_project("Extensions")->getPHID(); + $task_type = "Extension"; + $priority = 50; + $status = ManiphestTaskStatus::STATUS_OPEN; + $close_as_archived = false; } else { $extra .= "**Project**: " . $mtask->project . "\n"; - } - - if($active_trackers[$mtask->tracker][1]) { - $projects[] = lookup_project($active_trackers[$mtask->tracker][1])->getPHID(); - } - - $task_type = "Other"; - - if($active_trackers[$mtask->tracker][2]) { - $task_type = $active_trackers[$mtask->tracker][2]; - } - else { $extra .= "**Tracker**: " . $mtask->tracker . "\n"; + + $task_type = "Other"; + $priority = 50; + $close_as_archived = true; + $status = ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED; } + /* add remaining extra fields to description */ foreach($mtask->extra_fields as $field) { - if($field['name'] == "Category") { - if($active_categories[$field['value']]) - $projects[] = lookup_project($active_categories[$field['value']])->getPHID(); - - continue; - } - - if($field['name'] == "Status") { - switch($field['value']) { - case "None": /*$status = ManiphestTaskStatus::STATUS_OPEN;*/ break; - case "Closed": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "New": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Fixed / Closed": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Rejected": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Fixed": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Rejected / Closed": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Duplicate": $status = ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE; break; - case "Todo / Closed": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Open": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Merged w/ others scripts": $status = ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE; break; - case "Buggy": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "No wiki": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case ">Contrib": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Implemented": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Accepted": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Investigate": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Reopened": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case ">Release": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "On hold": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Investigating": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Awaiting Response": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Confirmed": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Out of scope / Closed": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Ready": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Incomplete": $status = ManiphestTaskStatus::STATUS_OPEN; break; - default: - echo "ERROR: unknown Status " . $field['value'] . "\n"; - break; - } - - // XXX continue; - } - - if($field['name'] == "Resolution") { - switch($field['value']) { - case "Investigate": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "New": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Approved": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Fixed": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Rejected": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Postponed": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Ready": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "None": /*$status = ManiphestTaskStatus::STATUS_OPEN;*/ break; - case "Ready": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Closed": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Open": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Invalid": $status = ManiphestTaskStatus::STATUS_CLOSED_INVALID; break; - case "Accepted As Bug": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Won't Fix": $status = ManiphestTaskStatus::STATUS_CLOSED_WONTFIX; break; - case "Duplicate": $status = ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE; break; - case "Awaiting Response": $status = ManiphestTaskStatus::STATUS_OPEN; break; - case "Applied": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Accepted": $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; break; - case "Need updates": $status = ManiphestTaskStatus::STATUS_OPEN; break; - default: - echo "ERROR: unknown Resolution " . $field['value'] . "\n"; - break; - } - } - - if($field['name'] == "Resolution(Old, use status)") { - // XXX - } - if($field['value'] == "" || $field['value'] == 'None') continue; @@ -198,8 +344,7 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick sub /* create task */ $task = create_task($author, $mtask->id, $title, $projects, - $description, $assign, $mtask->date, $ccs, $priority, $task_type); - + $description, $assign, $mtask->date, $ccs, $priority, $task_type, $extension_type); /* create array with all operations */ $sorted_dates = array(); @@ -218,21 +363,24 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick sub } /* history */ - $old_status = $mtask->state; + $old_status = $status; + $found_last_status = false; foreach ($mtask->history as $mhistory) { - // TODO: these often have the wrong user (e.g. T17501) // TODO: different types of status fields exist - if($mhistory->field == "Status") { + if($mhistory->field == "Status" || $mhistory->field == "status_id" || $mhistory->field == "Resolution") { $sorted_dates[] = $mhistory->date + 2; // couldn't find stable sort, so hack $sorted_actions[] = array($mhistory->user, $mhistory->date, $old_status); - $old_status = $mhistory->old; + $found_last_status = true; + break; // only does last status, too messy to figure out from history } } - $sorted_dates[] = $mtask->date; - $sorted_actions[] = array($mtask->author, $mtask->date, $old_status); + if(!$found_last_status) { + $sorted_dates[] = $mtask->date; + $sorted_actions[] = array("None", $mtask->date, $old_status); + } /* sort and apply in order */ array_multisort($sorted_dates, $sorted_actions); @@ -246,8 +394,8 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick sub // TODO skip low file IDS to avoid F1..F12 becoming shortcut key links // TODO mysql file size limit if($user) - create_comment($task, $user, "Attach file: " . $mfile->name, $mfile->date); - //create_file($task, $user, $mfile->name, $mfile->contents, $mfile->date);*/ + create_file($task, $user, $mfile->name, $mfile->contents, $mfile->date); + //create_comment($task, $user, "Attach file: " . $mfile->name, $mfile->date); } else if(is_object($action) && get_class($action) == "MigrateComment") { /* create comment */ @@ -268,19 +416,15 @@ for($id = intval($argv[1]); $id < intval($argv[2]); $id+=100) { // XXX quick sub if(!$user) $user = lookup_user("None"); - $status = ManiphestTaskStatus::STATUS_OPEN; - - if(strpos($mstatus, "Closed") !== false) - $status = ManiphestTaskStatus::STATUS_CLOSED_RESOLVED; - - set_status($task, $user, $status, $mdate); + set_status($task, $user, $mstatus, $mdate); } } - /* if me missed the status somehow, close anyway if task is closed */ - // TODO + /* final status check */ + if($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN && $close_as_archived) + set_status($task, lookup_user("None"), ManiphestTaskStatus::STATUS_CLOSED_ARCHIVED, $mtask->date); + if($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN && $mtask->state == "Closed") - echo "ERROR: status out of sync, task should have been closed\n"; - //set_status($task, lookup_user("None"), ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, $mtask->date); + echo "ERROR: status out of sync, task should have been closed (" . $id . ")\n"; } diff --git a/migration/phab.php b/migration/phab.php index 1d7d552f87..f545afc781 100644 --- a/migration/phab.php +++ b/migration/phab.php @@ -1,7 +1,8 @@ getFields() as $field) { @@ -14,48 +15,53 @@ function create_custom_field_transaction($task, $user, $value, $template) $old_values = array(); foreach ($aux_fields as $aux_arr_key => $aux_field) { - $aux_old_value = $aux_field->getOldValueForApplicationTransactions(); - $aux_field->setValueFromStorage($value); - $aux_new_value = $aux_field->getNewValueForApplicationTransactions(); + if($aux_arr_key == "std:maniphest:" . $name) { + $aux_old_value = $aux_field->getOldValueForApplicationTransactions(); + $aux_field->setValueFromStorage($value); + $aux_new_value = $aux_field->getNewValueForApplicationTransactions(); - $placeholder_editor = new PhabricatorUserProfileEditor(); + $placeholder_editor = new PhabricatorUserProfileEditor(); - $field_errors = $aux_field->validateApplicationTransactions( - $placeholder_editor, - PhabricatorTransactions::TYPE_CUSTOMFIELD, - array( - id(new ManiphestTransaction()) - ->setOldValue($aux_old_value) - ->setNewValue($aux_new_value), - )); + $field_errors = $aux_field->validateApplicationTransactions( + $placeholder_editor, + PhabricatorTransactions::TYPE_CUSTOMFIELD, + array( + id(new ManiphestTransaction()) + ->setOldValue($aux_old_value) + ->setNewValue($aux_new_value), + )); - foreach ($field_errors as $error) { - $errors[] = $error->getMessage(); - } + foreach ($field_errors as $error) { + $errors[] = $error->getMessage(); + } - $old_values[$aux_field->getFieldKey()] = $aux_old_value; + $old_values[$aux_field->getFieldKey()] = $aux_old_value; + } } $transactions = array(); - foreach ($aux_fields as $aux_field) { - $transaction = clone $template; - $transaction->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD); - $aux_key = $aux_field->getFieldKey(); - $transaction->setMetadataValue('customfield:key', $aux_key); - $old = idx($old_values, $aux_key); - $new = $aux_field->getNewValueForApplicationTransactions(); + foreach ($aux_fields as $aux_arr_key => $aux_field) { + if($aux_arr_key == "std:maniphest:" . $name) { + $transaction = clone $template; + $transaction->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD); + $aux_key = $aux_field->getFieldKey(); + $transaction->setMetadataValue('customfield:key', $aux_key); + $old = idx($old_values, $aux_key); + $new = $aux_field->getNewValueForApplicationTransactions(); - $transaction->setOldValue($old); - $transaction->setNewValue($new); + $transaction->setOldValue($old); + $transaction->setNewValue($new); + $transaction->setOverrideDate($date); - $transactions[] = $transaction; + $transactions[] = $transaction; + } } return $transactions; } -function create_task($user, $id, $title, $projects, $description, $assign_user, $date, $ccs, $priority, $field_value) +function create_task($user, $id, $title, $projects, $description, $assign_user, $date, $ccs, $priority, $type_field, $extension_field) { /* create task */ $task = ManiphestTask::initializeNewTask($user); @@ -94,7 +100,9 @@ function create_task($user, $id, $title, $projects, $description, $assign_user, } /* type */ - $transactions = array_merge($transactions, create_custom_field_transaction($task, $user, $field_value, $template)); + $transactions = array_merge($transactions, create_custom_field_transaction($task, $user, "blender:task-type", $type_field, $template, $date)); + if($extension_field != "None") + $transactions = array_merge($transactions, create_custom_field_transaction($task, $user, "blender:extension-type", $extension_field, $template, $date)); $editor = id(new ManiphestTransactionEditorPro()) ->setActor($user) diff --git a/src/infrastructure/storage/lisk/LiskDAO.php b/src/infrastructure/storage/lisk/LiskDAO.php index 55cc544b31..a8667a1266 100644 --- a/src/infrastructure/storage/lisk/LiskDAO.php +++ b/src/infrastructure/storage/lisk/LiskDAO.php @@ -1220,10 +1220,20 @@ abstract class LiskDAO { // If we are using autoincrement IDs, let MySQL assign the value for the // ID column, if it is empty. If the caller has explicitly provided a // value, use it. - $id_key = $this->getIDKeyForUse(); - if (empty($data[$id_key])) { - unset($data[$id_key]); - } + if ($this->__overrideID == null) { + $id_key = $this->getIDKeyForUse(); + if (empty($data[$id_key])) { + unset($data[$id_key]); + } + } + else { + // Blender hack to assign custom IDs + $id_key = $this->getIDKeyForUse(); + if (empty($data[$id_key])) { + $this->setID($this->__overrideID); + $data[$id_key] = $this->__overrideID; + } + } break; case self::IDS_COUNTER: // If we are using counter IDs, assign a new ID if we don't already have @@ -1259,7 +1269,7 @@ abstract class LiskDAO { $data); // Only use the insert id if this table is using auto-increment ids - if ($id_mechanism === self::IDS_AUTOINCREMENT) { + if ($this->__overrideID == null && $id_mechanism === self::IDS_AUTOINCREMENT) { $this->setID($conn->getInsertID()); } @@ -1363,6 +1373,14 @@ abstract class LiskDAO { */ protected function didWriteData() {} + /* Blender Hacks */ + public function setOverrideDate($date) { + $this->__overrideDate = $date; + } + + public function setOverrideID($id) { + $this->__overrideID = $id; + } /** * Hook to make internal object state changes prior to INSERT, REPLACE or @@ -1374,10 +1392,17 @@ abstract class LiskDAO { $use_timestamps = $this->getConfigOption(self::CONFIG_TIMESTAMPS); if ($use_timestamps) { - if (!$this->getDateCreated()) { - $this->setDateCreated(time()); + /* Blender Hacks */ + if ($this->__overrideDate == null) { + if (!$this->getDateCreated()) { + $this->setDateCreated(time()); + } + $this->setDateModified(time()); + } + else { + $this->setDateCreated($this->__overrideDate); + $this->setDateModified($this->__overrideDate); } - $this->setDateModified(time()); } if ($this->getConfigOption(self::CONFIG_AUX_PHID) && !$this->getPHID()) {