Subversion Repositories DevTools

Rev

Rev 888 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 888 Rev 892
Line 415... Line 415...
415
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
415
      releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
416
      mLogger.info("applyPv returned 0");
416
      mLogger.info("applyPv returned 0");
417
      return 0;
417
      return 0;
418
    }
418
    }
419
    
419
    
-
 
420
    MutableInt major = new MutableInt();
420
    int major = 0;
421
    major.value = 0;
-
 
422
    MutableInt minor = new MutableInt();
421
    int minor = 0;
423
    minor.value = 0;
-
 
424
    MutableInt patch = new MutableInt();
422
    int patch = 1000;
425
    patch.value = 1000;
423
 
426
 
424
    String field[] = mVersion.split("\\D");
427
    String field[] = mVersion.split("\\D");
425
    String nonStandardCotsVersion = "";
428
    String nonStandardCotsVersion = "";
426
 
429
 
427
    if ( field.length == 3 )
430
    if ( field.length == 3 )
428
    {
431
    {
429
      major = Integer.parseInt(field[0]);
432
      major.value = Integer.parseInt(field[0]);
430
      minor = Integer.parseInt(field[1]);
433
      minor.value = Integer.parseInt(field[1]);
431
      patch = Integer.parseInt(field[2]);
434
      patch.value = Integer.parseInt(field[2]);
432
    }
435
    }
433
    else
436
    else
434
    {
437
    {
435
      if ( !mChangeType.mMajor &&
438
      if ( !mChangeType.mMajor &&
436
           !mChangeType.mMinor &&
439
           !mChangeType.mMinor &&
Line 446... Line 449...
446
        int patchLen = patchStr.length();
449
        int patchLen = patchStr.length();
447
        
450
        
448
        // check patchStr is the last (at least 4) digits
451
        // check patchStr is the last (at least 4) digits
449
        if ( patchLen > 3 && mVersion.substring( mVersion.length() - patchLen, mVersion.length() ).compareTo(patchStr) == 0 )
452
        if ( patchLen > 3 && mVersion.substring( mVersion.length() - patchLen, mVersion.length() ).compareTo(patchStr) == 0 )
450
        {
453
        {
451
          patch = Integer.parseInt(patchStr);
454
          patch.value = Integer.parseInt(patchStr);
452
          nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen );
455
          nonStandardCotsVersion = mVersion.substring(0, mVersion.length() - patchLen );
453
        }
456
        }
454
      }
457
      }
455
      
458
      
456
      if ( nonStandardCotsVersion.length() == 0 )
459
      if ( nonStandardCotsVersion.length() == 0 )
Line 461... Line 464...
461
        return 1;
464
        return 1;
462
      }
465
      }
463
    }
466
    }
464
 
467
 
465
    if ( nonStandardCotsVersion.length() == 0 &&
468
    if ( nonStandardCotsVersion.length() == 0 &&
466
         patch < 1000 && 
469
         patch.value < 1000 && 
467
         field[2].substring(0, 1).compareTo("0") != 0 )
470
         field[2].substring(0, 1).compareTo("0") != 0 )
468
    {
471
    {
469
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
472
      mLogger.info("applyPV accomodate old style mVersion of the form 1.0.1");
470
      patch = patch * 1000;
473
      patch.value = patch.value * 1000;
471
    }
474
    }
472
      
475
      
473
    // mChangeType overrides mRippleField
476
    // mChangeType overrides mRippleField
474
    do
477
    do
