Path: blob/main/release/scripts/list-new-changesets.py
34677 views
#!/usr/bin/env python1#2# Copyright (c) 2014, Craig Rodrigues <[email protected]>3# All rights reserved.4#5# Redistribution and use in source and binary forms, with or without6# modification, are permitted provided that the following conditions7# are met:8# 1. Redistributions of source code must retain the above copyright9# notice unmodified, this list of conditions, and the following10# disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR16# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES17# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.18# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,19# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT20# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,21# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY22# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT23# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF24# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.25#2627# Display SVN log entries for changesets which have files which were28# Added or Deleted.29# This script takes arguments which would normally be30# passed to the "svn log" command.31#32# Examples:33#34# (1) Display all new changesets in stable/10 branch:35#36# list-new-changesets.py --stop-on-copy \37# svn://svn.freebsd.org/base/stable/1038#39# (2) Display all new changesets between r254153 and r261794 in40# stable/9 branch:41#42# list-new-changesets.py -r254153:261794 \43# svn://svn.freebsd.org/base/stable/94445from __future__ import print_function46import os47import subprocess48import sys49import xml.etree.ElementTree5051def print_logentry(logentry):52"""Print an SVN log entry.5354Take an SVN log entry formatted in XML, and print it out in55plain text.56"""57rev = logentry.attrib['revision']58author = logentry.find('author').text59date = logentry.find('date').text60msg = logentry.find('msg').text6162print("-" * 71)63print("%s | %s | %s" % (rev, author, date))64print("Changed paths:")65for paths in logentry.findall('paths'):66for path in paths.findall('path'):67print(" %s %s" % (path.attrib['action'], path.text))6869print()70print(msg.encode('utf-8'))7172def main(args):73"""Main function.7475Take command-line arguments which would be passed to 'svn log'.76Prepend '-v --xml' to get verbose XML formatted output.77Only display entries which have Added or Deleted files.78"""79cmd = ["svn", "log", "-v", "--xml"]80cmd += args[1:]8182print(" ".join(cmd))8384proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)85(out, err) = proc.communicate()8687if proc.returncode != 0:88print(err)89sys.exit(proc.returncode)9091displayed_entries = 092root = xml.etree.ElementTree.fromstring(out)9394for logentry in root.findall('logentry'):95show_logentry = False9697for paths in logentry.findall('paths'):98for path in paths.findall('path'):99if path.attrib['action'] == 'A':100show_logentry = True101elif path.attrib['action'] == 'D':102show_logentry = True103104if show_logentry == True :105print_logentry(logentry)106displayed_entries += 1107108if displayed_entries == 0:109print("No changesets with Added or Deleted files")110111if displayed_entries > 0:112print("-" * 71)113114115if __name__ == "__main__":116main(sys.argv)117118119