hgkw/keyword.py
changeset 297 9e29992343a1
parent 296 869b16d09eec
child 298 c8afb99bb70f
equal deleted inserted replaced
296:869b16d09eec 297:9e29992343a1
   435 
   435 
   436         def commit(self, files=None, text='', user=None, date=None,
   436         def commit(self, files=None, text='', user=None, date=None,
   437                    match=util.always, force=False, force_editor=False,
   437                    match=util.always, force=False, force_editor=False,
   438                    p1=None, p2=None, extra={}):
   438                    p1=None, p2=None, extra={}):
   439             wlock = lock = None
   439             wlock = lock = None
       
   440             _p1 = _p2 = None
   440             try:
   441             try:
   441                 wlock = self.wlock()
   442                 wlock = self.wlock()
   442                 lock = self.lock()
   443                 lock = self.lock()
   443                 # store and postpone commit hooks
   444                 # store and postpone commit hooks
   444                 commithooks = []
   445                 commithooks = []
   450                     # store parents for commit hook environment
   451                     # store parents for commit hook environment
   451                     if p1 is None:
   452                     if p1 is None:
   452                         _p1, _p2 = repo.dirstate.parents()
   453                         _p1, _p2 = repo.dirstate.parents()
   453                     else:
   454                     else:
   454                         _p1, _p2 = p1, p2 or nullid
   455                         _p1, _p2 = p1, p2 or nullid
       
   456                     _p1 = hex(_p1)
       
   457                     if _p2 == nullid:
       
   458                         _p2 = ''
       
   459                     else:
       
   460                         _p2 = hex(_p2)
   455 
   461 
   456                 node = super(kwrepo,
   462                 node = super(kwrepo,
   457                              self).commit(files=files, text=text, user=user,
   463                              self).commit(files=files, text=text, user=user,
   458                                           date=date, match=match, force=force,
   464                                           date=date, match=match, force=force,
   459                                           force_editor=force_editor,
   465                                           force_editor=force_editor,
   465                                   and _iskwfile(ui, mn, f)]
   471                                   and _iskwfile(ui, mn, f)]
   466                     if candidates:
   472                     if candidates:
   467                         # 6th, 7th arguments set expansion, commit to True
   473                         # 6th, 7th arguments set expansion, commit to True
   468                         _overwrite(ui, self, candidates, node, mn, True, True)
   474                         _overwrite(ui, self, candidates, node, mn, True, True)
   469 
   475 
   470                 if commithooks:
   476                 # restore commit hooks and run them
   471                     # restore commit hooks and run them
   477                 for name, cmd in commithooks:
   472                     for name, cmd in commithooks:
   478                     ui.setconfig('hooks', name, cmd)
   473                         ui.setconfig('hooks', name, cmd)
   479                 repo.hook('commit', node=node, parent1=_p1, parent2=_p2)
   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