Commits

Markus Zapke-Gründemann  committed 7021062

Added more comments explaining the code.

  • Participants
  • Parent commits 4828828

Comments (0)

Files changed (2)

 syntax: glob
 
 *.err
+pylintrc
 run-tests.py

File printparents.py

 """
 from mercurial import util
 
+# Every command must take ui and and repo as arguments.
+# opts is a dict where you can find other command line flags.
+#
+# Other parameters are taken in order from items on the command line that
+# don't start with a dash. If no default value is given in the parameter list,
+# they are required.
+#
+# For experimenting with Mercurial in the python interpreter:
+# Getting the repository of the current dir:
+#    >>> from mercurial import hg, ui
+#    >>> repo = hg.repository(ui.ui(), path = ".")
 
 def printparents(ui, repo, node, **opts):
+    # The doc string below will show up in hg help.
     """Print parent information."""
+    # repo can be indexed based on tags, an sha1, or a revision number.
     ctx = repo[node]
     parents = ctx.parents()
 
     try:
         if opts['short']:
+            # The string representation of a context returns a smaller portion
+            # of the sha1.
             ui.write('short %s %s\n' % (parents[0], parents[1]))
         elif opts['long']:
+            # The hex representation of a context returns the full sha1.
             ui.write('long %s %s\n' % (parents[0].hex(), parents[1].hex()))
         else:
             ui.write('default %s %s\n' % (parents[0], parents[1]))
 
 
 cmdtable = {
+    # cmd name        function call
     'print-parents': (printparents,
-         [('s', 'short', None, 'print short form'),
-          ('l', 'long', None, 'print long form')],
-         '[options] REV')
+        # See mercurial/fancyopts.py for all of the command flag options.
+        [('s', 'short', None, 'print short form'),
+        ('l', 'long', None, 'print long form')],
+        '[options] REV')
 }