[PATCH 2 of 9] make repo.branchcache hold a list of nodes
Alexis S. L. Carvalho
alexis at cecm.usp.br
Sun Mar 2 13:01:24 CST 2008
# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Date 1204481759 10800
# Node ID 8894448ad0e8d4aa0ce51a5da4181ecb1c58b24c
# Parent dd43ec3d30cd13f3925bd51006e0e2699f74ad8a
make repo.branchcache hold a list of nodes
diff -r dd43ec3d30cd -r 8894448ad0e8 mercurial/commands.py
--- a/mercurial/commands.py Sun Mar 02 15:15:59 2008 -0300
+++ b/mercurial/commands.py Sun Mar 02 15:15:59 2008 -0300
@@ -373,7 +373,10 @@ def branches(ui, repo, active=False):
"""
b = repo.branchtags()
heads = dict.fromkeys(repo.heads(), 1)
- l = [((n in heads), repo.changelog.rev(n), n, t) for t, n in b.items()]
+ l = []
+ for t, nodes in b.iteritems():
+ for n in nodes:
+ l.append(((n in heads), repo.changelog.rev(n), n, t))
l.sort()
l.reverse()
for ishead, r, n, t in l:
diff -r dd43ec3d30cd -r 8894448ad0e8 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py Sun Mar 02 15:15:59 2008 -0300
+++ b/mercurial/hgweb/hgweb_mod.py Sun Mar 02 15:15:59 2008 -0300
@@ -362,7 +362,7 @@ class hgweb(object):
# If this is an empty repo, ctx.node() == nullid,
# ctx.branch() == 'default', but branchtags() is
# an empty dict. Using dict.get avoids a traceback.
- if self.repo.branchtags().get(branch) == ctx.node():
+ if ctx.node() in self.repo.branchtags().get(branch, ()):
branches.append({"name": branch})
return branches
@@ -802,7 +802,10 @@ class hgweb(object):
parity = paritygen(self.stripecount)
b = self.repo.branchtags()
- l = [(-self.repo.changelog.rev(n), n, t) for t, n in b.items()]
+ l = []
+ for t, nodes in b.iteritems():
+ for n in nodes:
+ l.append((-self.repo.changelog.rev(n), n, t))
l.sort()
for r,n,t in l:
diff -r dd43ec3d30cd -r 8894448ad0e8 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sun Mar 02 15:15:59 2008 -0300
+++ b/mercurial/localrepo.py Sun Mar 02 15:15:59 2008 -0300
@@ -398,9 +398,11 @@ class localrepository(repo.repository):
# invalidate the cache
raise ValueError('invalidating branch cache (tip differs)')
for l in lines:
- if not l: continue
+ if not l:
+ continue
node, label = l.split(" ", 1)
- partial[label.strip()] = bin(node)
+ label = label.strip()
+ partial[label] = [bin(node)]
except (KeyboardInterrupt, util.SignalInterrupt):
raise
except Exception, inst:
@@ -413,8 +415,9 @@ class localrepository(repo.repository):
try:
f = self.opener("branch.cache", "w", atomictemp=True)
f.write("%s %s\n" % (hex(tip), tiprev))
- for label, node in branches.iteritems():
- f.write("%s %s\n" % (hex(node), label))
+ for label, nodes in branches.iteritems():
+ for n in nodes:
+ f.write("%s %s\n" % (hex(n), label))
f.rename()
except (IOError, OSError):
pass
@@ -423,7 +426,7 @@ class localrepository(repo.repository):
for r in xrange(start, end):
c = self.changectx(r)
b = c.branch()
- partial[b] = c.node()
+ partial[b] = [c.node()]
def lookup(self, key):
if key == '.':
@@ -441,7 +444,7 @@ class localrepository(repo.repository):
if key in self.tags():
return self.tags()[key]
if key in self.branchtags():
- return self.branchtags()[key]
+ return self.branchtags()[key][-1]
n = self.changelog._partialmatch(key)
if n:
return n
@@ -1215,7 +1218,7 @@ class localrepository(repo.repository):
# efficient way to do this as part of the previous algorithm.
set = util.set
- heads = [self.changelog.rev(branches[branch])]
+ heads = [max([self.changelog.rev(n) for n in branches[branch]])]
# Don't care if ancestors contains nullrev or not.
ancestors = set(self.changelog.parentrevs(heads[0]))
for rev in xrange(heads[0] - 1, nullrev, -1):
diff -r dd43ec3d30cd -r 8894448ad0e8 mercurial/merge.py
--- a/mercurial/merge.py Sun Mar 02 15:15:59 2008 -0300
+++ b/mercurial/merge.py Sun Mar 02 15:15:59 2008 -0300
@@ -571,7 +571,7 @@ def update(repo, node, branchmerge, forc
if node is None:
# tip of current branch
try:
- node = repo.branchtags()[wc.branch()]
+ node = repo.branchtags()[wc.branch()][-1]
except KeyError:
if wc.branch() == "default": # no default branch!
node = repo.lookup("tip") # update to tip
More information about the Mercurial-devel
mailing list