Differences between revisions 3 and 4
Revision 3 as of 2008-04-07 22:08:41
Size: 984
Editor: abuehl
Comment: changed cat
Revision 4 as of 2008-04-07 22:46:40
Size: 1046
Editor: abuehl
Comment: +title, +see also MercurialApi
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
This page has some basic code examples to get you started hacking on hg. == Developer Basics ==

This page has some basic code examples to get you started hacking on hg. See also MercurialApi.
Line 5: Line 7:
Here's some simple code to look at a changeset: Here's some simple code to look at a [:ChangeSet:changeset]:

Developer Basics

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

Looking at changesets

Here's some simple code to look at a [:ChangeSet: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


CategoryInternals

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