-3

I have a multi module maven project.

Project
    -Module1
    -Module2
    -Module3
    -Module4
    -Module5

I want to find the modules to which files were checked in based on the revision number.

I know svn log -v -r12345 -r12346 svn://repo-path.com/project will get the log for the changed paths but I want only the module names.

For eg: from the following log I want

------------------------------------------------------------------------
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 
------------------------------------------------------------------------

I want PROJECT.SHARED , PROJECT.SRE and MODULE.CYCLE to be picked up maybe in a log file to use them later for a build process.

How can I do this when I want to manually pass multiple revision numbers and generate the list of modules where changes were checked into via svn.

4

1 回答 1

2

Three separate tasks:

  1. call svn properly to create the log
  2. parse the log
  3. Write the parsed values somewhere

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. Depends on what you want...

于 2013-02-14T13:58:19.057 回答