mercurial/commands.py
changeset 221 2bfe525ef6ca
parent 220 3113a94c1bff
child 227 f57519cddd3d
equal deleted inserted replaced
220:3113a94c1bff 221:2bfe525ef6ca
     1 import os, re, traceback, sys, signal
     1 import os, re, traceback, sys, signal, time
     2 from mercurial import fancyopts, ui, hg
     2 from mercurial import fancyopts, ui, hg
     3 
     3 
     4 class UnknownCommand(Exception): pass
     4 class UnknownCommand(Exception): pass
     5 
     5 
     6 def filterfiles(list, files):
     6 def filterfiles(list, files):
   120                 pieces.append([ "%*s" % (m, x) for x in l])
   120                 pieces.append([ "%*s" % (m, x) for x in l])
   121 
   121 
   122         for p,l in zip(zip(*pieces), lines):
   122         for p,l in zip(zip(*pieces), lines):
   123             u.write(" ".join(p) + ": " + l[1])
   123             u.write(" ".join(p) + ": " + l[1])
   124 
   124 
       
   125 def heads(ui, repo):
       
   126     '''show current repository heads'''
       
   127     for n in repo.changelog.heads():
       
   128         i = repo.changelog.rev(n)
       
   129         changes = repo.changelog.read(n)
       
   130         (p1, p2) = repo.changelog.parents(n)
       
   131         (h, h1, h2) = map(hg.hex, (n, p1, p2))
       
   132         (i1, i2) = map(repo.changelog.rev, (p1, p2))
       
   133         print "rev:      %4d:%s" % (i, h)
       
   134         print "parents:  %4d:%s" % (i1, h1)
       
   135         if i2: print "          %4d:%s" % (i2, h2)
       
   136         print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]),
       
   137                                     hg.hex(changes[0]))
       
   138         print "user:", changes[1]
       
   139         print "date:", time.asctime(
       
   140             time.localtime(float(changes[2].split(' ')[0])))
       
   141         if ui.verbose: print "files:", " ".join(changes[3])
       
   142         print "description:"
       
   143         print changes[4]
       
   144 
   125 def status(ui, repo):
   145 def status(ui, repo):
   126     '''show changed files in the working directory
   146     '''show changed files in the working directory
   127 
   147 
   128 C = changed
   148 C = changed
   129 A = added
   149 A = added
   141     repo.undo()
   161     repo.undo()
   142 
   162 
   143 table = {
   163 table = {
   144     "init": (init, [], 'hg init'),
   164     "init": (init, [], 'hg init'),
   145     "branch|clone": (branch, [], 'hg branch [path]'),
   165     "branch|clone": (branch, [], 'hg branch [path]'),
       
   166     "heads": (heads, [], 'hg heads'),
   146     "help": (help, [], 'hg help [command]'),
   167     "help": (help, [], 'hg help [command]'),
   147     "checkout|co": (checkout, [], 'hg checkout [changeset]'),
   168     "checkout|co": (checkout, [], 'hg checkout [changeset]'),
   148     "ann|annotate": (annotate,
   169     "ann|annotate": (annotate,
   149                      [('r', 'revision', '', 'revision'),
   170                      [('r', 'revision', '', 'revision'),
   150                       ('u', 'user', None, 'show user'),
   171                       ('u', 'user', None, 'show user'),