##// END OF EJS Templates
phabricator: check associated Differential Revision from commit message...
Jun Wu -
r33263:ed611897 default
parent child Browse files
Show More
@@ -135,7 +135,9 b' def getrepophid(repo):'
135 135 repo.ui.setconfig('phabricator', 'repophid', repophid)
136 136 return repophid
137 137
138 _differentialrevisionre = re.compile('\AD([1-9][0-9]*)\Z')
138 _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
139 _differentialrevisiondescre = re.compile(
140 '^Differential Revision:.*D([1-9][0-9]*)$', re.M)
139 141
140 142 def getmapping(ctx):
141 143 """return (node, associated Differential Revision ID) or (None, None)
@@ -143,15 +145,26 b' def getmapping(ctx):'
143 145 Examines all precursors and their tags. Tags with format like "D1234" are
144 146 considered a match and the node with that tag, and the number after "D"
145 147 (ex. 1234) will be returned.
148
149 If tags are not found, examine commit message. The "Differential Revision:"
150 line could associate this changeset to a Differential Revision.
146 151 """
147 152 unfi = ctx.repo().unfiltered()
148 153 nodemap = unfi.changelog.nodemap
154
155 # Check tags like "D123"
149 156 for n in obsolete.allprecursors(unfi.obsstore, [ctx.node()]):
150 157 if n in nodemap:
151 158 for tag in unfi.nodetags(n):
152 m = _differentialrevisionre.match(tag)
159 m = _differentialrevisiontagre.match(tag)
153 160 if m:
154 161 return n, int(m.group(1))
162
163 # Check commit message
164 m = _differentialrevisiondescre.search(ctx.description())
165 if m:
166 return None, int(m.group(1))
167
155 168 return None, None
156 169
157 170 def getdiff(ctx, diffopts):
General Comments 0
You need to be logged in to leave comments. Login now