comparison mercurial/localrepo.py @ 8501:ab0e3f7ea315

commit: some tidying - simplify handling of 'close' - kill silly wlock=None - sort/uniq files later
author Matt Mackall <mpm@selenic.com>
date Mon, 18 May 2009 17:36:24 -0500
parents 1024bef53d9e
children 51b7d2a68e03
comparison
equal deleted inserted replaced
8500:1024bef53d9e 8501:ab0e3f7ea315
767 767
768 return fparent1 768 return fparent1
769 769
770 def commit(self, files=None, text="", user=None, date=None, match=None, 770 def commit(self, files=None, text="", user=None, date=None, match=None,
771 force=False, editor=False, extra={}): 771 force=False, editor=False, extra={}):
772 wlock = None
773 if extra.get("close"):
774 force = True
775 if files:
776 files = list(set(files))
777
778 ret = None 772 ret = None
779 wlock = self.wlock() 773 wlock = self.wlock()
780 try: 774 try:
781 p1, p2 = self.dirstate.parents() 775 p1, p2 = self.dirstate.parents()
782 776
783 if (not force and p2 != nullid and 777 if (not force and p2 != nullid and match and
784 (match and (match.files() or match.anypats()))): 778 (match.files() or match.anypats())):
785 raise util.Abort(_('cannot partially commit a merge ' 779 raise util.Abort(_('cannot partially commit a merge '
786 '(do not specify files or patterns)')) 780 '(do not specify files or patterns)'))
787 781
788 if files: 782 if files:
789 modified, removed = [], [] 783 modified, removed = [], []
790 for f in files: 784 for f in sorted(set(files)):
791 s = self.dirstate[f] 785 s = self.dirstate[f]
792 if s in 'nma': 786 if s in 'nma':
793 modified.append(f) 787 modified.append(f)
794 elif s == 'r': 788 elif s == 'r':
795 removed.append(f) 789 removed.append(f)
797 self.ui.warn(_("%s not tracked!\n") % f) 791 self.ui.warn(_("%s not tracked!\n") % f)
798 changes = [modified, [], removed, [], []] 792 changes = [modified, [], removed, [], []]
799 else: 793 else:
800 changes = self.status(match=match) 794 changes = self.status(match=match)
801 795
802 if (not (changes[0] or changes[1] or changes[2]) 796 if (not force and not extra.get("close") and p2 == nullid
803 and not force and p2 == nullid and 797 and not (changes[0] or changes[1] or changes[2])
804 self[None].branch() == self['.'].branch()): 798 and self[None].branch() == self['.'].branch()):
805 self.ui.status(_("nothing changed\n")) 799 self.ui.status(_("nothing changed\n"))
806 return None 800 return None
807 801
808 ms = merge_.mergestate(self) 802 ms = merge_.mergestate(self)
809 for f in changes[0]: 803 for f in changes[0]: