mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
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.
This commit is contained in:
parent
d9061cc274
commit
6bc1a87edc
@ -216,19 +216,13 @@ class GitHandler(object):
|
||||
|
||||
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 @@ class GitHandler(object):
|
||||
ref_name.endswith('^{}')):
|
||||
self.git.refs[ref_name] = sha
|
||||
|
||||
self.save_remote_refs()
|
||||
|
||||
# UTILITY FUNCTIONS
|
||||
|
||||
def convert_git_int_mode(self, mode):
|
||||
|
@ -286,6 +286,7 @@ also add an annotated tag
|
||||
$ hg -R hgrepo log -r master
|
||||
changeset: 4:a02330f767a4
|
||||
bookmark: master
|
||||
tag: default/master
|
||||
parent: 3:6f898ad1f3e1
|
||||
parent: 1:7fe02317c63d
|
||||
user: test <test@example.org>
|
||||
|
Loading…
Reference in New Issue
Block a user