475
    {
478
    {
476
      if ( mChangeType.mMajor )
479
      if ( mChangeType.mMajor )
477
      {
480
      {
-
 
481
        if ( !incrementFieldsAccordingToLimits(4, major, minor, patch) )
478
        major++;
482
        {
479
        mLogger.info("applyPV mChangeType.mMajor " + major);
483
          mLogger.info("applyPv returned 2");
480
        minor = 0;
484
          return 2;
481
        patch = 0;
485
        }
482
      }
486
      }
483
      else if ( mChangeType.mMinor )
487
      else if ( mChangeType.mMinor )
484
      {
488
      {
-
 
489
        if ( !incrementFieldsAccordingToLimits(3, major, minor, patch) )
485
        minor++;
490
        {
486
        mLogger.info("applyPV mChangeType.mMinor " + minor);
491
          mLogger.info("applyPv returned 2");
487
        patch = 0;
492
          return 2;
-
 
493
        }
488
      }
494
      }
489
      else if ( mChangeType.mPatch )
495
      else if ( mChangeType.mPatch )
490
      {
496
      {
491
        do
497
        if ( !incrementFieldsAccordingToLimits(2, major, minor, patch) )
492
        {
498
        {
-
 
499
          mLogger.info("applyPv returned 2");
493
          patch++;
500
          return 2;
494
        } while ( ( patch / 1000 ) * 1000 != patch );
501
        }
495
        mLogger.info("applyPV mChangeType.mPatch " + patch);
-
 
496
      }
502
      }
497
      else
503
      else
498
      {
504
      {
499
        if ( mRippleField.mMajor )
505
        if ( mRippleField.mMajor )
500
        {
506
        {
501
          major++;
507
          major.value++;
502
          mLogger.info("applyPV mRippleField.mMajor " + major);
508
          mLogger.info("applyPV mRippleField.mMajor " + major.value);
503
          minor = 0;
509
          minor.value = 0;
504
          patch = 0;
510
          patch.value = 0;
505
        }
511
        }
506
        else if ( mRippleField.mMinor )
512
        else if ( mRippleField.mMinor )
507
        {
513
        {
508
          minor++;
514
          minor.value++;
509
          mLogger.info("applyPV mRippleField.mMinor " + minor);
515
          mLogger.info("applyPV mRippleField.mMinor " + minor.value);
510
          patch = 0;
516
          patch.value = 0;
511
        }
517
        }
512
        else if ( mRippleField.mPatch )
518
        else if ( mRippleField.mPatch )
513
        {
519
        {
514
          do
520
          do
515
          {
521
          {
516
            patch++;
522
            patch.value++;
517
          } while ( ( patch / 1000 ) * 1000 != patch );
523
          } while ( ( patch.value / 1000 ) * 1000 != patch.value );
518
          mLogger.info("applyPV mRippleField.mPatch " + patch);
524
          mLogger.info("applyPV mRippleField.mPatch " + patch.value);
519
        }
525
        }
520
        else if ( mRippleField.mBuild )
526
        else if ( mRippleField.mBuild )
521
        {
527
        {
522
          patch++;
528
          patch.value++;
523
          mLogger.info("applyPV mRippleField.mBuild " + patch);
529
          mLogger.info("applyPV mRippleField.mBuild " + patch.value);
524
        }
530
        }
525
        else
531
        else
526
        {
532
        {
527
          // increment fields according to limits
533
          if ( !incrementFieldsAccordingToLimits(1, major, minor, patch) )
528
          boolean changeOccurred = false;
-
 
529
          boolean incrementField = true;
-
 
530
          
-
 
531
          if ( mBuildLimit != 0 )
-
 
532
          {
-
 
533
            // increment or reset the patch build number
-
 
534
            if ( patch < mBuildLimit )
-
 
535
            {
-
 
536
              // can increment the patch build number
-
 
537
              patch++;
-
 
538
              mLogger.info("applyPv mRippleField.mLimit build number " + patch);
-
 
539
              changeOccurred = true;
-
 
540
              incrementField = false;
-
 
541
            }
-
 
542
            else
-
 
543
            {
-
 
544
              if ( mPatchLimit == 0 )
-
 
545
              {
-
 
546
                // reset the patch number and patch build number
-
 
547
                patch = 0;
-
 
548
              }
-
 
549
            }
-
 
550
          }
-
 
551
          
-
 
552
          if ( mPatchLimit != 0 && incrementField )
-
 
553
          {
-
 
554
            // increment or reset the patch number
-
 
555
            if ( ( patch / 1000 ) < mPatchLimit )
-
 
556
            {
-
 
557
              do
-
 
558
              {
-
 
559
                patch++;
-
 
560
              } while ( ( patch / 1000 ) * 1000 != patch );
-
 
561
              
-
 
562
              mLogger.info("applyPv mRippleField.mLimit patch " + patch);
-
 
563
              changeOccurred = true;
-
 
564
              incrementField = false;
-
 
565
            }
-
 
566
            else
-
 
567
            {
-
 
568
              // reset the patch number and patch build number
-
 
569
              patch = 0;
-
 
570
            }
-
 
571
          }
-
 
572
          
-
 
573
          if ( mMinorLimit != 0 && incrementField )
-
 
574
          {
-
 
575
            // increment or reset the minor number
-
 
576
            if ( minor < mMinorLimit )
-
 
577
            {
-
 
578
              minor++;
-
 
579
              mLogger.info("applyPv mRippleField.mLimit minor " + minor);
-
 
580
              changeOccurred = true;
-
 
581
              incrementField = false;
-
 
582
            }
-
 
583
            else
-
 
584
            {
-
 
585
              // reset the minor number
-
 
586
              minor = 0;
-
 
587
            }
-
 
588
          }
-
 
589
          
-
 
590
          if ( mMajorLimit != 0 && incrementField )
-
 
591
          {
-
 
592
            // increment or reset the major number
-
 
593
            if ( major < mMajorLimit )
-
 
594
            {
-
 
595
              // increment the major number
-
 
596
              changeOccurred = true;
-
 
597
              major++;
-
 
598
              mLogger.info("applyPv mRippleField.mLimit major " + major);
-
 
599
            }
-
 
600
          }
-
 
601
          
-
 
602
          if ( !changeOccurred )
-
 
603
          {
534
          {
604
            // unable to increment a field due to field limitations
-
 
605
            mLogger.error("applyPV ripple field limitations prevent a ripple build");
-
 
606
            mLogger.info("applyPv returned 2");
535
            mLogger.info("applyPv returned 2");
607
            return 2;
536
            return 2;
608
          }
537
          }
609
        }
538
        }
610
      }
539
      }
611
 
540
 
612
      if ( nonStandardCotsVersion.length() == 0 )
541
      if ( nonStandardCotsVersion.length() == 0 )
613
      {
542
      {
614
        mVersion = String.valueOf(major) + "." + String.valueOf(minor) + ".";
543
        mVersion = String.valueOf(major.value) + "." + String.valueOf(minor.value) + ".";
615
      }
544
      }
616
      else
545
      else
617
      {
546
      {
618
        mVersion = nonStandardCotsVersion;
547
        mVersion = nonStandardCotsVersion;
619
      }
548
      }
620
      
549
      
621
      if ( patch < 10 )
550
      if ( patch.value < 10 )
622
      {
551
      {
623
        mVersion += "000";
552
        mVersion += "000";
624
      }
553
      }
625
      else if ( patch < 100 )
554
      else if ( patch.value < 100 )
626
      {
555
      {
627
        mVersion += "00";
556
        mVersion += "00";
628
      }
557
      }
629
      else if ( patch < 1000 )
558
      else if ( patch.value < 1000 )
630
      {
559
      {
631
        mVersion += "0";
560
        mVersion += "0";
632
      }
561
      }
633
      
562
      
634
      mVersion += String.valueOf(patch);
563
      mVersion += String.valueOf(patch.value);
635
    } while ( exists(releaseManager, rtag_id) );
564
    } while ( exists(releaseManager, rtag_id) );
