Mercurial > hg > hg-git
changeset 930:1a1d90e38651
refs: use dulwich to read remote refs
It is unclear to me why we keep a file (which can become out of sync) of remote
refs instead of just using dulwich. This caught a missing remote ref in the
test suite.
author | Sean Farley <sean@farley.io> |
---|---|
date | Sat, 16 May 2015 19:43:26 -0700 |
parents | 983126c08bad |
children | a12e11d9fb11 |
files | hggit/git_handler.py tests/test-pull.t |
diffstat | 2 files changed, 8 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -216,19 +216,13 @@ def load_remote_refs(self): self._remote_refs = {} - tagfile = self.repo.join(self.remote_refs_file) - if os.path.exists(tagfile): - tf = open(tagfile, 'rb') - tagdata = tf.read().split('\n') - td = [line.split(' ', 1) for line in tagdata if line] - self._remote_refs.update([(name, bin(sha)) for sha, name in td]) - - def save_remote_refs(self): - file = self.repo.opener(self.remote_refs_file, 'w+', atomictemp=True) - for tag, node in self.remote_refs.iteritems(): - file.write('%s %s\n' % (hex(node), tag)) - # If this complains, atomictempfile no longer has close - file.close() + for k, v in self.git.refs.as_dict().iteritems(): + if k.startswith('refs/remotes'): + k = k.replace('refs/remotes/', '') + try: + self._remote_refs[k] = bin(self._map_git[v]) + except KeyError: + pass # END FILE LOAD AND SAVE METHODS @@ -1334,8 +1328,6 @@ ref_name.endswith('^{}')): self.git.refs[ref_name] = sha - self.save_remote_refs() - # UTILITY FUNCTIONS def convert_git_int_mode(self, mode):