Mercurial > hg > hg-git
changeset 39:173e738d0da4
remote management tools
author | Scott Chacon <schacon@gmail.com> |
---|---|
date | Tue, 28 Apr 2009 16:36:57 -0700 |
parents | f0daee676e10 |
children | f5b000ec7100 |
files | TODO.txt __init__.py git_handler.py |
diffstat | 3 files changed, 54 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- a/__init__.py +++ b/__init__.py @@ -44,25 +44,46 @@ 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) + +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")) -def gpull(ui, repo): +def gfetch(ui, repo): 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')), - "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)')), }
--- a/git_handler.py +++ b/git_handler.py @@ -124,11 +124,30 @@ 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() + 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']