[PATCH 3 of 6] localrepo: hide commit() file selection behind workingctx
Patrick Mezard
pmezard at gmail.com
Sun Jun 15 12:21:39 CDT 2008
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1213549479 -7200
# Node ID e1e34459da2286d73194012d0f4af14f55d964f5
# Parent 7e232ca1faf6602ad12a880c1e381be3ead1610c
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 @@
"""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 @@
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 @@
(match and (match.files() or match.anypats()))):
raise util.Abort(_('cannot partially commit a merge '
'(do not specify files or patterns)'))
+
+ if files:
+ modified, removed = [], []
+ for f in files:
+ s = self.dirstate[f]
+ if s in 'nma':
+ modified.append(f)
+ elif s == 'r':
+ removed.append(f)
+ else:
+ self.ui.warn(_("%s not tracked!\n") % f)
+ changes = [modified, [], removed, [], []]
+ else:
+ changes = self.status(match=match)
else:
p1, p2 = p1, p2 or nullid
update_dirstate = (self.dirstate.parents()[0] == p1)
+ changes = [files, [], [], [], []]
- wctx = self.workingctx((p1, p2))
-
- if use_dirstate:
- if files:
- for f in files:
- s = self.dirstate[f]
- if s in 'nma':
- commit.append(f)
- elif s == 'r':
- remove.append(f)
- else:
- self.ui.warn(_("%s not tracked!\n") % f)
- else:
- changes = self.status(match=match)[:5]
- modified, added, removed, deleted, unknown = changes
- commit = modified + added
- remove = removed
- else:
- commit = 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)
More information about the Mercurial-devel
mailing list