mercurial/localrepo.py
changeset 8397 613ac2856535
parent 8395 475552c03496
child 8398 a45eb410e0f2
equal deleted inserted replaced
8396:d7a77ad9bcce 8397:613ac2856535
   774             return fparent1
   774             return fparent1
   775 
   775 
   776         changelist.append(fname)
   776         changelist.append(fname)
   777         return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
   777         return flog.add(text, meta, tr, linkrev, fparent1, fparent2)
   778 
   778 
   779     def rawcommit(self, files, text, user, date, p1=None, p2=None, extra={}):
       
   780         if p1 is None:
       
   781             p1, p2 = self.dirstate.parents()
       
   782         return self.commit(files=files, text=text, user=user, date=date,
       
   783                            p1=p1, p2=p2, extra=extra, empty_ok=True)
       
   784 
       
   785     def commit(self, files=None, text="", user=None, date=None,
   779     def commit(self, files=None, text="", user=None, date=None,
   786                match=None, force=False, force_editor=False,
   780                match=None, force=False, force_editor=False,
   787                p1=None, p2=None, extra={}, empty_ok=False):
   781                p1=None, p2=None, extra={}, empty_ok=False):
   788         wlock = lock = None
   782         wlock = lock = None
   789         if extra.get("close"):
   783         if extra.get("close"):
   791         if files:
   785         if files:
   792             files = list(set(files))
   786             files = list(set(files))
   793         try:
   787         try:
   794             wlock = self.wlock()
   788             wlock = self.wlock()
   795             lock = self.lock()
   789             lock = self.lock()
   796             use_dirstate = (p1 is None) # not rawcommit
   790 
   797 
   791             p1, p2 = self.dirstate.parents()
   798             if use_dirstate:
   792 
   799                 p1, p2 = self.dirstate.parents()
   793             if (not force and p2 != nullid and
   800                 update_dirstate = True
   794                 (match and (match.files() or match.anypats()))):
   801 
   795                 raise util.Abort(_('cannot partially commit a merge '
   802                 if (not force and p2 != nullid and
   796                                    '(do not specify files or patterns)'))
   803                     (match and (match.files() or match.anypats()))):
   797 
   804                     raise util.Abort(_('cannot partially commit a merge '
   798             if files:
   805                                        '(do not specify files or patterns)'))
   799                 modified, removed = [], []
   806 
   800                 for f in files:
   807                 if files:
   801                     s = self.dirstate[f]
   808                     modified, removed = [], []
   802                     if s in 'nma':
   809                     for f in files:
   803                         modified.append(f)
   810                         s = self.dirstate[f]
   804                     elif s == 'r':
   811                         if s in 'nma':
   805                         removed.append(f)
   812                             modified.append(f)
   806                     else:
   813                         elif s == 'r':
   807                         self.ui.warn(_("%s not tracked!\n") % f)
   814                             removed.append(f)
   808                 changes = [modified, [], removed, [], []]
   815                         else:
       
   816                             self.ui.warn(_("%s not tracked!\n") % f)
       
   817                     changes = [modified, [], removed, [], []]
       
   818                 else:
       
   819                     changes = self.status(match=match)
       
   820             else:
   809             else:
   821                 p1, p2 = p1, p2 or nullid
   810                 changes = self.status(match=match)
   822                 update_dirstate = (self.dirstate.parents()[0] == p1)
       
   823                 changes = [files, [], [], [], []]
       
   824 
   811 
   825             ms = merge_.mergestate(self)
   812             ms = merge_.mergestate(self)
   826             for f in changes[0]:
   813             for f in changes[0]:
   827                 if f in ms and ms[f] == 'u':
   814                 if f in ms and ms[f] == 'u':
   828                     raise util.Abort(_("unresolved merge conflicts "
   815                     raise util.Abort(_("unresolved merge conflicts "
   829                                                     "(see hg resolve)"))
   816                                                     "(see hg resolve)"))
   830             wctx = context.workingctx(self, (p1, p2), text, user, date,
   817             wctx = context.workingctx(self, (p1, p2), text, user, date,
   831                                       extra, changes)
   818                                       extra, changes)
   832             r = self._commitctx(wctx, force, force_editor, empty_ok,
   819             r = self._commitctx(wctx, force, force_editor, empty_ok,
   833                                 use_dirstate, update_dirstate)
   820                                 True, True)
   834             ms.reset()
   821             ms.reset()
   835             return r
   822             return r
   836 
   823 
   837         finally:
   824         finally:
   838             release(lock, wlock)
   825             release(lock, wlock)