changeset 733:a67fecf02adb

commands: switch to new-style declaration via decorators This is supported in all the versions that hg-git supports.
author Siddharth Agarwal <sid0@fb.com>
date Mon, 19 May 2014 19:03:02 -0700
parents 705f0a2a7c18
children 5e53342c846b
files hggit/__init__.py
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -22,6 +22,7 @@
 import os
 
 from mercurial import bundlerepo
+from mercurial import cmdutil
 from mercurial import commands
 from mercurial import demandimport
 from mercurial import dirstate
@@ -50,6 +51,9 @@
 testedwith = '2.8.2 3.0'
 buglink = 'https://bitbucket.org/durin42/hg-git/issues'
 
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
 # support for `hg clone git://github.com/defunkt/facebox.git`
 # also hg clone git+ssh://git@github.com/schacon/simplegit.git
 _gitschemes = ('git', 'git+ssh', 'git+http', 'git+https')
@@ -117,16 +121,22 @@
         klass = hgrepo.generate_repo_subclass(repo.__class__)
         repo.__class__ = klass
 
+@command('gimport', [], _('hg gimport'))
 def gimport(ui, repo, remote_name=None):
     repo.githandler.import_commits(remote_name)
 
+@command('gexport', [], _('hg gexport'))
 def gexport(ui, repo):
     repo.githandler.export_commits()
 
+@command('gclear', [], _('Clears out the Git cached data'))
 def gclear(ui, repo):
     repo.ui.status(_("clearing out the git cache data\n"))
     repo.githandler.clear()
 
+@command('gverify',
+         [('r', 'rev', '', _('revision to verify'), _('REV'))],
+         _('[-r REV]'))
 def gverify(ui, repo, **opts):
     '''verify that a Mercurial rev matches the corresponding Git rev
 
@@ -145,6 +155,7 @@
     extensions.wrapfunction(ignore, 'ignore', gitdirstate.gignore)
     dirstate.dirstate = gitdirstate.gitdirstate
 
+@command('git-cleanup', [], _('Cleans up git repository after history editing'))
 def git_cleanup(ui, repo):
     new_map = []
     for line in repo.opener(GitHandler.mapfile):
@@ -229,15 +240,3 @@
         gitnode = ''
     return gitnode
 
-cmdtable = {
-  "gimport":
-        (gimport, [], _('hg gimport')),
-  "gexport":
-        (gexport, [], _('hg gexport')),
-  "gclear":
-      (gclear, [], _('Clears out the Git cached data')),
-  "git-cleanup": (git_cleanup, [], _(
-        "Cleans up git repository after history editing")),
-  "gverify": (gverify,
-    [('r', 'rev', '', _('revision to verify'), _('REV'))], _('[-r REV]')),
-}