Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 8244:99d7e2db8da8
localrepo: Refactor var names in filecommit to improve readability.
author | Martijn Pieters <mj@zopatista.com> |
---|---|
date | Tue, 28 Apr 2009 18:14:49 +0200 |
parents | f802b4706a53 |
children | 54a4b520bd7d |
comparison
equal
deleted
inserted
replaced
8243:cb08c3765a02 | 8244:99d7e2db8da8 |
---|---|
709 def filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): | 709 def filecommit(self, fctx, manifest1, manifest2, linkrev, tr, changelist): |
710 """ | 710 """ |
711 commit an individual file as part of a larger transaction | 711 commit an individual file as part of a larger transaction |
712 """ | 712 """ |
713 | 713 |
714 fn = fctx.path() | 714 fname = fctx.path() |
715 t = fctx.data() | 715 text = fctx.data() |
716 fl = self.file(fn) | 716 flog = self.file(fname) |
717 fp1 = manifest1.get(fn, nullid) | 717 fparent1 = manifest1.get(fname, nullid) |
718 fp2 = manifest2.get(fn, nullid) | 718 fparent2 = manifest2.get(fname, nullid) |
719 | 719 |
720 meta = {} | 720 meta = {} |
721 cp = fctx.renamed() | 721 copy = fctx.renamed() |
722 if cp and cp[0] != fn: | 722 if copy and copy[0] != fname: |
723 # Mark the new revision of this file as a copy of another | 723 # Mark the new revision of this file as a copy of another |
724 # file. This copy data will effectively act as a parent | 724 # file. This copy data will effectively act as a parent |
725 # of this new revision. If this is a merge, the first | 725 # of this new revision. If this is a merge, the first |
726 # parent will be the nullid (meaning "look up the copy data") | 726 # parent will be the nullid (meaning "look up the copy data") |
727 # and the second one will be the other parent. For example: | 727 # and the second one will be the other parent. For example: |
737 # 0 --- 1 --- 3 rev4 reverts the content change from rev2 | 737 # 0 --- 1 --- 3 rev4 reverts the content change from rev2 |
738 # \ / merging rev3 and rev4 should use bar@rev2 | 738 # \ / merging rev3 and rev4 should use bar@rev2 |
739 # \- 2 --- 4 as the merge base | 739 # \- 2 --- 4 as the merge base |
740 # | 740 # |
741 | 741 |
742 cf = cp[0] | 742 cfname = copy[0] |
743 cr = manifest1.get(cf) | 743 crev = manifest1.get(cfname) |
744 nfp = fp2 | 744 newfparent = fparent2 |
745 | 745 |
746 if manifest2: # branch merge | 746 if manifest2: # branch merge |
747 if fp2 == nullid or cr is None: # copied on remote side | 747 if fparent2 == nullid or crev is None: # copied on remote side |
748 if cf in manifest2: | 748 if cfname in manifest2: |
749 cr = manifest2[cf] | 749 crev = manifest2[cfname] |
750 nfp = fp1 | 750 newfparent = fparent1 |
751 | 751 |
752 # find source in nearest ancestor if we've lost track | 752 # find source in nearest ancestor if we've lost track |
753 if not cr: | 753 if not crev: |
754 self.ui.debug(_(" %s: searching for copy revision for %s\n") % | 754 self.ui.debug(_(" %s: searching for copy revision for %s\n") % |
755 (fn, cf)) | 755 (fname, cfname)) |
756 for a in self['.'].ancestors(): | 756 for ancestor in self['.'].ancestors(): |
757 if cf in a: | 757 if cfname in ancestor: |
758 cr = a[cf].filenode() | 758 crev = ancestor[cfname].filenode() |
759 break | 759 break |
760 | 760 |
761 self.ui.debug(_(" %s: copy %s:%s\n") % (fn, cf, hex(cr))) | 761 self.ui.debug(_(" %s: copy %s:%s\n") % (fname, cfname, hex(crev))) |
762 meta["copy"] = cf | 762 meta["copy"] = cfname |
763 meta["copyrev"] = hex(cr) | 763 meta["copyrev"] = hex(crev) |
764 fp1, fp2 = nullid, nfp | 764 fparent1, fparent2 = nullid, newfparent |
765 elif fp2 != nullid: | 765 elif fparent2 != nullid: |
766 # is one parent an ancestor of the other? | 766 # is one parent an ancestor of the other? |
767 fpa = fl.ancestor(fp1, fp2) | 767 fparentancestor = flog.ancestor(fparent1, fparent2) |
768 if fpa == fp1: | 768 if fparentancestor == fparent1: |
769 fp1, fp2 = fp2, nullid | 769 fparent1, fparent2 = fparent2, nullid |
770 elif fpa == fp2: | 770 elif fparentancestor == fparent2: |
771 fp2 = nullid | 771 fparent2 = nullid |
772 | 772 |
773 # is the file unmodified from the parent? report existing entry | 773 # is the file unmodified from the parent? report existing entry |
774 if fp2 == nullid and not fl.cmp(fp1, t) and not meta: | 774 if fparent2 == nullid and not flog.cmp(fparent1, text) and not meta: |
775 return fp1 | 775 return fparent1 |
776 | 776 |
777 changelist.append(fn) | 777 changelist.append(fname) |
778 return fl.add(t, meta, tr, linkrev, fp1, fp2) | 778 return flog.add(text, meta, tr, linkrev, fparent1, fparent2) |
779 | 779 |
780 def rawcommit(self, files, text, user, date, p1=None, p2=None, extra={}): | 780 def rawcommit(self, files, text, user, date, p1=None, p2=None, extra={}): |
781 if p1 is None: | 781 if p1 is None: |
782 p1, p2 = self.dirstate.parents() | 782 p1, p2 = self.dirstate.parents() |
783 return self.commit(files=files, text=text, user=user, date=date, | 783 return self.commit(files=files, text=text, user=user, date=date, |