list_changes.py (12256:a100657644ee) | list_changes.py (12447:abcca2211632) |
---|---|
1#!/usr/bin/env python2 2# | 1#!/usr/bin/env python2 2# |
3# Copyright (c) 2017 ARM Limited | 3# Copyright (c) 2017-2018 Arm Limited |
4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating 9# to a hardware implementation of the functionality of the software 10# licensed hereunder. You may use the software subject to the license 11# terms below provided that you ensure that this notice is replicated --- 88 unchanged lines hidden (view full) --- 100 return None 101 102 assert len(cids) == 1 103 return cids[0] 104 105 def __str__(self): 106 return "%s: %s" % (self.rev[0:8], self.log[0]) 107 | 4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating 9# to a hardware implementation of the functionality of the software 10# licensed hereunder. You may use the software subject to the license 11# terms below provided that you ensure that this notice is replicated --- 88 unchanged lines hidden (view full) --- 100 return None 101 102 assert len(cids) == 1 103 return cids[0] 104 105 def __str__(self): 106 return "%s: %s" % (self.rev[0:8], self.log[0]) 107 |
108def list_revs(branch, baseline=None): | 108def list_revs(branch, baseline=None, paths=[]): |
109 """Get a generator that lists git revisions that exist in 'branch'. If 110 the optional parameter 'baseline' is specified, the generator 111 excludes commits that exist on that branch. 112 113 Returns: Generator of Commit objects 114 115 """ 116 117 if baseline is not None: 118 query = "%s..%s" % (branch, baseline) 119 else: 120 query = str(branch) 121 | 109 """Get a generator that lists git revisions that exist in 'branch'. If 110 the optional parameter 'baseline' is specified, the generator 111 excludes commits that exist on that branch. 112 113 Returns: Generator of Commit objects 114 115 """ 116 117 if baseline is not None: 118 query = "%s..%s" % (branch, baseline) 119 else: 120 query = str(branch) 121 |
122 changes = subprocess.check_output([ "git", "rev-list", query ]) | 122 changes = subprocess.check_output( 123 [ "git", "rev-list", query, '--'] + paths 124 ) |
123 124 if changes == "": 125 return 126 127 for rev in changes.rstrip("\n").split("\n"): 128 assert rev != "" 129 yield Commit(rev) 130 | 125 126 if changes == "": 127 return 128 129 for rev in changes.rstrip("\n").split("\n"): 130 assert rev != "" 131 yield Commit(rev) 132 |
131def list_changes(upstream, feature): 132 feature_revs = tuple(list_revs(upstream, feature)) 133 upstream_revs = tuple(list_revs(feature, upstream)) | 133def list_changes(upstream, feature, paths=[]): 134 feature_revs = tuple(list_revs(upstream, feature, paths=paths)) 135 upstream_revs = tuple(list_revs(feature, upstream, paths=paths)) |
134 135 feature_cids = dict([ 136 (c.change_id, c) for c in feature_revs if c.change_id is not None ]) 137 upstream_cids = dict([ 138 (c.change_id, c) for c in upstream_revs if c.change_id is not None ]) 139 140 incoming = filter( 141 lambda r: r.change_id and r.change_id not in feature_cids, --- 26 unchanged lines hidden (view full) --- 168 "Default: %(default)s") 169 parser.add_argument("--show-unknown", action="store_true", 170 help="Print changes without Change-Id tags") 171 parser.add_argument("--show-common", action="store_true", 172 help="Print common changes") 173 parser.add_argument("--deep-search", action="store_true", 174 help="Use a deep search to find incorrectly " \ 175 "rebased changes") | 136 137 feature_cids = dict([ 138 (c.change_id, c) for c in feature_revs if c.change_id is not None ]) 139 upstream_cids = dict([ 140 (c.change_id, c) for c in upstream_revs if c.change_id is not None ]) 141 142 incoming = filter( 143 lambda r: r.change_id and r.change_id not in feature_cids, --- 26 unchanged lines hidden (view full) --- 170 "Default: %(default)s") 171 parser.add_argument("--show-unknown", action="store_true", 172 help="Print changes without Change-Id tags") 173 parser.add_argument("--show-common", action="store_true", 174 help="Print common changes") 175 parser.add_argument("--deep-search", action="store_true", 176 help="Use a deep search to find incorrectly " \ 177 "rebased changes") |
178 parser.add_argument("paths", metavar="PATH", type=str, nargs="*", 179 help="Paths to list changes for") |
|
176 177 args = parser.parse_args() 178 179 incoming, outgoing, common, upstream_unknown, feature_unknown = \ | 180 181 args = parser.parse_args() 182 183 incoming, outgoing, common, upstream_unknown, feature_unknown = \ |
180 list_changes(args.upstream, args.feature) | 184 list_changes(args.upstream, args.feature, paths=args.paths) |
181 182 if incoming: 183 print "Incoming changes:" 184 for rev in incoming: 185 print rev 186 print 187 188 if args.show_unknown and upstream_unknown: --- 16 unchanged lines hidden (view full) --- 205 206 if args.show_unknown and feature_unknown: 207 print "Outgoing changes without change IDs:" 208 for rev in feature_unknown: 209 print rev 210 211 if args.deep_search: 212 print "Incorrectly rebased changes:" | 185 186 if incoming: 187 print "Incoming changes:" 188 for rev in incoming: 189 print rev 190 print 191 192 if args.show_unknown and upstream_unknown: --- 16 unchanged lines hidden (view full) --- 209 210 if args.show_unknown and feature_unknown: 211 print "Outgoing changes without change IDs:" 212 for rev in feature_unknown: 213 print rev 214 215 if args.deep_search: 216 print "Incorrectly rebased changes:" |
213 all_upstream_revs = list_revs(args.upstream) | 217 all_upstream_revs = list_revs(args.upstream, paths=args.paths) |
214 all_upstream_cids = dict([ 215 (c.change_id, c) for c in all_upstream_revs \ 216 if c.change_id is not None ]) 217 incorrect_outgoing = filter( 218 lambda r: r.change_id in all_upstream_cids, 219 outgoing) 220 for rev in incorrect_outgoing: 221 print rev 222 223 224 225 226if __name__ == "__main__": 227 _main() | 218 all_upstream_cids = dict([ 219 (c.change_id, c) for c in all_upstream_revs \ 220 if c.change_id is not None ]) 221 incorrect_outgoing = filter( 222 lambda r: r.change_id in all_upstream_cids, 223 outgoing) 224 for rev in incorrect_outgoing: 225 print rev 226 227 228 229 230if __name__ == "__main__": 231 _main() |