359310219944 — Paul Nathan 8 years ago
Merged in matclab/guestrepo-pnathan-pr/hg-1.8-cmd-registration (pull request #5)

Use new command decorator for command registration
1 files changed, 23 insertions(+), 20 deletions(-)

M guestrepo/__init__.py
M guestrepo/__init__.py +23 -20
@@ 89,10 89,12 @@ 
 
 from guestrepo import pull, push, grupdate, freeze, summary, state, grout, grin
 from guestrepo import colortable
+from mercurial import cmdutil
 
 import convert
 import lockedui
 
+
 # XXX It is supposed to work from mercurial 2.1 yet but I did not run the test
 # with other version yet. This temporary commit encourage people using other
 # version to update the content of this variable.

          
@@ 119,52 121,53 @@ jsonopt = [('', 'json', False,
 # Command table for the guestrepo extension
 # See the readme for a description of each command
 # format: {"command-name": (function, options-list, help-string)}
-cmdtable = {
-   "grpull": (pull,
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
+command("grpull",
               localopt + threadopt
               + [('u', 'update', False, "grupdate after grpull")],
-              "hg grpull [REPO [+]] [options]"),
-   "grpush": (push,
+              "hg grpull [REPO [+]] [options]")(pull)
+command("grpush",
               localopt + threadopt
               + [('', 'new-branch', False, "create new branches if necessary"),
                  ('', 'frozen', False, "only revision specified in grstate"),
                 ],
-              "hg grpush [REPO [+]] [options]"),
-   "grupdate": (grupdate,
+              "hg grpush [REPO [+]] [options]")(push)
+command("grupdate",
                 localopt + threadopt
                 # TODO: clean may be the wrong term.
                 + [('C', 'clean', False, 'ensure every non-guest repos is updated to revision -1')]
                 + [('P', 'purge', False, 'also run a "hg purge" in guest repos when cleaning (--clean)')]
                 + [('p', 'pull', False, "grpull before running grupdate")]
                 + [('f', 'file', '', "update using a .hgguestrepo file", 'FILE')],
-                "hg grupdate [REPO [+]] [options]"),
-   "grfreeze": (freeze,
+                "hg grupdate [REPO [+]] [options]")(grupdate)
+command("grfreeze",
                 [('f', 'file', '', "output state to a .hggrfrozen file",  'FILE'),
                  ('p', 'publish', False, "publish all record changeset"),
                  ('k', 'keep', False, "keep previous changeid of unmodified guests"),]
                 + threadopt,
-                "hg grfreeze"),
-   "grsummary": (summary,
+                "hg grfreeze")(freeze)
+command("grsummary",
                  [("i", "id", False, "Print the short changeset id"),
                   ("p", "phase", False, "Print phase information"), ]
                  + jsonopt + localopt,
-                 "hg grsummary"),
-   "grstate": (state,
+                 "hg grsummary")(summary)
+command("grstate",
                [('k', 'keep', False, "keep previous changeid of unmodified guests"),]
                + jsonopt + localopt,
-               "hg grstate"),
-   "grout" : (grout,
+               "hg grstate")(state)
+command("grout",
               localopt + threadopt + jsonopt,
-              "hg grout"),
-   "grin" : (grin,
+              "hg grout")(grout)
+command("grin",
              localopt + threadopt + jsonopt,
-             "hg grin"),
-   "grconvert": (convert.convert,
+             "hg grin")(grin)
+command("grconvert",
                  [('b', 'branch', False,
                    "write the current branch of each subrepo instead of the changeset")
                  ],
-                 "hg grconvert [--branch]")
-   }
+                 "hg grconvert [--branch]")(convert.convert)
 
 # hook run at mercurial startup just after ui object is created
 def uisetup(ui):