##// END OF EJS Templates
localrepo: hide commit() file selection behind workingctx
Patrick Mezard -
r6707:02bad342 default
parent child Browse files
Show More
@@ -446,14 +446,18 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 changes - a list of file lists as returned by localrepo.status()
450 or None to use the repository status.
449 """
451 """
450 def __init__(self, repo, parents=None):
452 def __init__(self, repo, parents=None, changes=None):
451 self._repo = repo
453 self._repo = repo
452 self._rev = None
454 self._rev = None
453 self._node = None
455 self._node = None
454 if parents:
456 if parents:
455 p1, p2 = parents
457 p1, p2 = parents
456 self._parents = [self._repo.changectx(p) for p in (p1, p2)]
458 self._parents = [self._repo.changectx(p) for p in (p1, p2)]
459 if changes:
460 self._status = list(changes)
457
461
458 def __str__(self):
462 def __str__(self):
459 return str(self._parents[0]) + "+"
463 return str(self._parents[0]) + "+"
@@ -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):
494 def workingctx(self, parents=None, changes=None):
495 return context.workingctx(self, parents)
495 return context.workingctx(self, parents, changes)
496
496
497 def parents(self, changeid=None):
497 def parents(self, changeid=None):
498 '''
498 '''
@@ -777,29 +777,28 b' class localrepository(repo.repository):'
777 (match and (match.files() or match.anypats()))):
777 (match and (match.files() or match.anypats()))):
778 raise util.Abort(_('cannot partially commit a merge '
778 raise util.Abort(_('cannot partially commit a merge '
779 '(do not specify files or patterns)'))
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
780
784 wctx = self.workingctx((p1, p2))
785
786 if use_dirstate:
787 if files:
781 if files:
782 modified, removed = [], []
788 for f in files:
783 for f in files:
789 s = self.dirstate[f]
784 s = self.dirstate[f]
790 if s in 'nma':
785 if s in 'nma':
791 commit.append(f)
786 modified.append(f)
792 elif s == 'r':
787 elif s == 'r':
793 remove.append(f)
788 removed.append(f)
794 else:
789 else:
795 self.ui.warn(_("%s not tracked!\n") % f)
790 self.ui.warn(_("%s not tracked!\n") % f)
791 changes = [modified, [], removed, [], []]
796 else:
792 else:
797 changes = self.status(match=match)[:5]
793 changes = self.status(match=match)
798 modified, added, removed, deleted, unknown = changes
799 commit = modified + added
800 remove = removed
801 else:
794 else:
802 commit = files
795 p1, p2 = p1, p2 or nullid
796 update_dirstate = (self.dirstate.parents()[0] == p1)
797 changes = [files, [], [], [], []]
798
799 wctx = self.workingctx((p1, p2), changes)
800 commit = wctx.modified() + wctx.added()
801 remove = wctx.removed()
803
802
804 c1 = self.changelog.read(p1)
803 c1 = self.changelog.read(p1)
805 c2 = self.changelog.read(p2)
804 c2 = self.changelog.read(p2)
General Comments 0
You need to be logged in to leave comments. Login now