##// END OF EJS Templates
docs: add args/returns docs for some cmdutil, context, and registrar functions...
rlevasseur@google.com -
r35106:b22a0d9e default
parent child Browse files
Show More
@@ -1850,7 +1850,13 b' class jsonchangeset(changeset_printer):'
1850 self.ui.write("\n }")
1850 self.ui.write("\n }")
1851
1851
1852 class changeset_templater(changeset_printer):
1852 class changeset_templater(changeset_printer):
1853 '''format changeset information.'''
1853 '''format changeset information.
1854
1855 Note: there are a variety of convenience functions to build a
1856 changeset_templater for common cases. See functions such as:
1857 makelogtemplater, show_changeset, buildcommittemplate, or other
1858 functions that use changesest_templater.
1859 '''
1854
1860
1855 # Arguments before "buffered" used to be positional. Consider not
1861 # Arguments before "buffered" used to be positional. Consider not
1856 # adding/removing arguments before "buffered" to not break callers.
1862 # adding/removing arguments before "buffered" to not break callers.
@@ -1972,7 +1978,8 b' def _lookuplogtemplate(ui, tmpl, style):'
1972 return formatter.lookuptemplate(ui, 'changeset', tmpl)
1978 return formatter.lookuptemplate(ui, 'changeset', tmpl)
1973
1979
1974 def makelogtemplater(ui, repo, tmpl, buffered=False):
1980 def makelogtemplater(ui, repo, tmpl, buffered=False):
1975 """Create a changeset_templater from a literal template 'tmpl'"""
1981 """Create a changeset_templater from a literal template 'tmpl'
1982 byte-string."""
1976 spec = logtemplatespec(tmpl, None)
1983 spec = logtemplatespec(tmpl, None)
1977 return changeset_templater(ui, repo, spec, buffered=buffered)
1984 return changeset_templater(ui, repo, spec, buffered=buffered)
1978
1985
@@ -3860,6 +3867,7 b' def _performrevert(repo, parents, ctx, a'
3860 repo.dirstate.copy(copied[f], f)
3867 repo.dirstate.copy(copied[f], f)
3861
3868
3862 class command(registrar.command):
3869 class command(registrar.command):
3870 """deprecated: used registrar.command instead"""
3863 def _doregister(self, func, name, *args, **kwargs):
3871 def _doregister(self, func, name, *args, **kwargs):
3864 func._deprecatedregistrar = True # flag for deprecwarn in extensions.py
3872 func._deprecatedregistrar = True # flag for deprecwarn in extensions.py
3865 return super(command, self)._doregister(func, name, *args, **kwargs)
3873 return super(command, self)._doregister(func, name, *args, **kwargs)
@@ -615,10 +615,13 b' class changectx(basectx):'
615 def closesbranch(self):
615 def closesbranch(self):
616 return 'close' in self._changeset.extra
616 return 'close' in self._changeset.extra
617 def extra(self):
617 def extra(self):
618 """Return a dict of extra information."""
618 return self._changeset.extra
619 return self._changeset.extra
619 def tags(self):
620 def tags(self):
621 """Return a list of byte tag names"""
620 return self._repo.nodetags(self._node)
622 return self._repo.nodetags(self._node)
621 def bookmarks(self):
623 def bookmarks(self):
624 """Return a list of byte bookmark names."""
622 return self._repo.nodebookmarks(self._node)
625 return self._repo.nodebookmarks(self._node)
623 def phase(self):
626 def phase(self):
624 return self._repo._phasecache.phase(self._repo, self._rev)
627 return self._repo._phasecache.phase(self._repo, self._rev)
@@ -629,7 +632,11 b' class changectx(basectx):'
629 return False
632 return False
630
633
631 def children(self):
634 def children(self):
632 """return contexts for each child changeset"""
635 """return list of changectx contexts for each child changeset.
636
637 This returns only the immediate child changesets. Use descendants() to
638 recursively walk children.
639 """
633 c = self._repo.changelog.children(self._node)
640 c = self._repo.changelog.children(self._node)
634 return [changectx(self._repo, x) for x in c]
641 return [changectx(self._repo, x) for x in c]
635
642
@@ -638,6 +645,10 b' class changectx(basectx):'
638 yield changectx(self._repo, a)
645 yield changectx(self._repo, a)
639
646
640 def descendants(self):
647 def descendants(self):
648 """Recursively yield all children of the changeset.
649
650 For just the immediate children, use children()
651 """
641 for d in self._repo.changelog.descendants([self._rev]):
652 for d in self._repo.changelog.descendants([self._rev]):
642 yield changectx(self._repo, d)
653 yield changectx(self._repo, d)
643
654
@@ -112,35 +112,53 b' class command(_funcregistrarbase):'
112 The created object can be used as a decorator for adding commands to
112 The created object can be used as a decorator for adding commands to
113 that command table. This accepts multiple arguments to define a command.
113 that command table. This accepts multiple arguments to define a command.
114
114
115 The first argument is the command name.
115 The first argument is the command name (as bytes).
116
116
117 The options argument is an iterable of tuples defining command arguments.
117 The `options` keyword argument is an iterable of tuples defining command
118 See ``mercurial.fancyopts.fancyopts()`` for the format of each tuple.
118 arguments. See ``mercurial.fancyopts.fancyopts()`` for the format of each
119 tuple.
119
120
120 The synopsis argument defines a short, one line summary of how to use the
121 The `synopsis` argument defines a short, one line summary of how to use the
121 command. This shows up in the help output.
122 command. This shows up in the help output.
122
123
123 The norepo argument defines whether the command does not require a
124 There are three arguments that control what repository (if any) is found
125 and passed to the decorated function: `norepo`, `optionalrepo`, and
126 `inferrepo`.
127
128 The `norepo` argument defines whether the command does not require a
124 local repository. Most commands operate against a repository, thus the
129 local repository. Most commands operate against a repository, thus the
125 default is False.
130 default is False. When True, no repository will be passed.
126
131
127 The optionalrepo argument defines whether the command optionally requires
132 The `optionalrepo` argument defines whether the command optionally requires
128 a local repository.
133 a local repository. If no repository can be found, None will be passed
134 to the decorated function.
129
135
130 The inferrepo argument defines whether to try to find a repository from the
136 The `inferrepo` argument defines whether to try to find a repository from
131 command line arguments. If True, arguments will be examined for potential
137 the command line arguments. If True, arguments will be examined for
132 repository locations. See ``findrepo()``. If a repository is found, it
138 potential repository locations. See ``findrepo()``. If a repository is
133 will be used.
139 found, it will be used and passed to the decorated function.
134
140
135 There are three constants in the class which tells what type of the command
141 There are three constants in the class which tells what type of the command
136 that is. That information will be helpful at various places. It will be also
142 that is. That information will be helpful at various places. It will be also
137 be used to decide what level of access the command has on hidden commits.
143 be used to decide what level of access the command has on hidden commits.
138 The constants are:
144 The constants are:
139
145
140 unrecoverablewrite is for those write commands which can't be recovered like
146 `unrecoverablewrite` is for those write commands which can't be recovered
141 push.
147 like push.
142 recoverablewrite is for write commands which can be recovered like commit.
148 `recoverablewrite` is for write commands which can be recovered like commit.
143 readonly is for commands which are read only.
149 `readonly` is for commands which are read only.
150
151 The signature of the decorated function looks like this:
152 def cmd(ui[, repo] [, <args>] [, <options>])
153
154 `repo` is required if `norepo` is False.
155 `<args>` are positional args (or `*args`) arguments, of non-option
156 arguments from the command line.
157 `<options>` are keyword arguments (or `**options`) of option arguments
158 from the command line.
159
160 See the WritingExtensions and MercurialApi documentation for more exhaustive
161 descriptions and examples.
144 """
162 """
145
163
146 unrecoverablewrite = "unrecoverable"
164 unrecoverablewrite = "unrecoverable"
General Comments 0
You need to be logged in to leave comments. Login now