Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 8401:ca7dc47eecc6
filecommit: swallow some bits from _commitctx, add _
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 14 May 2009 13:20:40 -0500 |
parents | 9eecc471aca3 |
children | 0ad521500424 |
comparison
equal
deleted
inserted
replaced
8400:9eecc471aca3 | 8401:ca7dc47eecc6 |
---|---|
703 self.dirstate.invalidate, _('working directory of %s') % | 703 self.dirstate.invalidate, _('working directory of %s') % |
704 self.origroot) | 704 self.origroot) |
705 self._wlockref = weakref.ref(l) | 705 self._wlockref = weakref.ref(l) |
706 return l | 706 return l |
707 | 707 |
708 def filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | 708 def _filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
709 """ | 709 """ |
710 commit an individual file as part of a larger transaction | 710 commit an individual file as part of a larger transaction |
711 """ | 711 """ |
712 | 712 |
713 fname = fctx.path() | 713 fname = fctx.path() |
714 text = fctx.data() | 714 text = fctx.data() |
715 flog = self.file(fname) | 715 flog = self.file(fname) |
716 fparent1 = manifest1.get(fname, nullid) | 716 fparent1 = manifest1.get(fname, nullid) |
717 fparent2 = manifest2.get(fname, nullid) | 717 fparent2 = fparent2o = manifest2.get(fname, nullid) |
718 | 718 |
719 meta = {} | 719 meta = {} |
720 copy = fctx.renamed() | 720 copy = fctx.renamed() |
721 if copy and copy[0] != fname: | 721 if copy and copy[0] != fname: |
722 # Mark the new revision of this file as a copy of another | 722 # Mark the new revision of this file as a copy of another |
767 if fparentancestor == fparent1: | 767 if fparentancestor == fparent1: |
768 fparent1, fparent2 = fparent2, nullid | 768 fparent1, fparent2 = fparent2, nullid |
769 elif fparentancestor == fparent2: | 769 elif fparentancestor == fparent2: |
770 fparent2 = nullid | 770 fparent2 = nullid |
771 | 771 |
772 # is the file unmodified from the parent? report existing entry | 772 # is the file changed? |
773 if fparent2 == nullid and not flog.cmp(fparent1, text) and not meta: | 773 if fparent2 != nullid or flog.cmp(fparent1, text) or meta: |
774 return fparent1 | 774 changelist.append(fname) |
775 | 775 return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
776 changelist.append(fname) | 776 |
777 return flog.add(text, meta, tr, linkrev, fparent1, fparent2) | 777 # are just the flags changed during merge? |
778 if fparent1 != fparent2o and manifest1.flags(fname) != fctx.flags(): | |
779 changelist.append(fname) | |
780 | |
781 return fparent1 | |
778 | 782 |
779 def commit(self, files=None, text="", user=None, date=None, | 783 def commit(self, files=None, text="", user=None, date=None, |
780 match=None, force=False, force_editor=False, | 784 match=None, force=False, force_editor=False, |
781 p1=None, p2=None, extra={}, empty_ok=False): | 785 p1=None, p2=None, extra={}, empty_ok=False): |
782 wlock = lock = None | 786 wlock = lock = None |
875 changed = [] | 879 changed = [] |
876 linkrev = len(self) | 880 linkrev = len(self) |
877 for f in commit: | 881 for f in commit: |
878 self.ui.note(f + "\n") | 882 self.ui.note(f + "\n") |
879 try: | 883 try: |
880 fctx = ctx.filectx(f) | 884 fctx = ctx[f] |
881 newflags = fctx.flags() | 885 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, |
882 new[f] = self.filecommit(fctx, m1, m2, linkrev, trp, changed) | 886 changed) |
883 if ((not changed or changed[-1] != f) and | 887 m1.set(f, fctx.flags()) |
884 m2.get(f) != new[f]): | |
885 # mention the file in the changelog if some | |
886 # flag changed, even if there was no content | |
887 # change. | |
888 if m1.flags(f) != newflags: | |
889 changed.append(f) | |
890 m1.set(f, newflags) | |
891 if working: | 888 if working: |
892 self.dirstate.normal(f) | 889 self.dirstate.normal(f) |
893 | 890 |
894 except (OSError, IOError): | 891 except (OSError, IOError): |
895 if working: | 892 if working: |