VirtualBox

Changeset 26559 in vbox


Ignore:
Timestamp:
Feb 16, 2010 12:44:18 AM (15 years ago)
Author:
vboxsync
Message:

scm: Remove svn:executable from files which shouldn't have them. Add svn:keywords 'Id Revision' to most files, but not headers.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/.scm-settings

    r26557 r26559  
    3434--only-svn-dirs
    3535--only-svn-files
    36 --set-svn-eol
     36#--set-svn-eol
     37--set-svn-executable
     38#--set-svn-keywords
    3739
    3840#
  • trunk/src/bldprogs/scm.cpp

    r26557 r26559  
    238238    /** Set svn:eol-style if missing or incorrect. */
    239239    bool            fSetSvnEol;
     240    /** Set svn:executable according to type (unually this means deleting it). */
     241    bool            fSetSvnExecutable;
     242    /** Set svn:keyword if completely or partially missing. */
     243    bool            fSetSvnKeywords;
    240244    /**  */
    241245    unsigned        cchTab;
     
    282286    SCMOPT_SET_SVN_EOL,
    283287    SCMOPT_DONT_SET_SVN_EOL,
     288    SCMOPT_SET_SVN_EXECUTABLE,
     289    SCMOPT_DONT_SET_SVN_EXECUTABLE,
     290    SCMOPT_SET_SVN_KEYWORDS,
     291    SCMOPT_DONT_SET_SVN_KEYWORDS,
    284292    SCMOPT_TAB_SIZE,
    285293    SCMOPT_FILTER_OUT_DIRS,
     
    359367static bool rewrite_ForceCRLF(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
    360368static bool rewrite_AdjustTrailingLines(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
     369static bool rewrite_SvnNoExecutable(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
     370static bool rewrite_SvnKeywords(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
    361371static bool rewrite_Makefile_kup(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
    362372static bool rewrite_Makefile_kmk(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings);
     
    389399    /* .fOnlySvnDirs = */           false,
    390400    /* .fSetSvnEol = */             false,
     401    /* .fSetSvnExecutable = */      false,
     402    /* .fSetSvnKeywords = */        false,
    391403    /* .cchTab = */                 8,
    392404    /* .pszFilterFiles = */         (char *)"",
     
    416428    { "--set-svn-eol",                      SCMOPT_SET_SVN_EOL,                     RTGETOPT_REQ_NOTHING },
    417429    { "--dont-set-svn-eol",                 SCMOPT_DONT_SET_SVN_EOL,                RTGETOPT_REQ_NOTHING },
     430    { "--set-svn-executable",               SCMOPT_SET_SVN_EXECUTABLE,              RTGETOPT_REQ_NOTHING },
     431    { "--dont-set-svn-executable",          SCMOPT_DONT_SET_SVN_EXECUTABLE,         RTGETOPT_REQ_NOTHING },
     432    { "--set-svn-keywords",                 SCMOPT_SET_SVN_KEYWORDS,                RTGETOPT_REQ_NOTHING },
     433    { "--dont-set-svn-keywords",            SCMOPT_DONT_SET_SVN_KEYWORDS,           RTGETOPT_REQ_NOTHING },
    418434    { "--tab-size",                         SCMOPT_TAB_SIZE,                        RTGETOPT_REQ_UINT8   },
    419435    { "--filter-out-dirs",                  SCMOPT_FILTER_OUT_DIRS,                 RTGETOPT_REQ_STRING  },
     
    427443static PFNSCMREWRITER const g_aRewritersFor_Makefile_kup[] =
    428444{
     445    rewrite_SvnNoExecutable,
    429446    rewrite_Makefile_kup
    430447};
     
    435452    rewrite_StripTrailingBlanks,
    436453    rewrite_AdjustTrailingLines,
     454    rewrite_SvnNoExecutable,
     455    rewrite_SvnKeywords,
    437456    rewrite_Makefile_kmk
    438457};
     
    444463    rewrite_StripTrailingBlanks,
    445464    rewrite_AdjustTrailingLines,
     465    rewrite_SvnNoExecutable,
     466    rewrite_SvnKeywords,
    446467    rewrite_C_and_CPP
    447468};
    448469
    449 static PFNSCMREWRITER const g_aRewritersFor_RC[] =
     470static PFNSCMREWRITER const g_aRewritersFor_H_and_HPP[] =
    450471{
    451472    rewrite_ForceNativeEol,
    452473    rewrite_ExpandTabs,
    453474    rewrite_StripTrailingBlanks,
    454     rewrite_AdjustTrailingLines
     475    rewrite_AdjustTrailingLines,
     476    rewrite_SvnNoExecutable,
     477    rewrite_C_and_CPP
     478};
     479
     480static PFNSCMREWRITER const g_aRewritersFor_RC[] =
     481{
     482    rewrite_ForceNativeEol,
     483    rewrite_ExpandTabs,
     484    rewrite_StripTrailingBlanks,
     485    rewrite_AdjustTrailingLines,
     486    rewrite_SvnNoExecutable,
     487    rewrite_SvnKeywords
    455488};
    456489
     
    472505{
    473506    { RT_ELEMENTS(g_aRewritersFor_Makefile_kup), &g_aRewritersFor_Makefile_kup[0], "Makefile.kup" },
    474     { RT_ELEMENTS(g_aRewritersFor_Makefile_kmk), &g_aRewritersFor_Makefile_kmk[0], "Makefile.kmk" },
    475     { RT_ELEMENTS(g_aRewritersFor_C_and_CPP),    &g_aRewritersFor_C_and_CPP[0],    "*.c|*.h|*.cpp|*.hpp|*.C|*.CPP|*.cxx|*.cc" },
     507    { RT_ELEMENTS(g_aRewritersFor_Makefile_kmk), &g_aRewritersFor_Makefile_kmk[0], "Makefile.kmk|Config.kmk" },
     508    { RT_ELEMENTS(g_aRewritersFor_C_and_CPP),    &g_aRewritersFor_C_and_CPP[0],    "*.c|*.cpp|*.C|*.CPP|*.cxx|*.cc" },
     509    { RT_ELEMENTS(g_aRewritersFor_H_and_HPP),    &g_aRewritersFor_H_and_HPP[0],    "*.h|*.hpp" },
    476510    { RT_ELEMENTS(g_aRewritersFor_RC),           &g_aRewritersFor_RC[0],           "*.rc" },
    477511    { RT_ELEMENTS(g_aRewritersFor_ShellScripts), &g_aRewritersFor_ShellScripts[0], "*.sh|configure" },
     
    20242058            return VINF_SUCCESS;
    20252059        case SCMOPT_DONT_SET_SVN_EOL:
     2060            pSettings->fSetSvnEol = false;
     2061            return VINF_SUCCESS;
     2062
     2063        case SCMOPT_SET_SVN_EXECUTABLE:
     2064            pSettings->fSetSvnExecutable = true;
     2065            return VINF_SUCCESS;
     2066        case SCMOPT_DONT_SET_SVN_EXECUTABLE:
     2067            pSettings->fSetSvnExecutable = false;
     2068            return VINF_SUCCESS;
     2069
     2070        case SCMOPT_SET_SVN_KEYWORDS:
     2071            pSettings->fSetSvnKeywords = true;
     2072            return VINF_SUCCESS;
     2073        case SCMOPT_DONT_SET_SVN_KEYWORDS:
     2074            pSettings->fSetSvnKeywords = false;
    20262075            return VINF_SUCCESS;
    20272076
     
    32113260        {
    32123261            if (rc == VERR_NOT_FOUND)
    3213                 ScmVerbose(pState, 2, " * Settings svn:eol-style to %s (missing)\n", pszDesiredSvnEol);
     3262                ScmVerbose(pState, 2, " * Setting svn:eol-style to %s (missing)\n", pszDesiredSvnEol);
    32143263            else
    3215                 ScmVerbose(pState, 2, " * Settings svn:eol-style to %s (was: %s)\n", pszDesiredSvnEol, pszEol);
    3216             rc = scmSvnSetProperty(pState, "svn:eol-style", pszDesiredSvnEol);
    3217             if (RT_FAILURE(rc))
    3218                 RTMsgError("scmSvnSetProperty: %Rrc\n", rc); /** @todo propagate the error somehow... */
    3219         }
     3264                ScmVerbose(pState, 2, " * Setting svn:eol-style to %s (was: %s)\n", pszDesiredSvnEol, pszEol);
     3265            int rc2 = scmSvnSetProperty(pState, "svn:eol-style", pszDesiredSvnEol);
     3266            if (RT_FAILURE(rc2))
     3267                RTMsgError("scmSvnSetProperty: %Rrc\n", rc2); /** @todo propagate the error somehow... */
     3268        }
     3269        if (RT_SUCCESS(rc))
     3270            RTStrFree(pszEol);
    32203271    }
    32213272
     
    33353386    ScmVerbose(pState, 2, " * Adjusted trailing blank lines\n");
    33363387    return true;
     3388}
     3389
     3390/**
     3391 * Make sure there is no svn:executable keyword on the current file.
     3392 *
     3393 * @returns false - the state carries these kinds of changes.
     3394 * @param   pState              The rewriter state.
     3395 * @param   pIn                 The input stream.
     3396 * @param   pOut                The output stream.
     3397 * @param   pSettings           The settings.
     3398 */
     3399static bool rewrite_SvnNoExecutable(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
     3400{
     3401    if (   !pSettings->fSetSvnExecutable
     3402        || !scmSvnIsInWorkingCopy(pState))
     3403        return false;
     3404
     3405    int rc = scmSvnQueryProperty(pState, "svn:executable", NULL);
     3406    if (RT_SUCCESS(rc))
     3407    {
     3408        ScmVerbose(pState, 2, " * removing svn:executable\n");
     3409        rc = scmSvnDelProperty(pState, "svn:executable");
     3410        if (RT_FAILURE(rc))
     3411            RTMsgError("scmSvnSetProperty: %Rrc\n", rc); /** @todo error propagation here.. */
     3412    }
     3413    return false;
     3414}
     3415
     3416/**
     3417 * Make sure the Id and Revision keywords are expanded.
     3418 *
     3419 * @returns false - the state carries these kinds of changes.
     3420 * @param   pState              The rewriter state.
     3421 * @param   pIn                 The input stream.
     3422 * @param   pOut                The output stream.
     3423 * @param   pSettings           The settings.
     3424 */
     3425static bool rewrite_SvnKeywords(PSCMRWSTATE pState, PSCMSTREAM pIn, PSCMSTREAM pOut, PCSCMSETTINGSBASE pSettings)
     3426{
     3427    if (   !pSettings->fSetSvnKeywords
     3428        || !scmSvnIsInWorkingCopy(pState))
     3429        return false;
     3430
     3431    char *pszKeywords;
     3432    int rc = scmSvnQueryProperty(pState, "svn:keywords", &pszKeywords);
     3433    if (    RT_SUCCESS(rc)
     3434        && (   !strstr(pszKeywords, "Id") /** @todo need some function for finding a word in a string.  */
     3435            || !strstr(pszKeywords, "Revision")) )
     3436    {
     3437        if (!strstr(pszKeywords, "Id") && !strstr(pszKeywords, "Revision"))
     3438            rc = RTStrAAppend(&pszKeywords, " Id Revision");
     3439        else if (!strstr(pszKeywords, "Id"))
     3440            rc = RTStrAAppend(&pszKeywords, " Id");
     3441        else
     3442            rc = RTStrAAppend(&pszKeywords, " Revision");
     3443        if (RT_SUCCESS(rc))
     3444        {
     3445            ScmVerbose(pState, 2, " * changing svn:keywords to '%s'\n", pszKeywords);
     3446            rc = scmSvnSetProperty(pState, "svn:keywords", pszKeywords);
     3447            if (RT_FAILURE(rc))
     3448                RTMsgError("scmSvnSetProperty: %Rrc\n", rc); /** @todo error propagation here.. */
     3449        }
     3450        else
     3451            RTMsgError("RTStrAppend: %Rrc\n", rc); /** @todo error propagation here.. */
     3452        RTStrFree(pszKeywords);
     3453    }
     3454    else if (rc == VERR_NOT_FOUND)
     3455    {
     3456        ScmVerbose(pState, 2, " * setting svn:keywords to 'Id Revision'\n");
     3457        rc = scmSvnSetProperty(pState, "svn:keywords", "Id Revision");
     3458        if (RT_FAILURE(rc))
     3459            RTMsgError("scmSvnSetProperty: %Rrc\n", rc); /** @todo error propagation here.. */
     3460    }
     3461    else if (RT_SUCCESS(rc))
     3462        RTStrFree(pszKeywords);
     3463
     3464    return false;
    33373465}
    33383466
     
    35443672                                ScmDiffStreams(pszFilename, &Stream1, pIn, g_fDiffIgnoreEol, g_fDiffIgnoreLeadingWS,
    35453673                                               g_fDiffIgnoreTrailingWS, g_fDiffSpecialChars, pBaseSettings->cchTab, g_pStdOut);
    3546                                 ScmVerbose(pState, 3, "would have modified the file \"%s%s\"\n", pszFilename, g_pszChangedSuff);
    3547                                 scmSvnDisplayChanges(pState);
     3674                                ScmVerbose(pState, 2, "would have modified the file \"%s%s\"\n", pszFilename, g_pszChangedSuff);
    35483675                            }
    35493676                        }
     
    39524079                        case SCMOPT_ONLY_SVN_DIRS:          RTPrintf("      Default: %RTbool\n", g_Defaults.fOnlySvnDirs); break;
    39534080                        case SCMOPT_ONLY_SVN_FILES:         RTPrintf("      Default: %RTbool\n", g_Defaults.fOnlySvnFiles); break;
     4081                        case SCMOPT_SET_SVN_EOL:            RTPrintf("      Default: %RTbool\n", g_Defaults.fSetSvnEol); break;
     4082                        case SCMOPT_SET_SVN_EXECUTABLE:     RTPrintf("      Default: %RTbool\n", g_Defaults.fSetSvnExecutable); break;
     4083                        case SCMOPT_SET_SVN_KEYWORDS:       RTPrintf("      Default: %RTbool\n", g_Defaults.fSetSvnKeywords); break;
    39544084                        case SCMOPT_TAB_SIZE:               RTPrintf("      Default: %u\n", g_Defaults.cchTab); break;
    39554085                        case SCMOPT_FILTER_OUT_DIRS:        RTPrintf("      Default: %s\n", g_Defaults.pszFilterOutDirs); break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette