[PATCH 4 of 6] localrepo: let commit() get extra data from workingctx
Patrick Mezard
pmezard at gmail.com
Sun Jun 15 12:21:40 CDT 2008
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1213549479 -7200
# Node ID dc756155dde05dccb85cf5f30ea0d41e854dc4cb
# Parent e1e34459da2286d73194012d0f4af14f55d964f5
localrepo: let commit() get extra data from workingctx
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -446,10 +446,11 @@
"""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.
+ extra - a dictionary of extra values, or None.
changes - a list of file lists as returned by localrepo.status()
or None to use the repository status.
"""
- def __init__(self, repo, parents=None, changes=None):
+ def __init__(self, repo, parents=None, extra=None, changes=None):
self._repo = repo
self._rev = None
self._node = None
@@ -458,6 +459,19 @@
self._parents = [self._repo.changectx(p) for p in (p1, p2)]
if changes:
self._status = list(changes)
+
+ self._extra = {}
+ if extra:
+ self._extra = extra.copy()
+ if 'branch' not in self._extra:
+ branch = self._repo.dirstate.branch()
+ try:
+ branch = branch.decode('UTF-8').encode('UTF-8')
+ except UnicodeDecodeError:
+ raise util.Abort(_('branch name not in UTF-8!'))
+ self._extra['branch'] = branch
+ if self._extra['branch'] == '':
+ self._extra['branch'] = 'default'
def __str__(self):
return str(self._parents[0]) + "+"
@@ -518,7 +532,8 @@
def deleted(self): return self._status[3]
def unknown(self): return self._status[4]
def clean(self): return self._status[5]
- def branch(self): return self._repo.dirstate.branch()
+ def branch(self): return self._extra['branch']
+ def extra(self): return self._extra
def tags(self):
t = []
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, changes=None):
- return context.workingctx(self, parents, changes)
+ def workingctx(self, parents=None, extra=None, changes=None):
+ return context.workingctx(self, parents, extra, changes)
def parents(self, changeid=None):
'''
@@ -767,7 +767,6 @@
remove = []
changed = []
use_dirstate = (p1 is None) # not rawcommit
- extra = extra.copy()
if use_dirstate:
p1, p2 = self.dirstate.parents()
@@ -796,23 +795,16 @@
update_dirstate = (self.dirstate.parents()[0] == p1)
changes = [files, [], [], [], []]
- wctx = self.workingctx((p1, p2), changes)
+ wctx = self.workingctx((p1, p2), extra, changes)
commit = wctx.modified() + wctx.added()
remove = wctx.removed()
+ extra = wctx.extra().copy()
+ branchname = extra['branch']
c1 = self.changelog.read(p1)
c2 = self.changelog.read(p2)
m1 = self.manifest.read(c1[0]).copy()
m2 = self.manifest.read(c2[0])
-
- if use_dirstate:
- branchname = wctx.branch()
- try:
- branchname = branchname.decode('UTF-8').encode('UTF-8')
- except UnicodeDecodeError:
- raise util.Abort(_('branch name not in UTF-8!'))
- else:
- branchname = ""
if use_dirstate:
oldname = c1[5].get("branch") # stored in UTF-8
@@ -900,9 +892,6 @@
os.chdir(self.root)
text = self.ui.edit("\n".join(edittext), user)
os.chdir(olddir)
-
- if branchname:
- extra["branch"] = branchname
lines = [line.rstrip() for line in text.rstrip().splitlines()]
while lines and not lines[0]:
More information about the Mercurial-devel
mailing list