##// END OF EJS Templates
localrepo: let commit() get extra data from workingctx
Patrick Mezard -
r6708:7566f00a default
parent child Browse files
Show More
@@ -446,10 +446,11 b' class workingctx(changectx):'
446 """A workingctx object makes access to data related to
446 """A workingctx object makes access to data related to
447 the current working directory convenient.
447 the current working directory convenient.
448 parents - a pair of parent nodeids, or None to use the dirstate.
448 parents - a pair of parent nodeids, or None to use the dirstate.
449 extra - a dictionary of extra values, or None.
449 changes - a list of file lists as returned by localrepo.status()
450 changes - a list of file lists as returned by localrepo.status()
450 or None to use the repository status.
451 or None to use the repository status.
451 """
452 """
452 def __init__(self, repo, parents=None, changes=None):
453 def __init__(self, repo, parents=None, extra=None, changes=None):
453 self._repo = repo
454 self._repo = repo
454 self._rev = None
455 self._rev = None
455 self._node = None
456 self._node = None
@@ -459,6 +460,19 b' class workingctx(changectx):'
459 if changes:
460 if changes:
460 self._status = list(changes)
461 self._status = list(changes)
461
462
463 self._extra = {}
464 if extra:
465 self._extra = extra.copy()
466 if 'branch' not in self._extra:
467 branch = self._repo.dirstate.branch()
468 try:
469 branch = branch.decode('UTF-8').encode('UTF-8')
470 except UnicodeDecodeError:
471 raise util.Abort(_('branch name not in UTF-8!'))
472 self._extra['branch'] = branch
473 if self._extra['branch'] == '':
474 self._extra['branch'] = 'default'
475
462 def __str__(self):
476 def __str__(self):
463 return str(self._parents[0]) + "+"
477 return str(self._parents[0]) + "+"
464
478
@@ -518,7 +532,8 b' class workingctx(changectx):'
518 def deleted(self): return self._status[3]
532 def deleted(self): return self._status[3]
519 def unknown(self): return self._status[4]
533 def unknown(self): return self._status[4]
520 def clean(self): return self._status[5]
534 def clean(self): return self._status[5]
521 def branch(self): return self._repo.dirstate.branch()
535 def branch(self): return self._extra['branch']
536 def extra(self): return self._extra
522
537
523 def tags(self):
538 def tags(self):
524 t = []
539 t = []
@@ -491,8 +491,8 b' class localrepository(repo.repository):'
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 '''
@@ -767,7 +767,6 b' class localrepository(repo.repository):'
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()
@@ -796,9 +795,11 b' class localrepository(repo.repository):'
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)
@@ -806,15 +807,6 b' class localrepository(repo.repository):'
806 m2 = self.manifest.read(c2[0])
807 m2 = self.manifest.read(c2[0])
807
808
808 if use_dirstate:
809 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
817 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):
@@ -901,9 +893,6 b' class localrepository(repo.repository):'
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
895
904 if branchname:
905 extra["branch"] = branchname
906
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]
General Comments 0
You need to be logged in to leave comments. Login now