1#!/usr/bin/env python2 2# 3# Copyright (c) 2017 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 --- 91 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): 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 ]) 123 |
124 if changes == "": 125 return 126 127 for rev in changes.rstrip("\n").split("\n"): 128 assert rev != "" 129 yield Commit(rev) 130 131def list_changes(upstream, feature): --- 33 unchanged lines hidden (view full) --- 165 "Default: %(default)s") 166 parser.add_argument("--feature", "-f", type=str, default="HEAD", 167 help="Feature branch for comparison. " \ 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") |
176 177 args = parser.parse_args() 178 179 incoming, outgoing, common, upstream_unknown, feature_unknown = \ 180 list_changes(args.upstream, args.feature) 181 182 if incoming: 183 print "Incoming changes:" --- 19 unchanged lines hidden (view full) --- 203 print rev 204 print 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:" 213 all_upstream_revs = list_revs(args.upstream) 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() |