756 p1=p1, p2=p2, extra=extra, empty_ok=True) |
756 p1=p1, p2=p2, extra=extra, empty_ok=True) |
757 |
757 |
758 def commit(self, files=None, text="", user=None, date=None, |
758 def commit(self, files=None, text="", user=None, date=None, |
759 match=None, force=False, force_editor=False, |
759 match=None, force=False, force_editor=False, |
760 p1=None, p2=None, extra={}, empty_ok=False): |
760 p1=None, p2=None, extra={}, empty_ok=False): |
761 wlock = lock = tr = None |
761 wlock = lock = None |
762 valid = 0 # don't save the dirstate if this isn't set |
|
763 if files: |
762 if files: |
764 files = util.unique(files) |
763 files = util.unique(files) |
765 try: |
764 try: |
766 wlock = self.wlock() |
765 wlock = self.wlock() |
767 lock = self.lock() |
766 lock = self.lock() |
768 commit = [] |
|
769 remove = [] |
|
770 changed = [] |
|
771 use_dirstate = (p1 is None) # not rawcommit |
767 use_dirstate = (p1 is None) # not rawcommit |
772 |
768 |
773 if use_dirstate: |
769 if use_dirstate: |
774 p1, p2 = self.dirstate.parents() |
770 p1, p2 = self.dirstate.parents() |
775 update_dirstate = True |
771 update_dirstate = True |
796 p1, p2 = p1, p2 or nullid |
792 p1, p2 = p1, p2 or nullid |
797 update_dirstate = (self.dirstate.parents()[0] == p1) |
793 update_dirstate = (self.dirstate.parents()[0] == p1) |
798 changes = [files, [], [], [], []] |
794 changes = [files, [], [], [], []] |
799 |
795 |
800 wctx = self.workingctx((p1, p2), text, user, date, extra, changes) |
796 wctx = self.workingctx((p1, p2), text, user, date, extra, changes) |
|
797 return self._commitctx(wctx, force, force_editor, empty_ok, |
|
798 use_dirstate, update_dirstate) |
|
799 finally: |
|
800 del lock, wlock |
|
801 |
|
802 def _commitctx(self, wctx, force=False, force_editor=False, empty_ok=False, |
|
803 use_dirstate=True, update_dirstate=True): |
|
804 tr = None |
|
805 valid = 0 # don't save the dirstate if this isn't set |
|
806 try: |
801 commit = wctx.modified() + wctx.added() |
807 commit = wctx.modified() + wctx.added() |
802 remove = wctx.removed() |
808 remove = wctx.removed() |
803 extra = wctx.extra().copy() |
809 extra = wctx.extra().copy() |
804 branchname = extra['branch'] |
810 branchname = extra['branch'] |
805 user = wctx.user() |
811 user = wctx.user() |
806 text = wctx.description() |
812 text = wctx.description() |
807 |
813 |
|
814 p1, p2 = [p.node() for p in wctx.parents()] |
808 c1 = self.changelog.read(p1) |
815 c1 = self.changelog.read(p1) |
809 c2 = self.changelog.read(p2) |
816 c2 = self.changelog.read(p2) |
810 m1 = self.manifest.read(c1[0]).copy() |
817 m1 = self.manifest.read(c1[0]).copy() |
811 m2 = self.manifest.read(c2[0]) |
818 m2 = self.manifest.read(c2[0]) |
812 |
819 |
922 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
930 self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
923 return n |
931 return n |
924 finally: |
932 finally: |
925 if not valid: # don't save our updated dirstate |
933 if not valid: # don't save our updated dirstate |
926 self.dirstate.invalidate() |
934 self.dirstate.invalidate() |
927 del tr, lock, wlock |
935 del tr |
928 |
936 |
929 def walk(self, match, node=None): |
937 def walk(self, match, node=None): |
930 ''' |
938 ''' |
931 walk recursively through the directory tree or a given |
939 walk recursively through the directory tree or a given |
932 changeset, finding all files matched by the match |
940 changeset, finding all files matched by the match |