diff --git a/TODO.txt b/TODO.txt index f0daee676e108ccd9f72a3dba24a60dc478962df_VE9ETy50eHQ=..173e738d0da45634ab0b0a5d667df4535f38c945_VE9ETy50eHQ= 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,7 +1,6 @@ GENERAL ========== -* remote management * submodules? * switch object mapping to hg->git since the many to one is that direction * file modes @@ -10,15 +9,9 @@ PUSH ========== -* get a list of all the hg changesets not yet mapped -* create git objects from each changeset (incl trees/blobs) - - add metadata to commits (branch names, explicit file names) -* update mapfile with new changeset/commit mapping -* connect to server pushing to - - figure out needs (use heads/bookmarks for haves) -* create packfile with needed objects - - some delta compression if possible (?) -* upload packfile, remove temp packfile +* update 'remote' references after push confirmation +* push confirmation? is there extra data after the packfile upload? +* output something after process is complete * convert tags to git diff --git a/__init__.py b/__init__.py index f0daee676e108ccd9f72a3dba24a60dc478962df_X19pbml0X18ucHk=..173e738d0da45634ab0b0a5d667df4535f38c945_X19pbml0X18ucHk= 100644 --- a/__init__.py +++ b/__init__.py @@ -44,6 +44,6 @@ node = git.remote_head('origin') hg.update(dest_repo, node) -def gpush(ui, repo, remote_name='origin'): +def gpush(ui, repo, remote_name='origin', branch=None): git = GitHandler(repo, ui) git.push(remote_name) @@ -48,3 +48,24 @@ git = GitHandler(repo, ui) git.push(remote_name) + +def gremote(ui, repo, *args): + git = GitHandler(repo, ui) + + if len(args) == 0: + git.remote_list() + else: + verb = args[0] + nick = args[1] + + if verb == 'add': + if args[2]: + git.remote_add(nick, args[2]) + else: + repo.ui.warn(_("must supply a url to add as a remote\n")) + elif verb == 'rm': + git.remote_remove(nick) + elif verb == 'show': + git.remote_show(nick) + else: + repo.ui.warn(_("unrecognized command to gremote\n")) @@ -50,7 +71,7 @@ -def gpull(ui, repo): +def gfetch(ui, repo): dest_repo.ui.status(_("pulling from git url\n")) commands.norepo += " gclone" cmdtable = { "gclone": @@ -52,12 +73,10 @@ dest_repo.ui.status(_("pulling from git url\n")) commands.norepo += " gclone" cmdtable = { "gclone": - (gclone, - [ #('A', 'authors', '', 'username mapping filename'), - ], - 'Clone a git repository into an hg repository.', + (gclone, [], + _('Clone a git repository into an hg repository.'), ), "gpush": (gpush, [], _('hg gpush remote')), @@ -61,8 +80,10 @@ ), "gpush": (gpush, [], _('hg gpush remote')), - "gpull": - (gpull, - [('m', 'merge', None, _('merge automatically'))], - _('hg gpull [--merge] remote')), + "gfetch": + (gfetch, [], + #[('m', 'merge', None, _('merge automatically'))], + _('hg gfetch remote')), + "gremote": + (gremote, [], _('hg gremote add remote (url)')), } diff --git a/git_handler.py b/git_handler.py index f0daee676e108ccd9f72a3dba24a60dc478962df_Z2l0X2hhbmRsZXIucHk=..173e738d0da45634ab0b0a5d667df4535f38c945_Z2l0X2hhbmRsZXIucHk= 100644 --- a/git_handler.py +++ b/git_handler.py @@ -124,8 +124,7 @@ 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 self.save_config() @@ -128,7 +127,27 @@ def remote_add(self, remote_name, git_url): self._config['remote.' + remote_name + '.url'] = git_url self.save_config() + def remote_remove(self, remote_name): + key = 'remote.' + remote_name + '.url' + if key in self._config: + del self._config[key] + self.save_config() + + def remote_show(self, remote_name): + key = 'remote.' + remote_name + '.url' + if key in self._config: + name = self._config[key] + print "URL for " + remote_name + " : " + name + else: + print "No remote named : " + remote_name + return + + def remote_list(self): + for key, value in self._config.iteritems(): + if key[0:6] == 'remote': + print key + "\t" + value + def remote_name_to_url(self, remote_name): return self._config['remote.' + remote_name + '.url']