Skip to content
Snippets Groups Projects
Commit 40edc4b8 authored by Abderrahim Kitouni's avatar Abderrahim Kitouni
Browse files

Reorganize push for more symmetry with fetch

parent e09d71dc
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,8 @@
elif not self.paths:
# intial cloning
self.update_remote_branches('default', refs)
else:
self.ui.status(_("nothing new on the server\n"))
self.save_map()
......@@ -119,7 +121,7 @@
self.update_references()
self.save_map()
def push(self, remote_name):
self.fetch(remote_name) # get and convert objects if they already exist
self.ui.status(_("pushing to : %s\n") % remote_name)
def push(self, remote):
self.fetch(remote) # get and convert objects if they already exist
self.ui.status(_("pushing to : %s\n") % remote)
self.export_commits(False)
......@@ -125,6 +127,13 @@
self.export_commits(False)
self.update_remote_references(remote_name)
self.upload_pack(remote_name)
changed_refs = self.upload_pack(remote)
remote_name = self.remote_name(remote)
if remote_name and changed_refs:
for ref, sha in changed_refs.iteritems():
self.ui.status(" "+ remote_name + "::" + ref + " => GIT:" + sha[0:8] + "\n")
self.update_remote_branches(remote_name, changed_refs)
def clear(self):
mapfile = self.repo.join(self.mapfile)
......@@ -557,14 +566,6 @@
try:
self.ui.status(_("creating and sending data\n"))
changed_refs = client.send_pack(path, changed, genpack)
remote_name = self.remote_name(remote)
if remote_name and changed_refs:
new_refs = {}
for ref, sha in changed_refs.iteritems():
self.ui.status(" "+ remote_name + "::" + ref + " => GIT:" + sha[0:8] + "\n")
new_refs[ref] = sha
self.git.set_remote_refs(new_refs, remote_name)
self.update_remote_branches(remote_name, new_refs)
except:
# TODO : remove try/except or do something useful here
raise
......@@ -675,10 +676,6 @@
refs = client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)
f.close()
commit()
if refs:
self.git.set_remote_refs(refs, remote_name)
else:
self.ui.status(_("nothing new on the server\n"))
return refs
finally:
f.close()
......@@ -698,11 +695,6 @@
if self.repo.tagtype(tag) == 'git':
self.git.set_ref('refs/tags/' + tag, self.map_git_get(hex(sha)))
# Make sure there's a refs/remotes/remote_name/name
# for every refs/heads/name
def update_remote_references(self, remote_name):
self.git.set_remote_refs(self.local_heads(), remote_name)
def local_heads(self):
try:
bms = bookmarks.parse(self.repo)
......@@ -768,6 +760,9 @@
tag = '%s/%s' % (remote_name, head)
self.repo.tag(tag, hgsha, '', True, None, None)
self.git.set_remote_refs(refs, remote_name)
## UTILITY FUNCTIONS
def convert_git_int_mode(self, mode):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment