Autogenerate command table.
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Wed, 25 May 2011 02:27:40 +0200
changeset 18 9ffe946febc0
parent 17 6aa349f47e7c
child 19 8784a989a572
Autogenerate command table.
states.py
--- a/states.py	Wed May 25 02:27:09 2011 +0200
+++ b/states.py	Wed May 25 02:27:40 2011 +0200
@@ -107,21 +107,18 @@
 # New commands
 #############################
 
-def cmdpublished(ui, repo, *changesets):
-    revs = scmutil.revrange(repo, changesets)
-    repo.setstate(ST0, [repo.changelog.node(rev) for rev in revs])
-    return 0
+cmdtable = {}
 
-def cmdready(ui, repo, *changesets):
-    revs = scmutil.revrange(repo, changesets)
-    repo.setstate(ST1, [repo.changelog.node(rev) for rev in revs])
-    return 0
-
-#autogen this
-cmdtable = {
-    'published':  (cmdpublished,   [], _('<revset>')),
-    'ready':  (cmdready,   [], _('<revset>')),
-    }
+def makecmd(state):
+    def cmdmoveheads(ui, repo, *changesets):
+        revs = scmutil.revrange(repo, changesets)
+        repo.setstate(state, [repo.changelog.node(rev) for rev in revs])
+        return 0
+    return cmdmoveheads
+for state in STATES:
+    if state.trackheads:
+        cmdmoveheads = makecmd(state)
+        cmdtable[state.name] = (cmdmoveheads, [], '<revset>')