contrib/phabricator.py
changeset 35626 a0d33f4ddff9
parent 34064 8b659b7388c0
child 35722 f18ba40d792f
equal deleted inserted replaced
35625:390f860228ba 35626:a0d33f4ddff9
   164     repo.ui.setconfig('phabricator', 'repophid', repophid)
   164     repo.ui.setconfig('phabricator', 'repophid', repophid)
   165     return repophid
   165     return repophid
   166 
   166 
   167 _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
   167 _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z')
   168 _differentialrevisiondescre = re.compile(
   168 _differentialrevisiondescre = re.compile(
   169     '^Differential Revision:\s*(?:.*)D([1-9][0-9]*)$', re.M)
   169     '^Differential Revision:\s*(?P<url>(?:.*)D(?P<id>[1-9][0-9]*))$', re.M)
   170 
   170 
   171 def getoldnodedrevmap(repo, nodelist):
   171 def getoldnodedrevmap(repo, nodelist):
   172     """find previous nodes that has been sent to Phabricator
   172     """find previous nodes that has been sent to Phabricator
   173 
   173 
   174     return {node: (oldnode, Differential diff, Differential Revision ID)}
   174     return {node: (oldnode, Differential diff, Differential Revision ID)}
   205                         continue
   205                         continue
   206 
   206 
   207         # Check commit message
   207         # Check commit message
   208         m = _differentialrevisiondescre.search(ctx.description())
   208         m = _differentialrevisiondescre.search(ctx.description())
   209         if m:
   209         if m:
   210             toconfirm[node] = (1, set(precnodes), int(m.group(1)))
   210             toconfirm[node] = (1, set(precnodes), int(m.group('id')))
   211 
   211 
   212     # Double check if tags are genuine by collecting all old nodes from
   212     # Double check if tags are genuine by collecting all old nodes from
   213     # Phabricator, and expect precursors overlap with it.
   213     # Phabricator, and expect precursors overlap with it.
   214     if toconfirm:
   214     if toconfirm:
   215         drevs = [drev for force, precs, drev in toconfirm.values()]
   215         drevs = [drev for force, precs, drev in toconfirm.values()]
   440                 action = 'created'
   440                 action = 'created'
   441 
   441 
   442             # Create a local tag to note the association, if commit message
   442             # Create a local tag to note the association, if commit message
   443             # does not have it already
   443             # does not have it already
   444             m = _differentialrevisiondescre.search(ctx.description())
   444             m = _differentialrevisiondescre.search(ctx.description())
   445             if not m or int(m.group(1)) != newrevid:
   445             if not m or int(m.group('id')) != newrevid:
   446                 tagname = 'D%d' % newrevid
   446                 tagname = 'D%d' % newrevid
   447                 tags.tag(repo, tagname, ctx.node(), message=None, user=None,
   447                 tags.tag(repo, tagname, ctx.node(), message=None, user=None,
   448                          date=None, local=True)
   448                          date=None, local=True)
   449         else:
   449         else:
   450             # Nothing changed. But still set "newrevid" so the next revision
   450             # Nothing changed. But still set "newrevid" so the next revision