##// END OF EJS Templates
phabricator: finding old nodes in batch...
Jun Wu -
r33442:3ab0d576 default
parent child Browse files
Show More
@@ -139,8 +139,12 b' def getrepophid(repo):'
139 139 _differentialrevisiondescre = re.compile(
140 140 '^Differential Revision:.*D([1-9][0-9]*)$', re.M)
141 141
142 def getmapping(ctx):
143 """return (node, associated Differential Revision ID) or (None, None)
142 def getoldnodedrevmap(repo, nodelist):
143 """find previous nodes that has been sent to Phabricator
144
145 return {node: (oldnode or None, Differential Revision ID)}
146 for node in nodelist with known previous sent versions, or associated
147 Differential Revision IDs.
144 148
145 149 Examines all precursors and their tags. Tags with format like "D1234" are
146 150 considered a match and the node with that tag, and the number after "D"
@@ -149,23 +153,28 b' def getmapping(ctx):'
149 153 If tags are not found, examine commit message. The "Differential Revision:"
150 154 line could associate this changeset to a Differential Revision.
151 155 """
152 unfi = ctx.repo().unfiltered()
156 url, token = readurltoken(repo)
157 unfi = repo.unfiltered()
153 158 nodemap = unfi.changelog.nodemap
154 159
155 # Check tags like "D123"
156 for n in obsolete.allprecursors(unfi.obsstore, [ctx.node()]):
157 if n in nodemap:
158 for tag in unfi.nodetags(n):
159 m = _differentialrevisiontagre.match(tag)
160 if m:
161 return n, int(m.group(1))
160 result = {} # {node: (oldnode or None, drev)}
161 for node in nodelist:
162 ctx = unfi[node]
163 # Check tags like "D123"
164 for n in obsolete.allprecursors(unfi.obsstore, [node]):
165 if n in nodemap:
166 for tag in unfi.nodetags(n):
167 m = _differentialrevisiontagre.match(tag)
168 if m:
169 result[node] = (n, int(m.group(1)))
170 continue
162 171
163 # Check commit message
164 m = _differentialrevisiondescre.search(ctx.description())
165 if m:
166 return None, int(m.group(1))
172 # Check commit message
173 m = _differentialrevisiondescre.search(ctx.description())
174 if m:
175 result[node] = (None, int(m.group(1)))
167 176
168 return None, None
177 return result
169 178
170 179 def getdiff(ctx, diffopts):
171 180 """plain-text diff without header (user, commit message, etc)"""
@@ -274,6 +283,8 b' def phabsend(ui, repo, *revs, **opts):'
274 283 if not revs:
275 284 raise error.Abort(_('phabsend requires at least one changeset'))
276 285
286 oldnodedrev = getoldnodedrevmap(repo, [repo[r].node() for r in revs])
287
277 288 # Send patches one by one so we know their Differential Revision IDs and
278 289 # can provide dependency relationship
279 290 lastrevid = None
@@ -282,7 +293,7 b' def phabsend(ui, repo, *revs, **opts):'
282 293 ctx = repo[rev]
283 294
284 295 # Get Differential Revision ID
285 oldnode, revid = getmapping(ctx)
296 oldnode, revid = oldnodedrev.get(ctx.node(), (None, None))
286 297 if oldnode != ctx.node():
287 298 # Create or update Differential Revision
288 299 revision = createdifferentialrevision(ctx, revid, lastrevid,
General Comments 0
You need to be logged in to leave comments. Login now