Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 6708:7566f00a3979
localrepo: let commit() get extra data from workingctx
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Wed, 18 Jun 2008 22:52:26 +0200 |
parents | 02bad34230a2 |
children | f84f507c53d3 |
comparison
equal
deleted
inserted
replaced
6707:02bad34230a2 | 6708:7566f00a3979 |
---|---|
489 return filelog.filelog(self.sopener, f) | 489 return filelog.filelog(self.sopener, f) |
490 | 490 |
491 def changectx(self, changeid=None): | 491 def changectx(self, changeid=None): |
492 return context.changectx(self, changeid) | 492 return context.changectx(self, changeid) |
493 | 493 |
494 def workingctx(self, parents=None, changes=None): | 494 def workingctx(self, parents=None, extra=None, changes=None): |
495 return context.workingctx(self, parents, changes) | 495 return context.workingctx(self, parents, extra, changes) |
496 | 496 |
497 def parents(self, changeid=None): | 497 def parents(self, changeid=None): |
498 ''' | 498 ''' |
499 get list of changectxs for parents of changeid or working directory | 499 get list of changectxs for parents of changeid or working directory |
500 ''' | 500 ''' |
765 lock = self.lock() | 765 lock = self.lock() |
766 commit = [] | 766 commit = [] |
767 remove = [] | 767 remove = [] |
768 changed = [] | 768 changed = [] |
769 use_dirstate = (p1 is None) # not rawcommit | 769 use_dirstate = (p1 is None) # not rawcommit |
770 extra = extra.copy() | |
771 | 770 |
772 if use_dirstate: | 771 if use_dirstate: |
773 p1, p2 = self.dirstate.parents() | 772 p1, p2 = self.dirstate.parents() |
774 update_dirstate = True | 773 update_dirstate = True |
775 | 774 |
794 else: | 793 else: |
795 p1, p2 = p1, p2 or nullid | 794 p1, p2 = p1, p2 or nullid |
796 update_dirstate = (self.dirstate.parents()[0] == p1) | 795 update_dirstate = (self.dirstate.parents()[0] == p1) |
797 changes = [files, [], [], [], []] | 796 changes = [files, [], [], [], []] |
798 | 797 |
799 wctx = self.workingctx((p1, p2), changes) | 798 wctx = self.workingctx((p1, p2), extra, changes) |
800 commit = wctx.modified() + wctx.added() | 799 commit = wctx.modified() + wctx.added() |
801 remove = wctx.removed() | 800 remove = wctx.removed() |
801 extra = wctx.extra().copy() | |
802 branchname = extra['branch'] | |
802 | 803 |
803 c1 = self.changelog.read(p1) | 804 c1 = self.changelog.read(p1) |
804 c2 = self.changelog.read(p2) | 805 c2 = self.changelog.read(p2) |
805 m1 = self.manifest.read(c1[0]).copy() | 806 m1 = self.manifest.read(c1[0]).copy() |
806 m2 = self.manifest.read(c2[0]) | 807 m2 = self.manifest.read(c2[0]) |
807 | |
808 if use_dirstate: | |
809 branchname = wctx.branch() | |
810 try: | |
811 branchname = branchname.decode('UTF-8').encode('UTF-8') | |
812 except UnicodeDecodeError: | |
813 raise util.Abort(_('branch name not in UTF-8!')) | |
814 else: | |
815 branchname = "" | |
816 | 808 |
817 if use_dirstate: | 809 if use_dirstate: |
818 oldname = c1[5].get("branch") # stored in UTF-8 | 810 oldname = c1[5].get("branch") # stored in UTF-8 |
819 if (not commit and not remove and not force and p2 == nullid | 811 if (not commit and not remove and not force and p2 == nullid |
820 and branchname == oldname): | 812 and branchname == oldname): |
898 # run editor in the repository root | 890 # run editor in the repository root |
899 olddir = os.getcwd() | 891 olddir = os.getcwd() |
900 os.chdir(self.root) | 892 os.chdir(self.root) |
901 text = self.ui.edit("\n".join(edittext), user) | 893 text = self.ui.edit("\n".join(edittext), user) |
902 os.chdir(olddir) | 894 os.chdir(olddir) |
903 | |
904 if branchname: | |
905 extra["branch"] = branchname | |
906 | 895 |
907 lines = [line.rstrip() for line in text.rstrip().splitlines()] | 896 lines = [line.rstrip() for line in text.rstrip().splitlines()] |
908 while lines and not lines[0]: | 897 while lines and not lines[0]: |
909 del lines[0] | 898 del lines[0] |
910 if not lines and use_dirstate: | 899 if not lines and use_dirstate: |