contrib/phabricator.py
changeset 33564 91e3dcefc9b7
parent 33498 b7a75b9a3386
child 33601 850d2ec2cf6a
equal deleted inserted replaced
33563:da94a99df96b 33564:91e3dcefc9b7
   136     repo.ui.setconfig('phabricator', 'repophid', repophid)
   136     repo.ui.setconfig('phabricator', 'repophid', repophid)
   137     return repophid
   137     return repophid
   138 
   138 
   139 _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
   139 _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
   140 _differentialrevisiondescre = re.compile(
   140 _differentialrevisiondescre = re.compile(
   141     '^Differential Revision:.*D([1-9][0-9]*)$', re.M)
   141     '^Differential Revision:\s*(.*)D([1-9][0-9]*)$', re.M)
   142 
   142 
   143 def getoldnodedrevmap(repo, nodelist):
   143 def getoldnodedrevmap(repo, nodelist):
   144     """find previous nodes that has been sent to Phabricator
   144     """find previous nodes that has been sent to Phabricator
   145 
   145 
   146     return {node: (oldnode or None, Differential Revision ID)}
   146     return {node: (oldnode or None, Differential Revision ID)}
   170                     m = _differentialrevisiontagre.match(tag)
   170                     m = _differentialrevisiontagre.match(tag)
   171                     if m:
   171                     if m:
   172                         toconfirm[node] = (n, set(precnodes), int(m.group(1)))
   172                         toconfirm[node] = (n, set(precnodes), int(m.group(1)))
   173                         continue
   173                         continue
   174 
   174 
   175         # Check commit message
   175         # Check commit message (make sure URL matches)
   176         m = _differentialrevisiondescre.search(ctx.description())
   176         m = _differentialrevisiondescre.search(ctx.description())
   177         if m:
   177         if m:
   178             result[node] = (None, int(m.group(1)))
   178             if m.group(1).rstrip('/') == url.rstrip('/'):
       
   179                 result[node] = (None, int(m.group(2)))
       
   180             else:
       
   181                 unfi.ui.warn(_('%s: Differential Revision URL ignored - host '
       
   182                                'does not match config\n') % ctx)
   179 
   183 
   180     # Double check if tags are genuine by collecting all old nodes from
   184     # Double check if tags are genuine by collecting all old nodes from
   181     # Phabricator, and expect precursors overlap with it.
   185     # Phabricator, and expect precursors overlap with it.
   182     if toconfirm:
   186     if toconfirm:
   183         confirmed = {} # {drev: {oldnode}}
   187         confirmed = {} # {drev: {oldnode}}