Differences between revisions 1 and 2
Revision 1 as of 2007-12-03 05:49:44
Size: 957
Editor: mpm
Comment:
Revision 2 as of 2008-02-07 15:39:44
Size: 985
Editor: abuehl
Comment: cat
Deletions are marked like this. Additions are marked like this.
Line 44: Line 44:
----
CategoryContributing

This page has some basic code examples to get you started hacking on hg.

Looking at changesets

Here's some simple code to look at a changeset:

   1 from mercurial import ui, hg
   2 
   3 u = ui.ui()  # get a ui object
   4 r = hg.repository(u, ".") # get a repo object for the current directory
   5 c = r.changectx("tip") # get a context object for the "tip" revision
   6 
   7 # show some information about the changeset
   8 print c # represented as the changeset hash
   9 print c.user()
  10 print c.description()
  11 print
  12 
  13 # let's take a peek at the files
  14 files = c.files()
  15 for f in files:
  16  fc = c[f]
  17  print " ", f, len(fc.data())

And the output looks like this:

$ python lc.py
534ec2689c94
Matt Mackall <mpm@selenic.com>
copy: more cleanups

- remove copyfile src variable
- add some comments
- simplify actual copy logic
- simplify 'undelete' logic
- make the error counting actually work

  mercurial/cmdutil.py 41944


CategoryContributing

DeveloperBasics (last edited 2010-10-15 21:57:56 by abuehl)