Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 6706:716a1296e182
localrepo: replace dirstate by workingfilectx in filecommit()
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 18 Jun 2008 22:52:25 +0200 |
parents | fec6bc978843 |
children | 02bad34230a2 |
comparison
equal
deleted
inserted
replaced
6705:fec6bc978843 | 6706:716a1296e182 |
---|---|
681 self.dirstate.invalidate, _('working directory of %s') % | 681 self.dirstate.invalidate, _('working directory of %s') % |
682 self.origroot) | 682 self.origroot) |
683 self._wlockref = weakref.ref(l) | 683 self._wlockref = weakref.ref(l) |
684 return l | 684 return l |
685 | 685 |
686 def filecommit(self, fn, manifest1, manifest2, linkrev, tr, changelist): | 686 def filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
687 """ | 687 """ |
688 commit an individual file as part of a larger transaction | 688 commit an individual file as part of a larger transaction |
689 """ | 689 """ |
690 | 690 |
691 t = self.wread(fn) | 691 fn = fctx.path() |
692 t = fctx.data() | |
692 fl = self.file(fn) | 693 fl = self.file(fn) |
693 fp1 = manifest1.get(fn, nullid) | 694 fp1 = manifest1.get(fn, nullid) |
694 fp2 = manifest2.get(fn, nullid) | 695 fp2 = manifest2.get(fn, nullid) |
695 | 696 |
696 meta = {} | 697 meta = {} |
697 cp = self.dirstate.copied(fn) | 698 cp = fctx.renamed() |
698 if cp and cp != fn: | 699 if cp and cp[0] != fn: |
700 cp = cp[0] | |
699 # Mark the new revision of this file as a copy of another | 701 # Mark the new revision of this file as a copy of another |
700 # file. This copy data will effectively act as a parent | 702 # file. This copy data will effectively act as a parent |
701 # of this new revision. If this is a merge, the first | 703 # of this new revision. If this is a merge, the first |
702 # parent will be the nullid (meaning "look up the copy data") | 704 # parent will be the nullid (meaning "look up the copy data") |
703 # and the second one will be the other parent. For example: | 705 # and the second one will be the other parent. For example: |
766 changed = [] | 768 changed = [] |
767 use_dirstate = (p1 is None) # not rawcommit | 769 use_dirstate = (p1 is None) # not rawcommit |
768 extra = extra.copy() | 770 extra = extra.copy() |
769 | 771 |
770 if use_dirstate: | 772 if use_dirstate: |
773 p1, p2 = self.dirstate.parents() | |
774 update_dirstate = True | |
775 | |
776 if (not force and p2 != nullid and | |
777 (match and (match.files() or match.anypats()))): | |
778 raise util.Abort(_('cannot partially commit a merge ' | |
779 '(do not specify files or patterns)')) | |
780 else: | |
781 p1, p2 = p1, p2 or nullid | |
782 update_dirstate = (self.dirstate.parents()[0] == p1) | |
783 | |
784 wctx = self.workingctx((p1, p2)) | |
785 | |
786 if use_dirstate: | |
771 if files: | 787 if files: |
772 for f in files: | 788 for f in files: |
773 s = self.dirstate[f] | 789 s = self.dirstate[f] |
774 if s in 'nma': | 790 if s in 'nma': |
775 commit.append(f) | 791 commit.append(f) |
783 commit = modified + added | 799 commit = modified + added |
784 remove = removed | 800 remove = removed |
785 else: | 801 else: |
786 commit = files | 802 commit = files |
787 | 803 |
788 if use_dirstate: | |
789 p1, p2 = self.dirstate.parents() | |
790 update_dirstate = True | |
791 | |
792 if (not force and p2 != nullid and | |
793 (match and (match.files() or match.anypats()))): | |
794 raise util.Abort(_('cannot partially commit a merge ' | |
795 '(do not specify files or patterns)')) | |
796 else: | |
797 p1, p2 = p1, p2 or nullid | |
798 update_dirstate = (self.dirstate.parents()[0] == p1) | |
799 | |
800 c1 = self.changelog.read(p1) | 804 c1 = self.changelog.read(p1) |
801 c2 = self.changelog.read(p2) | 805 c2 = self.changelog.read(p2) |
802 m1 = self.manifest.read(c1[0]).copy() | 806 m1 = self.manifest.read(c1[0]).copy() |
803 m2 = self.manifest.read(c2[0]) | 807 m2 = self.manifest.read(c2[0]) |
804 | 808 |
805 if use_dirstate: | 809 if use_dirstate: |
806 branchname = self.workingctx().branch() | 810 branchname = wctx.branch() |
807 try: | 811 try: |
808 branchname = branchname.decode('UTF-8').encode('UTF-8') | 812 branchname = branchname.decode('UTF-8').encode('UTF-8') |
809 except UnicodeDecodeError: | 813 except UnicodeDecodeError: |
810 raise util.Abort(_('branch name not in UTF-8!')) | 814 raise util.Abort(_('branch name not in UTF-8!')) |
811 else: | 815 else: |
829 | 833 |
830 # check in files | 834 # check in files |
831 new = {} | 835 new = {} |
832 linkrev = self.changelog.count() | 836 linkrev = self.changelog.count() |
833 commit.sort() | 837 commit.sort() |
834 is_exec = util.execfunc(self.root, m1.execf) | |
835 is_link = util.linkfunc(self.root, m1.linkf) | |
836 for f in commit: | 838 for f in commit: |
837 self.ui.note(f + "\n") | 839 self.ui.note(f + "\n") |
840 fctx = wctx.filectx(f) | |
838 try: | 841 try: |
839 new[f] = self.filecommit(f, m1, m2, linkrev, trp, changed) | 842 new[f] = self.filecommit(fctx, m1, m2, linkrev, trp, changed) |
840 new_exec = is_exec(f) | 843 new_exec = fctx.isexec() |
841 new_link = is_link(f) | 844 new_link = fctx.islink() |
842 if ((not changed or changed[-1] != f) and | 845 if ((not changed or changed[-1] != f) and |
843 m2.get(f) != new[f]): | 846 m2.get(f) != new[f]): |
844 # mention the file in the changelog if some | 847 # mention the file in the changelog if some |
845 # flag changed, even if there was no content | 848 # flag changed, even if there was no content |
846 # change. | 849 # change. |