diff --git a/__init__.py b/__init__.py index 58cd0512911931eeae9da4d24ed3a760e4ff4f1e_X19pbml0X18ucHk=..ace0f6ed65a10cd71b74cedac78099fdcf9f197e_X19pbml0X18ucHk= 100644 --- a/__init__.py +++ b/__init__.py @@ -44,9 +44,9 @@ node = git.remote_head('origin') hg.update(dest_repo, node) -def gpush(ui, repo, remote_name): - # determine new repo name - dest_repo.ui.status(_("pushing to git url\n")) +def gpush(ui, repo, remote_name='origin'): + git = GitHandler(repo, ui) + git.push(remote_name) def gpull(ui, repo): dest_repo.ui.status(_("pulling from git url\n")) @@ -60,7 +60,5 @@ 'Clone a git repository into an hg repository.', ), "gpush": - (gpush, - [('m', 'merge', None, _('merge automatically'))], - _('hg gpush remote')), + (gpush, [], _('hg gpush remote')), "gpull": @@ -66,3 +64,5 @@ "gpull": - (gpull, [], _('hg gpull [--merge] remote')), + (gpull, + [('m', 'merge', None, _('merge automatically'))], + _('hg gpull [--merge] remote')), } diff --git a/git_handler.py b/git_handler.py index 58cd0512911931eeae9da4d24ed3a760e4ff4f1e_Z2l0X2hhbmRsZXIucHk=..ace0f6ed65a10cd71b74cedac78099fdcf9f197e_Z2l0X2hhbmRsZXIucHk= 100644 --- a/git_handler.py +++ b/git_handler.py @@ -18,4 +18,5 @@ self.load_map() self.load_config() + # make the git data directory def init_if_missing(self): @@ -21,3 +22,2 @@ def init_if_missing(self): - # make the git data directory git_hg_path = os.path.join(self.repo.path, 'git') @@ -23,6 +23,7 @@ git_hg_path = os.path.join(self.repo.path, 'git') - os.mkdir(git_hg_path) - dulwich.repo.Repo.init_bare(git_hg_path) + if not os.path.exists(git_hg_path): + os.mkdir(git_hg_path) + dulwich.repo.Repo.init_bare(git_hg_path) def load_git(self): git_dir = os.path.join(self.repo.path, 'git') @@ -66,6 +67,12 @@ self.import_git_objects(remote_name) self.save_map() + def push(self, remote_name): + self.ui.status(_("pushing to : " + remote_name + "\n")) + self.export_git_objects() + self.upload_pack(remote_name) + self.save_map() + # TODO: make these actually save and recall def remote_add(self, remote_name, git_url): self._config['remote.' + remote_name + '.url'] = git_url @@ -79,6 +86,9 @@ if head == 'HEAD': return self._map[sha] return None + + def upload_pack(self, remote_name): + self.ui.status(_("upload pack\n")) def fetch_pack(self, remote_name): git_url = self.remote_name_to_url(remote_name)