changeset 9675:ee913987e4b0

localrepo/branchcache: remove lbranchmap(), convert users to use utf-8 names We don't need a "local-charset" aware branchmap() function, we can convert the names when needed during the output.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 31 Oct 2009 00:31:08 +0100
parents 603b23c6967b
children 48bf28d3c8dd
files mercurial/commands.py mercurial/localrepo.py
diffstat 2 files changed, 12 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat Oct 31 00:27:50 2009 +0100
+++ b/mercurial/commands.py	Sat Oct 31 00:31:08 2009 +0100
@@ -450,8 +450,7 @@
     """
 
     hexfunc = ui.debugflag and hex or short
-    activebranches = [encoding.tolocal(repo[n].branch())
-                            for n in repo.heads()]
+    activebranches = [repo[n].branch() for n in repo.heads()]
     def testactive(tag, node):
         realhead = tag in activebranches
         open = node in repo.branchheads(tag, closed=False)
@@ -462,8 +461,9 @@
 
     for isactive, node, tag in branches:
         if (not active) or isactive:
+            encodedtag = encoding.tolocal(tag)
             if ui.quiet:
-                ui.write("%s\n" % tag)
+                ui.write("%s\n" % encodedtag)
             else:
                 hn = repo.lookup(node)
                 if isactive:
@@ -474,8 +474,8 @@
                     notice = ' (closed)'
                 else:
                     notice = ' (inactive)'
-                rev = str(node).rjust(31 - encoding.colwidth(tag))
-                data = tag, rev, hexfunc(hn), notice
+                rev = str(node).rjust(31 - encoding.colwidth(encodedtag))
+                data = encodedtag, rev, hexfunc(hn), notice
                 ui.write("%s %s:%s%s\n" % data)
 
 def bundle(ui, repo, fname, dest=None, **opts):
@@ -1401,21 +1401,22 @@
         heads = []
         visitedset = set()
         for branchrev in branchrevs:
-            branch = repo[branchrev].branch()
+            branch = repo[encoding.fromlocal(branchrev)].branch()
+            encodedbranch = encoding.tolocal(branch)
             if branch in visitedset:
                 continue
             visitedset.add(branch)
             bheads = repo.branchheads(branch, start, closed=closed)
             if not bheads:
                 if not opts.get('rev'):
-                    ui.warn(_("no open branch heads on branch %s\n") % branch)
+                    ui.warn(_("no open branch heads on branch %s\n") % encodedbranch)
                 elif branch != branchrev:
                     ui.warn(_("no changes on branch %s containing %s are "
                               "reachable from %s\n")
-                            % (branch, branchrev, opts.get('rev')))
+                            % (encodedbranch, branchrev, opts.get('rev')))
                 else:
                     ui.warn(_("no changes on branch %s are reachable from %s\n")
-                            % (branch, opts.get('rev')))
+                            % (encodedbranch, opts.get('rev')))
             if hideinactive:
                 bheads = [bhead for bhead in bheads if bhead in _heads]
             heads.extend(bheads)
--- a/mercurial/localrepo.py	Sat Oct 31 00:27:50 2009 +0100
+++ b/mercurial/localrepo.py	Sat Oct 31 00:31:08 2009 +0100
@@ -318,16 +318,6 @@
 
         return partial
 
-    def lbranchmap(self):
-        branchcache = {}
-        partial = self.branchmap()
-
-        # the branch cache is stored on disk as UTF-8, but in the local
-        # charset internally
-        for k, v in partial.iteritems():
-            branchcache[encoding.tolocal(k)] = v
-        return branchcache
-
     def branchmap(self):
         tip = self.changelog.tip()
         if self._branchcache is not None and self._branchcachetip == tip:
@@ -351,7 +341,7 @@
         '''return a dict where branch names map to the tipmost head of
         the branch, open heads come before closed'''
         bt = {}
-        for bn, heads in self.lbranchmap().iteritems():
+        for bn, heads in self.branchmap().iteritems():
             head = None
             for i in range(len(heads)-1, -1, -1):
                 h = heads[i]
@@ -1167,7 +1157,7 @@
         '''
         if branch is None:
             branch = self[None].branch()
-        branches = self.lbranchmap()
+        branches = self.branchmap()
         if branch not in branches:
             return []
         # the cache returns heads ordered lowest to highest