636
    
565
    
637
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
566
    releaseManager.claimVersion(mPid, mVersion + mExtension, rtag_id);
638
    mLogger.info("applyPv returned 0");
567
    mLogger.info("applyPv returned 0");
639
    return 0;
568
    return 0;
640
  }
569
  }
641
 
570
 
-
 
571
  /**increments fields according to mRippleField.mLimit if necessary
-
 
572
   * will apply it to the field passed as follows
-
 
573
   * 1 = build
-
 
574
   * 2 = patch
-
 
575
   * 3 = minor
-
 
576
   * other = major
-
 
577
   * returns true on success
-
 
578
   *         false on ripple field limitations prevent a ripple build
-
 
579
   */
-
 
580
  private boolean incrementFieldsAccordingToLimits(int field, MutableInt major, MutableInt minor, MutableInt patch)
-
 
581
  {
-
 
582
    boolean retVal = true;
-
 
583
    
-
 
584
    if (!mRippleField.mLimit)
-
 
585
    {
-
 
586
      // simple case
-
 
587
      // no need to take field limits into consideration
-
 
588
      switch (field)
-
 
589
      {
-
 
590
      case 1:
-
 
591
        // unreachable
-
 
592
        // the only scenario involving build number manipulation involves the mRippleField.mLimit being set
-
 
593
        retVal = false;
-
 
594
        break;
-
 
595
      case 2:
-
 
596
        do
-
 
597
        {
-
 
598
          patch.value++;
-
 
599
        } while ( ( patch.value / 1000 ) * 1000 != patch.value );
-
 
600
        mLogger.info("incrementFieldsAccordingToLimits patch " + patch.value);
-
 
601
        break;
-
 
602
      case 3:
-
 
603
        minor.value++;
-
 
604
        mLogger.info("incrementFieldsAccordingToLimits minor " + minor.value);
-
 
605
        patch.value = 0;
-
 
606
        break;
-
 
607
      default:
-
 
608
        major.value++;
-
 
609
        mLogger.info("incrementFieldsAccordingToLimits major " + major.value);
-
 
610
        minor.value = 0;
-
 
611
        patch.value = 0;
-
 
612
      }
-
 
613
    }
-
 
614
    else
-
 
615
    {
-
 
616
      // take field limits into consideration
-
 
617
      boolean changeOccurred = false;
-
 
618
      boolean incrementField = true;
-
 
619
      
-
 
620
      switch (field)
-
 
621
      {
-
 
622
      case 1:
-
 
623
        if ( mBuildLimit != 0 )
-
 
624
        {
-
 
625
          // increment or reset the patch build number
-
 
626
          int buildNumber = patch.value - (patch.value/1000) * 1000;
-
 
627
          
-
 
628
          if ( buildNumber < mBuildLimit )
-
 
629
          {
-
 
630
            // can increment the patch build number
-
 
631
            patch.value++;
-
 
632
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit build number " + patch.value);
-
 
633
            changeOccurred = true;
-
 
634
            incrementField = false;
-
 
635
          }
-
 
636
          else
-
 
637
          {
-
 
638
            if ( mPatchLimit == 0 )
-
 
639
            {
-
 
640
              // reset the patch number and patch build number
-
 
641
              patch.value = 0;
-
 
642
            }
-
 
643
          }
-
 
644
        }
-
 
645
        // no break by design
-
 
646
      case 2:
-
 
647
        if ( mPatchLimit != 0 && incrementField )
-
 
648
        {
-
 
649
          // increment or reset the patch number
-
 
650
          if ( ( patch.value / 1000 ) < mPatchLimit )
-
 
651
          {
-
 
652
            do
-
 
653
            {
-
 
654
              patch.value++;
-
 
655
            } while ( ( patch.value / 1000 ) * 1000 != patch.value );
-
 
656
            
-
 
657
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit patch " + patch.value);
-
 
658
            changeOccurred = true;
-
 
659
            incrementField = false;
-
 
660
          }
-
 
661
          else
-
 
662
          {
-
 
663
            // reset the patch number and patch build number
-
 
664
            patch.value = 0;
-
 
665
          }
-
 
666
        }
-
 
667
        // no break by design
-
 
668
      case 3:
-
 
669
        if ( mMinorLimit != 0 && incrementField )
-
 
670
        {
-
 
671
          // increment or reset the minor number
-
 
672
          if ( minor.value < mMinorLimit )
-
 
673
          {
-
 
674
            minor.value++;
-
 
675
            patch.value = 0;
-
 
676
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit minor " + minor.value);
-
 
677
            changeOccurred = true;
-
 
678
            incrementField = false;
-
 
679
          }
-
 
680
          else
-
 
681
          {
-
 
682
            // reset the minor number
-
 
683
            minor.value = 0;
-
 
684
          }
-
 
685
        }
-
 
686
        // no break by design
-
 
687
      default:
-
 
688
        if ( mMajorLimit != 0 && incrementField )
-
 
689
        {
-
 
690
          // increment or reset the major number
-
 
691
          if ( major.value < mMajorLimit )
-
 
692
          {
-
 
693
            // increment the major number
-
 
694
            changeOccurred = true;
-
 
695
            major.value++;
-
 
696
            minor.value = 0;
-
 
697
            patch.value = 0;
-
 
698
            mLogger.info("incrementFieldsAccordingToLimits mRippleField.mLimit major " + major.value);
-
 
699
          }
-
 
700
        }
-
 
701
      }
-
 
702
      
-
 
703
      if ( !changeOccurred )
-
 
704
      {
-
 
705
        // unable to increment a field due to field limitations
-
 
706
        mLogger.error("incrementFieldsAccordingToLimits ripple field limitations prevent a ripple build");
-
 
707
        mLogger.info("incrementFieldsAccordingToLimits returned false");
-
 
708
        retVal = false;
-
 
709
      }
-
 
710
    }
-
 
711
    
-
 
712
    return retVal;
-
 
713
  }
-
 
714
  
642
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
715
  /**returns true if the version exists in the dpkg_archive, deploy_archive or release manager database
643
   * claims the version in the release manager database
716
   * claims the version in the release manager database
644
   */
717
   */
645
  private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
718
  private boolean exists(ReleaseManager releaseManager, int rtag_id) throws Exception
646
  {
719
  {