mercurial/localrepo.py
changeset 8706 25e9c71b89de
parent 8705 509083f54e52
child 8707 0550dfe4fca1
equal deleted inserted replaced
8705:509083f54e52 8706:25e9c71b89de
   182 
   182 
   183         if '.hgtags' not in self.dirstate:
   183         if '.hgtags' not in self.dirstate:
   184             self.add(['.hgtags'])
   184             self.add(['.hgtags'])
   185 
   185 
   186         m = match_.exact(self.root, '', ['.hgtags'])
   186         m = match_.exact(self.root, '', ['.hgtags'])
   187         tagnode = self.commit(None, message, user, date, extra=extra, match=m)
   187         tagnode = self.commit(message, user, date, extra=extra, match=m)
   188 
   188 
   189         for name in names:
   189         for name in names:
   190             self.hook('tag', node=hex(node), tag=name, local=local)
   190             self.hook('tag', node=hex(node), tag=name, local=local)
   191 
   191 
   192         return tagnode
   192         return tagnode
   771         if fparent1 !=  fparent2o and manifest1.flags(fname) != fctx.flags():
   771         if fparent1 !=  fparent2o and manifest1.flags(fname) != fctx.flags():
   772             changelist.append(fname)
   772             changelist.append(fname)
   773 
   773 
   774         return fparent1
   774         return fparent1
   775 
   775 
   776     def commit(self, files=None, text="", user=None, date=None, match=None,
   776     def commit(self, text="", user=None, date=None, match=None, force=False,
   777                force=False, editor=False, extra={}):
   777                editor=False, extra={}):
   778         """Add a new revision to current repository.
   778         """Add a new revision to current repository.
   779 
   779 
   780         Revision information is gathered from the working directory, files and
   780         Revision information is gathered from the working directory,
   781         match can be used to filter the committed files.
   781         match can be used to filter the committed files. If editor is
   782         If editor is supplied, it is called to get a commit message.
   782         supplied, it is called to get a commit message.
   783         """
   783         """
   784         wlock = self.wlock()
   784         wlock = self.wlock()
   785         try:
   785         try:
   786             p1, p2 = self.dirstate.parents()
   786             p1, p2 = self.dirstate.parents()
   787 
   787 
   788             if (not force and p2 != nullid and match and
   788             if (not force and p2 != nullid and match and
   789                 (match.files() or match.anypats())):
   789                 (match.files() or match.anypats())):
   790                 raise util.Abort(_('cannot partially commit a merge '
   790                 raise util.Abort(_('cannot partially commit a merge '
   791                                    '(do not specify files or patterns)'))
   791                                    '(do not specify files or patterns)'))
   792 
   792 
   793             if files:
   793             changes = self.status(match=match, clean=force)
   794                 modified, removed = [], []
   794             if force:
   795                 for f in sorted(set(files)):
   795                 changes[0].extend(changes[6]) # mq may commit unchanged files
   796                     s = self.dirstate[f]
       
   797                     if s in 'nma':
       
   798                         modified.append(f)
       
   799                     elif s == 'r':
       
   800                         removed.append(f)
       
   801                     else:
       
   802                         self.ui.warn(_("%s not tracked!\n") % f)
       
   803                 changes = [modified, [], removed, [], []]
       
   804             else:
       
   805                 changes = self.status(match=match, clean=force)
       
   806                 if force:
       
   807                     changes[0].extend(changes[6])
       
   808 
   796 
   809             if (not force and not extra.get("close") and p2 == nullid
   797             if (not force and not extra.get("close") and p2 == nullid
   810                 and not (changes[0] or changes[1] or changes[2])
   798                 and not (changes[0] or changes[1] or changes[2])
   811                 and self[None].branch() == self['.'].branch()):
   799                 and self[None].branch() == self['.'].branch()):
   812                 self.ui.status(_("nothing changed\n"))
   800                 self.ui.status(_("nothing changed\n"))