[Svnmerge] svnmerge and externals

Ericsson, Lars lars.ericsson at kollmorgen.com
Wed Nov 9 04:56:22 PST 2011


# Hi,
# 
# Below/attached you will find a new version of the check_dir_clean(dir)
function.
# 
# The following notes applies:
# 1) It requires a more modern python compared with current statement
(2.0)
# 2) The launchsvn() method cannot use standard python PIPE since
#    the output may very well exceeded the fixed PIPE buffer size.
# 3) The test criteria "external" for dirty working copy may have to
#    be modified. My test shows that it is ok, but I cannot guarantee
it.
# 
# The first section is just stubs to create the test environment and
# should be removed.
#
# /Lars

import xml.etree.ElementTree as ET
import subprocess
import tempfile

################################################################
# To make the test envornment to work
opts = {"force": False}

def launchsvn(cmd):
    stdout = tempfile.TemporaryFile()
    reply = subprocess.Popen("svn %s" % (cmd), stdout=stdout)
    reply.wait()
    if reply.returncode:
        raise Exception("%s returned error code %d" % (cmd,
reply.returncode))

    stdout.seek(0,0)
    output = stdout.read()
    return output

def report(s):
    print s

def error(s):
    print s
#
################################################################


# new function

def check_dir_clean(dir):
    """Check the current status of dir for local mods."""
    if opts["force"]:
        report('skipping status check because of --force')
        return
    report('checking status of "%s"' % dir)

    # Checking with --xml will produce a more exact result.
    # Any wc-status not "external" indicates a dirty working copy
    reply = launchsvn("status --xml %s" % dir)
    
    svn_st = ET.fromstring(reply)
    changed = [(entry.attrib["path"],
entry.find("wc-status").attrib["item"])
               for entry in svn_st.findall("target/entry")
               if entry.find("wc-status").attrib["item"] not
in("external", "normal")]
    
    # if verbose
    for path,status in changed:
        print ("%s (%s)" %(path, status))

    if changed:
        error('"%s" has local modifications; it must be clean' % dir)
        
check_dir_clean('.')


Please be advised that this email may contain confidential 
information.  If you are not the intended recipient, please notify us 
by email by replying to the sender and delete this message.  The 
sender disclaims that the content of this email constitutes an offer 
to enter into, or the acceptance of, any agreement; provided that the 
foregoing does not invalidate the binding effect of any digital or 
other electronic reproduction of a manual signature that is included 
in any attachment.





More information about the Svnmerge mailing list