Skip to content

Commit ebbc8e0

Browse files
committed
Merge pull request #976 from greg-1-anderson/remove-multiple
Remove drush rsync multiple-command
2 parents 7f4ecc0 + 57c0211 commit ebbc8e0

File tree

3 files changed

+28
-163
lines changed

3 files changed

+28
-163
lines changed

commands/core/rsync.core.inc

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -40,45 +40,40 @@ function drush_core_rsync($source, $destination, $additional_options = array())
4040
return drush_set_error('DRUSH_BAD_PATH', dt('Could not evaluate destination path !path.', array('!path' => $destination)));
4141
}
4242

43-
// Check to see if this is an rsync multiple command (multiple sources and multiple destinations)
44-
$is_multiple = drush_do_multiple_command('rsync', $source_settings, $destination_settings, TRUE);
45-
46-
if ($is_multiple === FALSE) {
47-
// If the user path is the same for the source and the destination, then
48-
// always add a slash to the end of the source. If the user path is not
49-
// the same in the source and the destination, then you need to know how
50-
// rsync paths work, and put on the trailing '/' if you want it.
51-
if ($source_settings['user-path'] == $destination_settings['user-path']) {
52-
$source_path .= '/';
53-
}
54-
// Prompt for confirmation. This is destructive.
55-
if (!drush_get_context('DRUSH_SIMULATE')) {
56-
drush_print(dt("You will destroy data from !target and replace with data from !source", array('!source' => $source_path, '!target' => $destination_path)));
57-
if (!drush_confirm(dt('Do you really want to continue?'))) {
58-
// was: return drush_set_error('CORE_SYNC_ABORT', 'Aborting.');
59-
return drush_user_abort();
60-
}
43+
// If the user path is the same for the source and the destination, then
44+
// always add a slash to the end of the source. If the user path is not
45+
// the same in the source and the destination, then you need to know how
46+
// rsync paths work, and put on the trailing '/' if you want it.
47+
if ($source_settings['user-path'] == $destination_settings['user-path']) {
48+
$source_path .= '/';
49+
}
50+
// Prompt for confirmation. This is destructive.
51+
if (!drush_get_context('DRUSH_SIMULATE')) {
52+
drush_print(dt("You will destroy data from !target and replace with data from !source", array('!source' => $source_path, '!target' => $destination_path)));
53+
if (!drush_confirm(dt('Do you really want to continue?'))) {
54+
// was: return drush_set_error('CORE_SYNC_ABORT', 'Aborting.');
55+
return drush_user_abort();
6156
}
57+
}
6258

63-
// Exclude settings is the default only when both the source and
64-
// the destination are aliases or site names. Therefore, include
65-
// settings will be the default whenever either the source or the
66-
// destination contains a : or a /.
67-
$include_settings_is_default = (strpos($source . $destination, ':') !== FALSE) || (strpos($source . $destination, '/') !== FALSE);
59+
// Exclude settings is the default only when both the source and
60+
// the destination are aliases or site names. Therefore, include
61+
// settings will be the default whenever either the source or the
62+
// destination contains a : or a /.
63+
$include_settings_is_default = (strpos($source . $destination, ':') !== FALSE) || (strpos($source . $destination, '/') !== FALSE);
6864

69-
$options = _drush_build_rsync_options($additional_options, $include_settings_is_default);
65+
$options = _drush_build_rsync_options($additional_options, $include_settings_is_default);
7066

71-
// Get all of the args and options that appear after the command name.
72-
$original_args = drush_get_original_cli_args_and_options();
73-
foreach ($original_args as $original_option) {
74-
if ($original_option{0} == '-') {
75-
$options .= ' ' . $original_option;
76-
}
67+
// Get all of the args and options that appear after the command name.
68+
$original_args = drush_get_original_cli_args_and_options();
69+
foreach ($original_args as $original_option) {
70+
if ($original_option{0} == '-') {
71+
$options .= ' ' . $original_option;
7772
}
78-
79-
// Go ahead and call rsync with the paths we determined
80-
return drush_core_exec_rsync($source_path, $destination_path, $options);
8173
}
74+
75+
// Go ahead and call rsync with the paths we determined
76+
return drush_core_exec_rsync($source_path, $destination_path, $options);
8277
}
8378

8479
/**

includes/drush.inc

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,83 +1251,6 @@ function _drush_should_remove_command_arg($arg, $removal_list) {
12511251
return FALSE;
12521252
}
12531253

1254-
/**
1255-
* Used by functions that operate on lists of sites, moving
1256-
* information from the source to the destination. Currenlty
1257-
* this includes 'drush rsync' and 'drush sql sync'.
1258-
*/
1259-
function drush_do_multiple_command($command, $source_record, $destination_record, $allow_single_source = FALSE) {
1260-
$is_multiple_command = FALSE;
1261-
1262-
if ((($allow_single_source == TRUE) || array_key_exists('site-list', $source_record)) && array_key_exists('site-list', $destination_record)) {
1263-
$is_multiple_command = TRUE;
1264-
$source_path = array_key_exists('path-component', $source_record) ? $source_record['path-component'] : '';
1265-
$destination_path = array_key_exists('path-component', $destination_record) ? $destination_record['path-component'] : '';
1266-
1267-
$target_list = array_values(drush_sitealias_resolve_sitelist($destination_record));
1268-
if (array_key_exists('site-list', $source_record)) {
1269-
$source_list = array_values(drush_sitealias_resolve_sitelist($source_record));
1270-
1271-
if (drush_sitealias_check_lists_alignment($source_list, $target_list) === FALSE) {
1272-
if (array_key_exists('unordered-list', $source_record) || array_key_exists('unordered-list', $destination_record)) {
1273-
drush_sitelist_align_lists($source_list, $target_list, $aligned_source, $aligned_target);
1274-
$source_list = $aligned_source;
1275-
$target_list = $aligned_target;
1276-
}
1277-
}
1278-
}
1279-
else {
1280-
$source_list = array_fill(0, count($target_list), $source_record);
1281-
}
1282-
1283-
if (!drush_get_context('DRUSH_SIMULATE')) {
1284-
drush_print(dt('You are about to !command between all of the following targets:', array('!command' => $command)));
1285-
$i = 0;
1286-
foreach ($source_list as $one_source) {
1287-
$one_target = $target_list[$i];
1288-
++$i;
1289-
drush_print(dt(' !source will overwrite !target', array('!source' => drush_sitealias_alias_record_to_spec($one_source) . $source_path, '!target' => drush_sitealias_alias_record_to_spec($one_target) . $destination_path)));
1290-
}
1291-
1292-
if (drush_confirm('Continue? ') === FALSE) {
1293-
return drush_user_abort();
1294-
}
1295-
}
1296-
1297-
$data = drush_redispatch_get_options();
1298-
$i = 0;
1299-
foreach ($source_list as $one_source) {
1300-
$one_target = $target_list[$i];
1301-
++$i;
1302-
1303-
$source_spec = drush_sitealias_alias_record_to_spec($one_source);
1304-
$target_spec = drush_sitealias_alias_record_to_spec($one_target);
1305-
1306-
drush_log(dt('Begin do_multiple !command via backend invoke', array('!command' => $command)));
1307-
$values = drush_invoke_process('@self', $command, array($source_spec . $source_path, $target_spec . $destination_path), $data);
1308-
drush_log(dt('Backend invoke is complete'));
1309-
}
1310-
}
1311-
1312-
return $is_multiple_command;
1313-
}
1314-
1315-
/**
1316-
* Run a command on the site specified by the provided command record.
1317-
*
1318-
* The standard function that provides this service is called
1319-
* drush_invoke_process. Please call the standard function.
1320-
*
1321-
* @param backend_options
1322-
* TRUE - integrate errors
1323-
* FALSE - do not integrate errors
1324-
* array - @see drush_backend_invoke_concurrent
1325-
*
1326-
function drush_do_site_command($site_record, $command, $args = array(), $command_options = array(), $backend_options = FALSE) {
1327-
return drush_invoke_process($site_record, $command, $args, $command_options, $backend_options);
1328-
}
1329-
*/
1330-
13311254
/**
13321255
* Redispatch the specified command using the same
13331256
* options that were passed to this invocation of drush.

includes/sitealias.inc

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,59 +1069,6 @@ function drush_sitealias_resolve_sitelist($alias_record) {
10691069
return $result_list;
10701070
}
10711071

1072-
/**
1073-
* Check to see if the uri is the same in the source and target
1074-
* lists for all items in the array. This is a strong requirement
1075-
* in D6; in D7, it is still highly convenient for the uri to
1076-
* be the same, because the site folder name == the uri, and if
1077-
* the uris match, then it is easier to rsync between remote machines.
1078-
*
1079-
* @param $source
1080-
* Array of source alias records
1081-
* @param $target
1082-
* Array of target alias records to compare against source list
1083-
* @return
1084-
* TRUE iff the uris of the sources and targets are in alignment
1085-
*/
1086-
function drush_sitealias_check_lists_alignment($source, $target) {
1087-
$is_aligned = TRUE;
1088-
1089-
$i = 0;
1090-
foreach ($source as $one_source) {
1091-
if ((!isset($target[$i])) || (!_drush_sitelist_check_site_records($one_source, $target[$i]))) {
1092-
$is_aligned = FALSE;
1093-
break;
1094-
}
1095-
++$i;
1096-
}
1097-
1098-
return $is_aligned;
1099-
}
1100-
1101-
/**
1102-
* If the source and target lists contain alias records to the same
1103-
* sets of sites, but in different orders, this routine will re-order
1104-
* the lists so that they are in alignment.
1105-
*
1106-
* TODO: Review the advisability of this operation.
1107-
*/
1108-
function drush_sitelist_align_lists(&$source, &$target, &$source_result, &$target_result) {
1109-
$source_result = array();
1110-
$target_result = array();
1111-
1112-
foreach ($source as $key => $one_source) {
1113-
$one_target = _drush_sitelist_find_in_list($one_source, $target);
1114-
if ($one_target !== FALSE) {
1115-
$source_result[] = $one_source;
1116-
$target_result[] = $one_target;
1117-
unset($source[$key]);
1118-
}
1119-
}
1120-
1121-
$source = $source_result;
1122-
$target = $target_result;
1123-
}
1124-
11251072
function _drush_sitelist_find_in_list($one_source, &$target) {
11261073
$result = FALSE;
11271074

0 commit comments

Comments
 (0)