查找使用svn检查更改的模块

时间:2013-02-14 13:18:26

标签: python perl parsing svn shell

我有一个多模块maven项目。

Project
    -Module1
    -Module2
    -Module3
    -Module4
    -Module5

我想根据修订号找到要检入文件的模块。

我知道svn log -v -r12345 -r12346 svn://repo-path.com/project将获取更改路径的日志,但我只想要模块名称。

例如:来自我想要的以下日志

------------------------------------------------------------------------
r12345 | debajyoti.das@email.com | 2013-02-06 01:40:23 -0800 (Wed, 06 Feb 2013) | 1 line
Changed paths:
   M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/NamedExtensionPoint.java
   M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/PrePostExtensionPoint.java
   M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/helper/ExtensionConfigurationHelper.java
   M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/DocumentGeneratorExt.java
   M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/NamedExtensionPoint.java
   M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/SystemDateBll.java

BUG 12345678 - BLAH IMPLEMENTATION
------------------------------------------------------------------------
r12346 | debajyoti.das@email.com | 2013-02-06 01:40:23 -0800 (Wed, 06 Feb 2013) | 1 line
Changed paths:
   M /MODULE/CYCLE/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/FileCycle1.java
   M /MODULE/CYCLE/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/FileCycle2.java

BUG 12345679 - BLAH IMPLEMENTATION 
------------------------------------------------------------------------

我希望PROJECT.SHAREDPROJECT.SREMODULE.CYCLE可能会在日志文件中被选中,以便稍后在构建过程中使用它们。

当我想手动传递多个修订号并生成通过svn检查更改的模块列表时,我该怎么做呢。

1 个答案:

答案 0 :(得分:2)

三个单独的任务:

  1. 正确调用svn以创建日志
  2. 解析日志
  3. 将解析后的值写入某处
  4. 1

    import subprocess as sp
    
    svn_url = "svn://repo-path.com/project"
    revisions = [12345, 12346]
    revision_clargs = ["-r%i" % revision for revision in revisions]
    popen = sp.Popen(["svn", "log", "-v"] + revision_clargs + [svn_url],stdout=sp.PIPE,stderr=sp.PIPE)
    out,err = popen.communicate()
    

    2

    input_ = """
    ------------------------------------------------------------------------
    r12345 | debajyoti.das@email.com | 2013-02-06 01:40:23 -0800 (Wed, 06 Feb 2013) | 1 line
    Changed paths:
       M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/NamedExtensionPoint.java
       M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/PrePostExtensionPoint.java
       M /PROJECT/SHARED/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/helper/ExtensionConfigurationHelper.java
       M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/DocumentGeneratorExt.java
       M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/NamedExtensionPoint.java
       M /PROJECT/SRE/branches/DEV_Branch/ext/src/main/java/com/companyname/ext/SystemDateBll.java
    
    BUG 12345678 - BLAH IMPLEMENTATION
    ------------------------------------------------------------------------
    r12346 | debajyoti.das@email.com | 2013-02-06 01:40:23 -0800 (Wed, 06 Feb 2013) | 1 line
    Changed paths:
       M /MODULE/CYCLE/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/FileCycle1.java
       M /MODULE/CYCLE/branches/DEV_Branch/extensibility/src/main/java/com/companyname/extensibility/FileCycle2.java
    
    BUG 12345679 - BLAH IMPLEMENTATION 
    ------------------------------------------------------------------------
    """
    
    modified_prefix = "   M "
    
    projects = set(map(lambda x: ".".join(x.split("/")[1:3]),
                   filter(lambda x: x.startswith(modified_prefix),
                          (input_.split("\n")))))
    

    3。取决于你想要的......