Mercurial > hg > hg-git
changeset 819:2c5e41d670b5
git_handler: return filtered refs as an OrderedDict
This actually has no direct impact here, but it allows extensions to customize
the list of filtered refs and be sure of the order in which they'll be
processed.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Fri, 31 Oct 2014 10:40:58 -0700 (2014-10-31) |
parents | bfe8c8e0d29c |
children | 826296785e8b |
files | hggit/git_handler.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1047,7 +1047,7 @@ that match the heads. Otherwise, return refs that are heads or tags. ''' - filteredrefs = {} + filteredrefs = [] if heads is not None: # contains pairs of ('refs/(heads|tags|...)/foo', 'foo') # if ref is just '<foo>', then we get ('foo', 'foo') @@ -1059,7 +1059,7 @@ if not r: raise hgutil.Abort("ref %s not found on remote server" % h) elif len(r) == 1: - filteredrefs[r[0]] = refs[r[0]] + filteredrefs.append(r[0]) else: raise hgutil.Abort("ambiguous reference %s: %r" % (h, r)) else: @@ -1067,8 +1067,12 @@ if (not ref.endswith('^{}') and (ref.startswith('refs/heads/') or ref.startswith('refs/tags/'))): - filteredrefs[ref] = sha - return filteredrefs + filteredrefs.append(ref) + + # the choice of OrderedDict vs plain dict has no impact on stock hg-git, + # but allows extensions to customize the order in which refs are + # returned + return util.OrderedDict((r, refs[r]) for r in filteredrefs) def update_references(self): exportable = self.get_exportable()