# HG changeset patch # User Patrick Mezard # Date 2008-06-18 20:52:25 # Node ID 02bad34230a2e39b331312c53628667ab254bbab # Parent 716a1296e182fa3bcb0db2ba4453fd87f1b34509 localrepo: hide commit() file selection behind workingctx diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -446,14 +446,18 @@ class workingctx(changectx): """A workingctx object makes access to data related to the current working directory convenient. parents - a pair of parent nodeids, or None to use the dirstate. + changes - a list of file lists as returned by localrepo.status() + or None to use the repository status. """ - def __init__(self, repo, parents=None): + def __init__(self, repo, parents=None, changes=None): self._repo = repo self._rev = None self._node = None if parents: p1, p2 = parents self._parents = [self._repo.changectx(p) for p in (p1, p2)] + if changes: + self._status = list(changes) def __str__(self): return str(self._parents[0]) + "+" diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -491,8 +491,8 @@ class localrepository(repo.repository): def changectx(self, changeid=None): return context.changectx(self, changeid) - def workingctx(self, parents=None): - return context.workingctx(self, parents) + def workingctx(self, parents=None, changes=None): + return context.workingctx(self, parents, changes) def parents(self, changeid=None): ''' @@ -777,29 +777,28 @@ class localrepository(repo.repository): (match and (match.files() or match.anypats()))): raise util.Abort(_('cannot partially commit a merge ' '(do not specify files or patterns)')) - else: - p1, p2 = p1, p2 or nullid - update_dirstate = (self.dirstate.parents()[0] == p1) - wctx = self.workingctx((p1, p2)) - - if use_dirstate: if files: + modified, removed = [], [] for f in files: s = self.dirstate[f] if s in 'nma': - commit.append(f) + modified.append(f) elif s == 'r': - remove.append(f) + removed.append(f) else: self.ui.warn(_("%s not tracked!\n") % f) + changes = [modified, [], removed, [], []] else: - changes = self.status(match=match)[:5] - modified, added, removed, deleted, unknown = changes - commit = modified + added - remove = removed + changes = self.status(match=match) else: - commit = files + p1, p2 = p1, p2 or nullid + update_dirstate = (self.dirstate.parents()[0] == p1) + changes = [files, [], [], [], []] + + wctx = self.workingctx((p1, p2), changes) + commit = wctx.modified() + wctx.added() + remove = wctx.removed() c1 = self.changelog.read(p1) c2 = self.changelog.read(p2)