3 # Copyright (c) 2014, Craig Rodrigues <rodrigc@FreeBSD.org>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice unmodified, this list of conditions, and the following
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # Display SVN log entries for changesets which have files which were
31 # This script takes arguments which would normally be
32 # passed to the "svn log" command.
36 # (1) Display all new changesets in stable/10 branch:
38 # list-new-changesets.py --stop-on-copy \
39 # svn://svn.freebsd.org/base/stable/10
41 # (2) Display all new changesets between r254153 and r261794 in
44 # list-new-changesets.py -r254153:261794 \
45 # svn://svn.freebsd.org/base/stable/9
50 import xml.etree.ElementTree
52 def print_logentry(logentry):
53 """Print an SVN log entry.
55 Take an SVN log entry formatted in XML, and print it out in
58 rev = logentry.attrib['revision']
59 author = logentry.find('author').text
60 date = logentry.find('date').text
61 msg = logentry.find('msg').text
64 print "%s | %s | %s" % (rev, author, date)
65 print "Changed paths:"
66 for paths in logentry.findall('paths'):
67 for path in paths.findall('path'):
68 print " %s %s" % (path.attrib['action'], path.text)
71 print msg.encode('utf-8')
76 Take command-line arguments which would be passed to 'svn log'.
77 Prepend '-v --xml' to get verbose XML formatted output.
78 Only display entries which have Added or Deleted files.
80 cmd = ["svn", "log", "-v", "--xml"]
85 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
86 (out, err) = proc.communicate()
88 if proc.returncode != 0:
90 sys.exit(proc.returncode)
93 root = xml.etree.ElementTree.fromstring(out)
95 for logentry in root.findall('logentry'):
98 for paths in logentry.findall('paths'):
99 for path in paths.findall('path'):
100 if path.attrib['action'] == 'A':
102 elif path.attrib['action'] == 'D':
105 if show_logentry == True :
106 print_logentry(logentry)
107 displayed_entries += 1
109 if displayed_entries == 0:
110 print "No changesets with Added or Deleted files"
112 if displayed_entries > 0:
116 if __name__ == "__main__":