Reimplemented from VersionSelector.
Definition at line 3244 of file cmt_use.cxx.
03245 {
03246 Use* selected = ref_use;
03247
03248 int old_v = -1;
03249 int old_r = -1;
03250 int old_p = -1;
03251 cmt_string old_pp;
03252
03253 int new_v = -1;
03254 int new_r = -1;
03255 int new_p = -1;
03256 cmt_string new_pp;
03257
03258 int alias_v = -1;
03259 int alias_r = -1;
03260 int alias_p = -1;
03261 cmt_string alias_pp;
03262
03263 enum { no_alias, new_has_alias, ref_has_alias } has_alias = no_alias;
03264
03265 cmt_string ref_version = ref_use->version;
03266 if (ref_version == "v0") ref_version = ref_use->specified_version;
03267
03268 cmt_string new_version = new_use->version;
03269 if (new_version == "v0") new_version = new_use->specified_version;
03270
03271 CmtSystem::is_version_directory (ref_version, old_v, old_r, old_p);
03272 old_pp = ref_use->path;
03273
03274 CmtSystem::is_version_directory (new_version, new_v, new_r, new_p);
03275 new_pp = new_use->path;
03276
03277 if (new_use->version_alias != "")
03278 {
03279 has_alias = new_has_alias;
03280 CmtSystem::is_version_directory (new_use->version_alias,
03281 alias_v, alias_r, alias_p);
03282 alias_pp = new_use->path_alias;
03283 }
03284 else if (ref_use->version_alias != "")
03285 {
03286 has_alias = ref_has_alias;
03287 CmtSystem::is_version_directory (ref_use->version_alias,
03288 alias_v, alias_r, alias_p);
03289 alias_pp = ref_use->path_alias;
03290 }
03291
03292 ref_use->undiscard ();
03293 new_use->undiscard ();
03294
03295 if (new_v != old_v)
03296 {
03297 if (has_alias != no_alias)
03298 {
03299 if (has_alias == new_has_alias)
03300 {
03301 new_v = alias_v;
03302 new_r = alias_r;
03303 new_p = alias_p;
03304 new_pp = alias_pp;
03305 }
03306 else if (has_alias == ref_has_alias)
03307 {
03308 old_v = alias_v;
03309 old_r = alias_r;
03310 old_p = alias_p;
03311 old_pp = alias_pp;
03312 }
03313 }
03314 }
03315
03316 if ((new_v != -1) && (old_v != -1) && (new_v != old_v))
03317 {
03318
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328 CmtError::set (CmtError::version_conflict, "BestFitSelector::operate> ");
03329
03330 if (ref_use != new_use) new_use->discard ();
03331 }
03332 else if ((new_v == -1) || (old_v == -1))
03333 {
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343
03344 if ((old_v == -1) && (new_v != -1))
03345 {
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356 if (ref_use->real_path != new_use->real_path)
03357 {
03358 if (ref_use != new_use) ref_use->discard ();
03359 selected = new_use;
03360 selected->done = false;
03361 }
03362 else
03363 {
03364 if (ref_use != new_use) new_use->discard ();
03365 ref_use->version = new_version;
03366 }
03367 }
03368 else
03369 {
03370
03371
03372
03373
03374
03375
03376
03377
03378 if (ref_use != new_use) new_use->discard ();
03379 }
03380 }
03381 else if ((new_r == -1) || (old_r == -1) || (new_r < old_r))
03382 {
03383
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393 if ((old_r == -1) && (new_r != -1))
03394 {
03395
03396
03397
03398
03399
03400
03401
03402
03403
03404
03405
03406
03407 if (ref_use->real_path != new_use->real_path)
03408 {
03409 if (ref_use != new_use) ref_use->discard ();
03410 selected = new_use;
03411 selected->done = false;
03412 }
03413 else
03414 {
03415
03416
03417 if (ref_use != new_use) new_use->discard ();
03418 ref_use->version = new_version;
03419 }
03420 }
03421 else
03422 {
03423
03424
03425
03426
03427
03428
03429
03430
03431 if (ref_use != new_use) new_use->discard ();
03432 }
03433 }
03434 else if (new_r > old_r)
03435 {
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446 if (ref_use != new_use) ref_use->discard ();
03447 selected = new_use;
03448 selected->done = false;
03449 }
03450 else if ((new_p == -1) || (old_p == -1) || (new_p < old_p))
03451 {
03452
03453
03454
03455
03456
03457
03458 if ((old_p == -1) && (new_p != -1))
03459 {
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470 if (ref_use->real_path != new_use->real_path)
03471 {
03472 if (ref_use != new_use) ref_use->discard ();
03473 selected = new_use;
03474 selected->done = false;
03475 }
03476 else
03477 {
03478 if (ref_use != new_use) new_use->discard ();
03479 ref_use->version = new_version;
03480 }
03481 }
03482 else
03483 {
03484
03485
03486
03487
03488
03489
03490
03491
03492 if (ref_use != new_use) new_use->discard ();
03493 }
03494 }
03495 else if (new_p > old_p)
03496 {
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507 if (ref_use != new_use) ref_use->discard ();
03508 selected = new_use;
03509 selected->done = false;
03510 }
03511 else if (new_pp != old_pp)
03512 {
03513 if (ref_use != new_use) ref_use->discard ();
03514 selected = new_use;
03515 selected->done = false;
03516 }
03517
03518 return (selected);
03519 }