##// END OF EJS Templates
phabricator: verify local tags before trusting them...
Jun Wu -
r33443:e48082e0 default
parent child Browse files
Show More
@@ -35,6 +35,7 b' from __future__ import absolute_import'
35 35 import json
36 36 import re
37 37
38 from mercurial.node import bin, nullid
38 39 from mercurial.i18n import _
39 40 from mercurial import (
40 41 encoding,
@@ -158,15 +159,17 b' def getoldnodedrevmap(repo, nodelist):'
158 159 nodemap = unfi.changelog.nodemap
159 160
160 161 result = {} # {node: (oldnode or None, drev)}
162 toconfirm = {} # {node: (oldnode, {precnode}, drev)}
161 163 for node in nodelist:
162 164 ctx = unfi[node]
163 # Check tags like "D123"
164 for n in obsolete.allprecursors(unfi.obsstore, [node]):
165 # For tags like "D123", put them into "toconfirm" to verify later
166 precnodes = list(obsolete.allprecursors(unfi.obsstore, [node]))
167 for n in precnodes:
165 168 if n in nodemap:
166 169 for tag in unfi.nodetags(n):
167 170 m = _differentialrevisiontagre.match(tag)
168 171 if m:
169 result[node] = (n, int(m.group(1)))
172 toconfirm[node] = (n, set(precnodes), int(m.group(1)))
170 173 continue
171 174
172 175 # Check commit message
@@ -174,6 +177,28 b' def getoldnodedrevmap(repo, nodelist):'
174 177 if m:
175 178 result[node] = (None, int(m.group(1)))
176 179
180 # Double check if tags are genuine by collecting all old nodes from
181 # Phabricator, and expect precursors overlap with it.
182 if toconfirm:
183 confirmed = {} # {drev: {oldnode}}
184 drevs = [drev for n, precs, drev in toconfirm.values()]
185 diffs = callconduit(unfi, 'differential.querydiffs',
186 {'revisionIDs': drevs})
187 for diff in diffs.values():
188 drev = int(diff[r'revisionID'])
189 oldnode = bin(encoding.unitolocal(getdiffmeta(diff).get(r'node')))
190 if node:
191 confirmed.setdefault(drev, set()).add(oldnode)
192 for newnode, (oldnode, precset, drev) in toconfirm.items():
193 if bool(precset & confirmed.get(drev, set())):
194 result[newnode] = (oldnode, drev)
195 else:
196 tagname = 'D%d' % drev
197 tags.tag(repo, tagname, nullid, message=None, user=None,
198 date=None, local=True)
199 unfi.ui.warn(_('D%s: local tag removed - does not match '
200 'Differential history\n') % drev)
201
177 202 return result
178 203
179 204 def getdiff(ctx, diffopts):
General Comments 0
You need to be logged in to leave comments. Login now