hgkw/keyword.py
changeset 296 869b16d09eec
parent 293 a7d568671575
child 297 9e29992343a1
equal deleted inserted replaced
294:343c5dd8dcda 296:869b16d09eec
   439             wlock = lock = None
   439             wlock = lock = None
   440             try:
   440             try:
   441                 wlock = self.wlock()
   441                 wlock = self.wlock()
   442                 lock = self.lock()
   442                 lock = self.lock()
   443                 # store and postpone commit hooks
   443                 # store and postpone commit hooks
   444                 # store parents for commit hook environment
       
   445                 commithooks = []
   444                 commithooks = []
   446                 xp1, xp2 = p1, p2
       
   447                 for name, cmd in ui.configitems('hooks'):
   445                 for name, cmd in ui.configitems('hooks'):
   448                     if name.split('.', 1)[0] == 'commit':
   446                     if name.split('.', 1)[0] == 'commit':
   449                         commithooks.append((name, cmd))
   447                         commithooks.append((name, cmd))
   450                         ui.setconfig('hooks', name, '')
   448                         ui.setconfig('hooks', name, '')
   451                 if commithooks:
   449                 if commithooks:
   452                     if xp1 is None:
   450                     # store parents for commit hook environment
   453                         xp1, xp2 = repo.dirstate.parents()
   451                     if p1 is None:
   454                     elif not xp2:
   452                         _p1, _p2 = repo.dirstate.parents()
   455                         xp2 = nullid
       
   456                     xp1 = hex(xp1)
       
   457                     if xp2 == nullid:
       
   458                         xp2 = ''
       
   459                     else:
   453                     else:
   460                         xp2 = hex(xp2)
   454                         _p1, _p2 = p1, p2 or nullid
   461 
   455 
   462                 node = super(kwrepo,
   456                 node = super(kwrepo,
   463                              self).commit(files=files, text=text, user=user,
   457                              self).commit(files=files, text=text, user=user,
   464                                           date=date, match=match, force=force,
   458                                           date=date, match=match, force=force,
   465                                           force_editor=force_editor,
   459                                           force_editor=force_editor,
   471                                   and _iskwfile(ui, mn, f)]
   465                                   and _iskwfile(ui, mn, f)]
   472                     if candidates:
   466                     if candidates:
   473                         # 6th, 7th arguments set expansion, commit to True
   467                         # 6th, 7th arguments set expansion, commit to True
   474                         _overwrite(ui, self, candidates, node, mn, True, True)
   468                         _overwrite(ui, self, candidates, node, mn, True, True)
   475 
   469 
   476                 # restore commit hooks and run them
   470                 if commithooks:
   477                 for name, cmd in commithooks:
   471                     # restore commit hooks and run them
   478                     ui.setconfig('hooks', name, cmd)
   472                     for name, cmd in commithooks:
   479                 repo.hook('commit', node=node, parent1=xp1, parent2=xp2)
   473                         ui.setconfig('hooks', name, cmd)
       
   474                     xp1 = hex(_p1)
       
   475                     if _p2 == nullid:
       
   476                         xp2 = ''
       
   477                     else:
       
   478                         xp2 = hex(_p2)
       
   479                     repo.hook('commit', node=node, parent1=xp1, parent2=xp2)
   480                 return node
   480                 return node
   481             finally:
   481             finally:
   482                 del wlock, lock
   482                 del wlock, lock
   483 
   483 
   484     repo.__class__ = kwrepo
   484     repo.__class__ = kwrepo