daily pastebin goal
26%
SHARE
TWEET

asolntsev

a guest Jan 15th, 2010 253 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static String findBranchHeadRevision( ScmFileHistory file, String revisionNumber) {
  2.   String sRevBase = revisionNumber.replaceFirst("(.*)\\.0(\\.\\d+)", "$1$2."); // sRevBase = "1.3.2."
  3.   String sBranchHead = revisionNumber.replaceFirst("(.*)\\.0\\.\\d+", "$1");   // sBranchHead = "1.3"
  4.  
  5.   int maxRevNum = -1;
  6.  
  7.   for (String rev : file.getRevisions()) { // Loop all revisions
  8.     if (rev.startsWith(sRevBase))
  9.     {
  10.       String tail = rev.substring(sRevBase.length());
  11.       if (tail.indexOf('.') == -1) {
  12.         int num = Integer.parseInt(tail);
  13.         if (num > maxRevNum) {
  14.           maxRevNum = num;
  15.           sBranchHead = rev;   // sBranchHead = "1.3.2.1", then "1.3.2.3", and finally "1.3.2.4"
  16.         }
  17.       }
  18.     }
  19.   }
  20.  
  21.   return sBranchHead;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top