changeset 221:2bfe525ef6ca

Beginning of multi-head support -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Beginning of multi-head support Add revlog.heads() Add heads command to list changeset heads manifest hash: 50df6fffe59a40c19782e2c77c8077db026fde67 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCn7tFywK+sNU5EO8RAusWAJ9EojIxgqEEt8VZd5S+5Laj8tHV+ACfWLb5 TC7AnsoFGg50jAWF0EsofDA= =nzyH -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 02 Jun 2005 18:07:01 -0800
parents 3113a94c1bff
children 87484f627422
files mercurial/commands.py mercurial/revlog.py
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jun 02 17:39:29 2005 -0800
+++ b/mercurial/commands.py	Thu Jun 02 18:07:01 2005 -0800
@@ -1,4 +1,4 @@
-import os, re, traceback, sys, signal
+import os, re, traceback, sys, signal, time
 from mercurial import fancyopts, ui, hg
 
 class UnknownCommand(Exception): pass
@@ -122,6 +122,26 @@
         for p,l in zip(zip(*pieces), lines):
             u.write(" ".join(p) + ": " + l[1])
 
+def heads(ui, repo):
+    '''show current repository heads'''
+    for n in repo.changelog.heads():
+        i = repo.changelog.rev(n)
+        changes = repo.changelog.read(n)
+        (p1, p2) = repo.changelog.parents(n)
+        (h, h1, h2) = map(hg.hex, (n, p1, p2))
+        (i1, i2) = map(repo.changelog.rev, (p1, p2))
+        print "rev:      %4d:%s" % (i, h)
+        print "parents:  %4d:%s" % (i1, h1)
+        if i2: print "          %4d:%s" % (i2, h2)
+        print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]),
+                                    hg.hex(changes[0]))
+        print "user:", changes[1]
+        print "date:", time.asctime(
+            time.localtime(float(changes[2].split(' ')[0])))
+        if ui.verbose: print "files:", " ".join(changes[3])
+        print "description:"
+        print changes[4]
+
 def status(ui, repo):
     '''show changed files in the working directory
 
@@ -143,6 +163,7 @@
 table = {
     "init": (init, [], 'hg init'),
     "branch|clone": (branch, [], 'hg branch [path]'),
+    "heads": (heads, [], 'hg heads'),
     "help": (help, [], 'hg help [command]'),
     "checkout|co": (checkout, [], 'hg checkout [changeset]'),
     "ann|annotate": (annotate,
--- a/mercurial/revlog.py	Thu Jun 02 17:39:29 2005 -0800
+++ b/mercurial/revlog.py	Thu Jun 02 18:07:01 2005 -0800
@@ -156,6 +156,17 @@
     def end(self, rev): return self.start(rev) + self.length(rev)
     def base(self, rev): return self.index[rev][2]
 
+    def heads(self):
+        p = {}
+        h = []
+        for r in range(self.count() - 1, 0, -1):
+            n = self.node(r)
+            if n not in p:
+                h.append(n)
+            for pn in self.parents(n):
+                p[pn] = 1
+        return h
+    
     def lookup(self, id):
         try:
             rev = int(id)