Patchwork [1,of,4] localrepo: add _findlocaltags method

login
register
mail settings
Submitter Sean Farley
Date March 28, 2014, 1:15 a.m.
Message ID <795f649f5a9fabb7bf05.1395969336@laptop.local>
Download mbox | patch
Permalink /patch/4090/
State Superseded
Headers show

Comments

Sean Farley - March 28, 2014, 1:15 a.m.
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1395964833 18000
#      Thu Mar 27 19:00:33 2014 -0500
# Node ID 795f649f5a9fabb7bf05d51bb8a2f82451a80512
# Parent  dfad9bb23ab49bd461544c1d5fab3318ab637d23
localrepo: add _findlocaltags method

This method will be used in future patches to allow access to only getting the
local tags. This will allow us to improve performance to avoid the cost of
building the tag cache for large repos with many heads.
Sean Farley - March 28, 2014, 4:59 p.m.
Sean Farley <sean.michael.farley@gmail.com> writes:

> # HG changeset patch
> # User Sean Farley <sean.michael.farley@gmail.com>
> # Date 1395964833 18000
> #      Thu Mar 27 19:00:33 2014 -0500
> # Node ID 795f649f5a9fabb7bf05d51bb8a2f82451a80512
> # Parent  dfad9bb23ab49bd461544c1d5fab3318ab637d23
> localrepo: add _findlocaltags method
>
> This method will be used in future patches to allow access to only getting the
> local tags. This will allow us to improve performance to avoid the cost of
> building the tag cache for large repos with many heads.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -603,15 +603,33 @@ class localrepository(object):
>  
>          # Build the return dicts.  Have to re-encode tag names because
>          # the tags module always uses UTF-8 (in order not to lose info
>          # writing to the cache), but the rest of Mercurial wants them in
>          # local encoding.
> +        for (name, (node, hist)) in alltags.iteritems():
> +            if node != nullid:
> +                tags[encoding.tolocal(name)] = node
> +        tags['tip'] = self.changelog.tip()
> +        tagtypes = dict([(encoding.tolocal(name), value)
> +                         for (name, value) in tagtypes.iteritems()])
> +
> +        return (tags, tagtypes)
> +
> +    def _findlocaltags(self):
> +        alltags = {}
> +        tagtypes = {}
> +
> +        tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
> +
> +        # Build the return dicts.  Have to re-encode tag names because
> +        # the tags module always uses UTF-8 (in order not to lose info
> +        # writing to the cache), but the rest of Mercurial wants them in
> +        # local encoding.
>          tags = {}
>          for (name, (node, hist)) in alltags.iteritems():
>              if node != nullid:
>                  tags[encoding.tolocal(name)] = node
> -        tags['tip'] = self.changelog.tip()
>          tagtypes = dict([(encoding.tolocal(name), value)
>                           for (name, value) in tagtypes.iteritems()])
>          return (tags, tagtypes)
>  
>      def tagtype(self, tagname):

Pierre-Yves mentioned that these functions should have doc strings, so
go ahead and drop this series.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -603,15 +603,33 @@  class localrepository(object):
 
         # Build the return dicts.  Have to re-encode tag names because
         # the tags module always uses UTF-8 (in order not to lose info
         # writing to the cache), but the rest of Mercurial wants them in
         # local encoding.
+        for (name, (node, hist)) in alltags.iteritems():
+            if node != nullid:
+                tags[encoding.tolocal(name)] = node
+        tags['tip'] = self.changelog.tip()
+        tagtypes = dict([(encoding.tolocal(name), value)
+                         for (name, value) in tagtypes.iteritems()])
+
+        return (tags, tagtypes)
+
+    def _findlocaltags(self):
+        alltags = {}
+        tagtypes = {}
+
+        tagsmod.readlocaltags(self.ui, self, alltags, tagtypes)
+
+        # Build the return dicts.  Have to re-encode tag names because
+        # the tags module always uses UTF-8 (in order not to lose info
+        # writing to the cache), but the rest of Mercurial wants them in
+        # local encoding.
         tags = {}
         for (name, (node, hist)) in alltags.iteritems():
             if node != nullid:
                 tags[encoding.tolocal(name)] = node
-        tags['tip'] = self.changelog.tip()
         tagtypes = dict([(encoding.tolocal(name), value)
                          for (name, value) in tagtypes.iteritems()])
         return (tags, tagtypes)
 
     def tagtype(self, tagname):