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
47 from __future__ import print_function
51 import xml.etree.ElementTree
53 def print_logentry(logentry):
54 """Print an SVN log entry.
56 Take an SVN log entry formatted in XML, and print it out in
59 rev = logentry.attrib['revision']
60 author = logentry.find('author').text
61 date = logentry.find('date').text
62 msg = logentry.find('msg').text
65 print("%s | %s | %s" % (rev, author, date))
66 print("Changed paths:")
67 for paths in logentry.findall('paths'):
68 for path in paths.findall('path'):
69 print(" %s %s" % (path.attrib['action'], path.text))
72 print(msg.encode('utf-8'))
77 Take command-line arguments which would be passed to 'svn log'.
78 Prepend '-v --xml' to get verbose XML formatted output.
79 Only display entries which have Added or Deleted files.
81 cmd = ["svn", "log", "-v", "--xml"]
86 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
87 (out, err) = proc.communicate()
89 if proc.returncode != 0:
91 sys.exit(proc.returncode)
94 root = xml.etree.ElementTree.fromstring(out)
96 for logentry in root.findall('logentry'):
99 for paths in logentry.findall('paths'):
100 for path in paths.findall('path'):
101 if path.attrib['action'] == 'A':
103 elif path.attrib['action'] == 'D':
106 if show_logentry == True :
107 print_logentry(logentry)
108 displayed_entries += 1
110 if displayed_entries == 0:
111 print("No changesets with Added or Deleted files")
113 if displayed_entries > 0:
117 if __name__ == "__main__":