mercurial/localrepo.py
changeset 10970 3213e8947975
parent 10969 ca052b484e56
child 11047 c7dbd6c4877a
equal deleted inserted replaced
10969:ca052b484e56 10970:3213e8947975
   796             match.dir = vdirs.append
   796             match.dir = vdirs.append
   797             match.bad = fail
   797             match.bad = fail
   798 
   798 
   799         wlock = self.wlock()
   799         wlock = self.wlock()
   800         try:
   800         try:
   801             p1, p2 = self.dirstate.parents()
       
   802             wctx = self[None]
   801             wctx = self[None]
   803 
   802             merge = len(wctx.parents()) > 1
   804             if (not force and p2 != nullid and match and
   803 
       
   804             if (not force and merge and match and
   805                 (match.files() or match.anypats())):
   805                 (match.files() or match.anypats())):
   806                 raise util.Abort(_('cannot partially commit a merge '
   806                 raise util.Abort(_('cannot partially commit a merge '
   807                                    '(do not specify files or patterns)'))
   807                                    '(do not specify files or patterns)'))
   808 
   808 
   809             changes = self.status(match=match, clean=force)
   809             changes = self.status(match=match, clean=force)
   839                         else:
   839                         else:
   840                             fail(f, _("no match under directory!"))
   840                             fail(f, _("no match under directory!"))
   841                     elif f not in self.dirstate:
   841                     elif f not in self.dirstate:
   842                         fail(f, _("file not tracked!"))
   842                         fail(f, _("file not tracked!"))
   843 
   843 
   844             if (not force and not extra.get("close") and p2 == nullid
   844             if (not force and not extra.get("close") and not merge
   845                 and not (changes[0] or changes[1] or changes[2])
   845                 and not (changes[0] or changes[1] or changes[2])
   846                 and self[None].branch() == self['.'].branch()):
   846                 and wctx.branch() == wctx.p1().branch()):
   847                 return None
   847                 return None
   848 
   848 
   849             ms = mergemod.mergestate(self)
   849             ms = mergemod.mergestate(self)
   850             for f in changes[0]:
   850             for f in changes[0]:
   851                 if f in ms and ms[f] == 'u':
   851                 if f in ms and ms[f] == 'u':
   871             # the assumption that the user will use the same editor again.
   871             # the assumption that the user will use the same editor again.
   872             msgfile = self.opener('last-message.txt', 'wb')
   872             msgfile = self.opener('last-message.txt', 'wb')
   873             msgfile.write(cctx._text)
   873             msgfile.write(cctx._text)
   874             msgfile.close()
   874             msgfile.close()
   875 
   875 
       
   876             p1, p2 = self.dirstate.parents()
       
   877             hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
   876             try:
   878             try:
   877                 hookp1, hookp2 = hex(p1), (p2 != nullid and hex(p2) or '')
       
   878                 self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
   879                 self.hook("precommit", throw=True, parent1=hookp1, parent2=hookp2)
   879                 ret = self.commitctx(cctx, True)
   880                 ret = self.commitctx(cctx, True)
   880             except:
   881             except:
   881                 if edited:
   882                 if edited:
   882                     msgfn = self.pathto(msgfile.name[len(self.root)+1:])
   883                     msgfn = self.pathto(msgfile.name[len(self.root)+1:])