hgext/mq.py
changeset 21235 51069bf6366b
parent 21234 b9a16ed5acec
child 21236 49148d7868df
equal deleted inserted replaced
21234:b9a16ed5acec 21235:51069bf6366b
  1506             if inclsubs:
  1506             if inclsubs:
  1507                 substatestate = repo.dirstate['.hgsubstate']
  1507                 substatestate = repo.dirstate['.hgsubstate']
  1508 
  1508 
  1509             ph = patchheader(self.join(patchfn), self.plainmode)
  1509             ph = patchheader(self.join(patchfn), self.plainmode)
  1510             diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
  1510             diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
  1511             if msg:
       
  1512                 ph.setmessage(msg)
       
  1513             if newuser:
  1511             if newuser:
  1514                 ph.setuser(newuser)
  1512                 ph.setuser(newuser)
  1515             if newdate:
  1513             if newdate:
  1516                 ph.setdate(newdate)
  1514                 ph.setdate(newdate)
  1517             ph.setparent(hex(patchparent))
  1515             ph.setparent(hex(patchparent))
  1518 
  1516 
  1519             # only commit new patch when write is complete
  1517             # only commit new patch when write is complete
  1520             patchf = self.opener(patchfn, 'w', atomictemp=True)
  1518             patchf = self.opener(patchfn, 'w', atomictemp=True)
  1521 
       
  1522             comments = str(ph)
       
  1523             if comments:
       
  1524                 patchf.write(comments)
       
  1525 
  1519 
  1526             # update the dirstate in place, strip off the qtip commit
  1520             # update the dirstate in place, strip off the qtip commit
  1527             # and then commit.
  1521             # and then commit.
  1528             #
  1522             #
  1529             # this should really read:
  1523             # this should really read:
  1640                 for f in mm:
  1634                 for f in mm:
  1641                     repo.dirstate.normallookup(f)
  1635                     repo.dirstate.normallookup(f)
  1642                 for f in forget:
  1636                 for f in forget:
  1643                     repo.dirstate.drop(f)
  1637                     repo.dirstate.drop(f)
  1644 
  1638 
  1645                 if not msg:
       
  1646                     if not ph.message:
       
  1647                         message = "[mq]: %s\n" % patchfn
       
  1648                     else:
       
  1649                         message = "\n".join(ph.message)
       
  1650                 else:
       
  1651                     message = msg
       
  1652 
       
  1653                 user = ph.user or changes[1]
  1639                 user = ph.user or changes[1]
  1654 
  1640 
  1655                 oldphase = repo[top].phase()
  1641                 oldphase = repo[top].phase()
  1656 
  1642 
  1657                 # assumes strip can roll itself back if interrupted
  1643                 # assumes strip can roll itself back if interrupted
  1663                 repo.dirstate.invalidate()
  1649                 repo.dirstate.invalidate()
  1664                 raise
  1650                 raise
  1665 
  1651 
  1666             try:
  1652             try:
  1667                 # might be nice to attempt to roll back strip after this
  1653                 # might be nice to attempt to roll back strip after this
       
  1654 
       
  1655                 if not msg:
       
  1656                     if not ph.message:
       
  1657                         message = "[mq]: %s\n" % patchfn
       
  1658                     else:
       
  1659                         message = "\n".join(ph.message)
       
  1660                 else:
       
  1661                     message = msg
       
  1662                     ph.setmessage(msg)
  1668 
  1663 
  1669                 # Ensure we create a new changeset in the same phase than
  1664                 # Ensure we create a new changeset in the same phase than
  1670                 # the old one.
  1665                 # the old one.
  1671                 n = newcommit(repo, oldphase, message, user, ph.date,
  1666                 n = newcommit(repo, oldphase, message, user, ph.date,
  1672                               match=match, force=True)
  1667                               match=match, force=True)
  1674                 c = [list(x) for x in refreshchanges]
  1669                 c = [list(x) for x in refreshchanges]
  1675                 if inclsubs:
  1670                 if inclsubs:
  1676                     self.putsubstate2changes(substatestate, c)
  1671                     self.putsubstate2changes(substatestate, c)
  1677                 chunks = patchmod.diff(repo, patchparent,
  1672                 chunks = patchmod.diff(repo, patchparent,
  1678                                        changes=c, opts=diffopts)
  1673                                        changes=c, opts=diffopts)
       
  1674                 comments = str(ph)
       
  1675                 if comments:
       
  1676                     patchf.write(comments)
  1679                 for chunk in chunks:
  1677                 for chunk in chunks:
  1680                     patchf.write(chunk)
  1678                     patchf.write(chunk)
  1681                 patchf.close()
  1679                 patchf.close()
  1682 
  1680 
  1683                 marks = repo._bookmarks
  1681                 marks = repo._bookmarks