Advertisement
jackpoz

revision extractor svn 1.7.0

Oct 14th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.72 KB | None | 0 0
  1. Index: extras/RevisionExtractor/RevisionExtractor/Main.cpp
  2. ===================================================================
  3. --- extras/RevisionExtractor/RevisionExtractor/Main.cpp (revision 4634)
  4. +++ extras/RevisionExtractor/RevisionExtractor/Main.cpp (working copy)
  5. @@ -11,10 +11,46 @@
  6.     int revision = 0;
  7.     std::string tag = "TRUNK";
  8.  
  9. +   /* Since Subversion 1.7.0 http://subversion.apache.org/docs/release-notes/1.7.html Subversion clients use "Centralized Metadata Storage",
  10. +   /* storing all metadata in the .svn folder in the root directory of the local svn checkout, instead of having a .svn folder for each
  11. +   /* repository folder. Another difference is that metadata is stored as SQLite database instead of text files.
  12. +   /* For now let's just try with to get the revision from "svn info"
  13. +   */
  14. +
  15.     FILE* entries = fopen("../.svn/entries", "r");
  16.  
  17. -   if (entries != NULL)
  18. +   if (entries == NULL)
  19.     {
  20. +       FILE* svninfoOutput = _popen("svn info", "r");
  21. +       if (svninfoOutput != NULL)
  22. +       {
  23. +           int character;
  24. +           //the revision number is at 6th line so stop after that. "5" is the count of "\n" to skip
  25. +           const int revisionLine = 5;
  26. +           int line = 0;
  27. +           char revisionNumber[5];
  28. +           memset(revisionNumber, 0, sizeof(revisionNumber));
  29. +           int revisionDigits = 0;
  30. +
  31. +           do
  32. +           {
  33. +               character = fgetc(svninfoOutput);
  34. +               if(line == revisionLine)
  35. +               {
  36. +                   if(isdigit(character))
  37. +                       revisionNumber[revisionDigits++] = character;
  38. +               }
  39. +
  40. +               if(character == '\n')
  41. +                   ++line;
  42. +           }
  43. +           while (character != EOF && line <= revisionLine);
  44. +
  45. +           revision = atoi(revisionNumber);
  46. +       }
  47. +   }
  48. +   else
  49. +   {
  50.         fseek(entries, 0, SEEK_END);
  51.         auto entriessize = ftell(entries);
  52.         fseek(entries, 0, SEEK_SET);
  53.  
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement