list_changes.py (11922:0b284e4322fc) list_changes.py (12256:a100657644ee)
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
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(upstream, branch):
109 """Get a generator that lists git revisions that exist in 'branch' but
110 not in 'upstream'.
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.
111
112 Returns: Generator of Commit objects
113
114 """
115
112
113 Returns: Generator of Commit objects
114
115 """
116
116 changes = subprocess.check_output(
117 [ "git", "rev-list", "%s..%s" % (upstream, branch) ])
117 if baseline is not None:
118 query = "%s..%s" % (branch, baseline)
119 else:
120 query = str(branch)
118
121
122 changes = subprocess.check_output([ "git", "rev-list", query ])
123
119 if changes == "":
120 return
121
122 for rev in changes.rstrip("\n").split("\n"):
123 assert rev != ""
124 yield Commit(rev)
125
126def list_changes(upstream, feature):

--- 33 unchanged lines hidden (view full) ---

160 "Default: %(default)s")
161 parser.add_argument("--feature", "-f", type=str, default="HEAD",
162 help="Feature branch for comparison. " \
163 "Default: %(default)s")
164 parser.add_argument("--show-unknown", action="store_true",
165 help="Print changes without Change-Id tags")
166 parser.add_argument("--show-common", action="store_true",
167 help="Print common changes")
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")
168
169 args = parser.parse_args()
170
171 incoming, outgoing, common, upstream_unknown, feature_unknown = \
172 list_changes(args.upstream, args.feature)
173
174 if incoming:
175 print "Incoming changes:"

--- 19 unchanged lines hidden (view full) ---

195 print rev
196 print
197
198 if args.show_unknown and feature_unknown:
199 print "Outgoing changes without change IDs:"
200 for rev in feature_unknown:
201 print rev
202
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
203
204
222
223
224
225
205if __name__ == "__main__":
206 _main()
226if __name__ == "__main__":
227 _main()