hg
author mpm@selenic.com
Wed, 25 May 2005 08:53:01 -0800
changeset 150 8029ee2949b8
parent 145 fbce9fc531d2
child 155 083c38bdfa64
child 155 083c38bdfa64
permissions -rw-r--r--
Add options to annotate for user/rev/changeset This eliminates the blame command and makes annotate more flexible.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     1
#!/usr/bin/env python
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     2
#
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     3
# mercurial - a minimal scalable distributed SCM
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
     4
# v0.4f "jane dark"
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     5
#
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     6
# Copyright 2005 Matt Mackall <mpm@selenic.com>
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     7
#
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     8
# This software may be used and distributed according to the terms
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
     9
# of the GNU General Public License, incorporated herein by reference.
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    10
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    11
# the psyco compiler makes commits a bit faster
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    12
# and makes changegroup merge about 20 times slower!
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    13
# try:
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    14
#    import psyco
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    15
#    psyco.full()
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    16
# except:
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    17
#    pass
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    18
23
018fb8d9ea8d Import time for hg history command
mpm@selenic.com
parents: 22
diff changeset
    19
import sys, os, time
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    20
from mercurial import hg, mdiff, fancyopts
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    21
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    22
def help():
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
    23
    print """\
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    24
 commands:
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    25
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    26
 add [files...]        add the given files in the next commit
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    27
 addremove             add all new files, delete all missing files
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    28
 annotate [files...]   show changeset number per file line
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    29
 branch <path>         create a branch of <path> in this directory
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    30
 checkout [changeset]  checkout the latest or given changeset
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    31
 commit                commit all changes to the repository
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    32
 diff [files...]       diff working directory (or selected files)
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    33
 dump <file> [rev]     dump the latest or given revision of a file
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    34
 dumpmanifest [rev]    dump the latest or given revision of the manifest
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    35
 history               show changeset history
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    36
 init                  create a new repository in this directory
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    37
 log <file>            show revision history of a single file
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    38
 merge <path>          merge changes from <path> into local repository
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    39
 remove [files...]     remove the given files in the next commit
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
    40
 status                show new, missing, and changed files in working dir
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
    41
 tags                  show current changeset tags
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    42
"""
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    43
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    44
def filterfiles(list, files):
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    45
    l = [ x for x in list if x in files ]
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
    46
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    47
    for f in files:
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    48
        if f[-1] != os.sep: f += os.sep
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    49
        l += [ x for x in list if x.startswith(f) ]
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    50
    return l
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
    51
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    52
def diff(files = None, node1 = None, node2 = None):
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    53
    def date(c):
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    54
        return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    55
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    56
    if node2:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    57
        change = repo.changelog.read(node2)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    58
        mmap2 = repo.manifest.read(change[0])
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    59
        (c, a, d) = repo.diffrevs(node1, node2)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    60
        def read(f): return repo.file(f).read(mmap2[f])
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    61
        date2 = date(change)
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    62
    else:
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    63
        date2 = time.asctime()
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    64
        if not node1:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    65
            node1 = repo.current
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    66
        (c, a, d) = repo.diffdir(repo.root, node1)
129
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    67
        a = [] # ignore unknown files in repo, by popular request
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    68
        def read(f): return file(os.path.join(repo.root, f)).read()
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    69
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    70
    change = repo.changelog.read(node1)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    71
    mmap = repo.manifest.read(change[0])
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    72
    date1 = date(change)
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    73
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    74
    if files:
129
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    75
        c, a, d = map(lambda x: filterfiles(x, files), (c, a, d))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    76
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    77
    for f in c:
130
e6678a1beb6a Make hg diff handle files that have been added but not yet committed.
mpm@selenic.com
parents: 129
diff changeset
    78
        to = ""
e6678a1beb6a Make hg diff handle files that have been added but not yet committed.
mpm@selenic.com
parents: 129
diff changeset
    79
        if mmap.has_key(f):
e6678a1beb6a Make hg diff handle files that have been added but not yet committed.
mpm@selenic.com
parents: 129
diff changeset
    80
            to = repo.file(f).read(mmap[f])
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    81
        tn = read(f)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    82
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
129
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    83
    for f in a:
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    84
        to = ""
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    85
        tn = read(f)
1db9207def07 Fix diff and export not showing added files
mpm@selenic.com
parents: 124
diff changeset
    86
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    87
    for f in d:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    88
        to = repo.file(f).read(mmap[f])
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    89
        tn = ""
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    90
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    91
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    92
options = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    93
opts = [('v', 'verbose', None, 'verbose'),
83
9fd5b35cfc45 Add -q quiet option
mpm@selenic.com
parents: 81
diff changeset
    94
        ('d', 'debug', None, 'debug'),
107
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    95
        ('q', 'quiet', None, 'quiet'),
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    96
        ('y', 'noninteractive', None, 'run non-interactively'),
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    97
        ]
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    98
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    99
args = fancyopts.fancyopts(sys.argv[1:], opts, options,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   100
                           'hg [options] <command> [command options] [files]')
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   101
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   102
try:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   103
    cmd = args[0]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   104
    args = args[1:]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   105
except:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   106
    cmd = ""
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   107
107
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
   108
ui = hg.ui(options["verbose"], options["debug"], options["quiet"],
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
   109
           not options["noninteractive"])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   110
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   111
if cmd == "init":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   112
    repo = hg.repository(ui, ".", create=1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   113
    sys.exit(0)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   114
elif cmd == "branch" or cmd == "clone":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   115
    os.system("cp -al %s/.hg .hg" % args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   116
    sys.exit(0)
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   117
elif cmd == "help":
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   118
    help()
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   119
    sys.exit(0)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   120
else:
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   121
    try:
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   122
        repo = hg.repository(ui=ui)
74
mpm@selenic.com
parents: 70
diff changeset
   123
    except IOError:
83
9fd5b35cfc45 Add -q quiet option
mpm@selenic.com
parents: 81
diff changeset
   124
        ui.warn("Unable to open repository\n")
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   125
        sys.exit(0)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   126
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   127
relpath = None
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   128
if os.getcwd() != repo.root:
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   129
    relpath = os.getcwd()[len(repo.root) + 1: ]
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   130
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   131
if cmd == "checkout" or cmd == "co":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   132
    node = repo.changelog.tip()
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   133
    if args:
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   134
        node = repo.lookup(args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   135
    repo.checkout(node)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   136
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   137
elif cmd == "add":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   138
    repo.add(args)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   139
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   140
elif cmd == "remove" or cmd == "rm" or cmd == "del" or cmd == "delete":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   141
    repo.remove(args)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   142
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   143
elif cmd == "commit" or cmd == "checkin" or cmd == "ci":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   144
    if 1:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   145
        if len(args) > 0:
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   146
            repo.commit(repo.current, args)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   147
        else:
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   148
            repo.commit(repo.current)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   149
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   150
elif cmd == "import" or cmd == "patch":
69
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   151
    try:
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   152
        import psyco
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   153
        psyco.full()
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   154
    except:
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   155
        pass
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   156
    
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   157
    ioptions = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   158
    opts = [('p', 'strip', 1, 'path strip'),
50
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   159
            ('b', 'base', "", 'base path'),
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   160
            ('q', 'quiet', "", 'silence diff')
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   161
            ]
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   162
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   163
    args = fancyopts.fancyopts(args, opts, ioptions,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   164
                              'hg import [options] <patch names>')
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   165
    d = ioptions["base"]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   166
    strip = ioptions["strip"]
50
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   167
    quiet = ioptions["quiet"] and "> /dev/null" or ""
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   168
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   169
    for patch in args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   170
        ui.status("applying %s\n" % patch)
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   171
        pf = os.path.join(d, patch)
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   172
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   173
        text = ""
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   174
        for l in file(pf):
69
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   175
            if l[:4] == "--- ": break
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   176
            text += l
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   177
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   178
        f = os.popen("lsdiff --strip %d %s" % (strip, pf))
54
b24731008221 Fix lsdiff filtering
mpm@selenic.com
parents: 53
diff changeset
   179
        files = filter(None, map(lambda x: x.rstrip(), f.read().splitlines()))
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   180
        f.close()
69
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   181
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   182
        if files:
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   183
            if os.system("patch -p%d < %s %s" % (strip, pf, quiet)):
ab03c7a52cf2 Minor changes to import so that we can successfully import Ingo's
mpm@selenic.com
parents: 68
diff changeset
   184
                raise "patch failed!"
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   185
        repo.commit(repo.current, files, text)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   186
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   187
elif cmd == "status":
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   188
    (c, a, d) = repo.diffdir(repo.root, repo.current)
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   189
    if relpath:
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   190
        (c, a, d) = map(lambda x: filterfiles(x, [ relpath ]), (c, a, d))
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   191
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   192
    for f in c: print "C", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   193
    for f in a: print "?", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   194
    for f in d: print "R", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   195
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   196
elif cmd == "diff":
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   197
    revs = []
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   198
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   199
    if args:
38
ed1d3e3ca8e0 Add improved rev lookup to diff and export
mpm@selenic.com
parents: 34
diff changeset
   200
        doptions = {}
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   201
        opts = [('r', 'revision', [], 'revision')]
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   202
        args = fancyopts.fancyopts(args, opts, doptions,
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   203
                                   'hg diff [options] [files]')
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   204
        revs = map(lambda x: repo.lookup(x), doptions['revision'])
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   205
    
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   206
    if len(revs) > 2:
83
9fd5b35cfc45 Add -q quiet option
mpm@selenic.com
parents: 81
diff changeset
   207
        self.ui.warn("too many revisions to diff\n")
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   208
        sys.exit(1)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   209
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   210
    if relpath:
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   211
        if not args: args = [ relpath ]
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   212
        else: args = [ os.path.join(relpath, x) for x in args ]
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   213
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   214
    diff(args, *revs)
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   215
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   216
elif cmd == "annotate":
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   217
    bcache = {}
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   218
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   219
    def getnode(rev):
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   220
        return hg.short(repo.changelog.node(rev))
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   221
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   222
    def getname(rev):
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   223
        try:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   224
            return bcache[rev]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   225
        except KeyError:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   226
            cl = repo.changelog.read(repo.changelog.node(rev))
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   227
            name = cl[1]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   228
            f = name.find('@')
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   229
            if f >= 0:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   230
                name = name[:f]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   231
            bcache[rev] = name
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   232
            return name
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   233
    
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   234
    aoptions = {}
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   235
    opts = [('r', 'revision', '', 'revision'),
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   236
            ('u', 'user', None, 'show user'),
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   237
            ('n', 'number', None, 'show revision number'),
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   238
            ('c', 'changeset', None, 'show changeset')]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   239
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   240
    args = fancyopts.fancyopts(args, opts, aoptions,
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   241
                               'hg annotate [-u] [-c] [-n] [-r id] [files]')
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   242
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   243
    opmap = [['user', getname], ['number', str], ['changeset', getnode]]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   244
    if not aoptions['user'] and not aoptions['changeset']:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   245
        aoptions['number'] = 1
122
82fd709deb8e Subdir support for annotate
mpm@selenic.com
parents: 121
diff changeset
   246
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   247
    if args:
122
82fd709deb8e Subdir support for annotate
mpm@selenic.com
parents: 121
diff changeset
   248
        if relpath: args = [ os.path.join(relpath, x) for x in args ]
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   249
        node = repo.current
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   250
        if aoptions['revision']:
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   251
            node = repo.changelog.lookup(aoptions['revision'])
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   252
        change = repo.changelog.read(node)
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   253
        mmap = repo.manifest.read(change[0])
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   254
        maxuserlen = 0
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   255
        maxchangelen = 0
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   256
        for f in args:
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   257
            lines = repo.file(f).annotate(mmap[f])
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   258
            pieces = []
80
5b7a444c794a Fix field width for annotate
mpm@selenic.com
parents: 79
diff changeset
   259
150
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   260
            for o, f in opmap:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   261
                if aoptions[o]:
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   262
                    l = [ f(n) for n,t in lines ]
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   263
                    m = max(map(len, l))
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   264
                    pieces.append([ "%*s" % (m, x) for x in l])
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   265
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   266
            for p,l in zip(zip(*pieces), lines):
8029ee2949b8 Add options to annotate for user/rev/changeset
mpm@selenic.com
parents: 145
diff changeset
   267
                sys.stdout.write(" ".join(p) + ": " + l[1])
79
837d473d54d5 Add basic annotation support
mpm@selenic.com
parents: 74
diff changeset
   268
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   269
elif cmd == "export":
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   270
    node = repo.lookup(args[0])
68
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   271
    prev, other = repo.changelog.parents(node)
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   272
    change = repo.changelog.read(node)
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   273
    print "# HG changeset patch"
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   274
    print "# User %s" % change[1]
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   275
    print "# Node ID %s" % hg.hex(node)
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   276
    print "# Parent  %s" % hg.hex(prev)
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   277
    print
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   278
    if other != hg.nullid:
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   279
        print "# Parent  %s" % hg.hex(other)
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   280
    print change[4]
6fa994fe90fc Print changeset metadata for export
mpm@selenic.com
parents: 67
diff changeset
   281
    
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   282
    diff(None, prev, node)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   283
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   284
elif cmd == "debugchangegroup":
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   285
    newer = repo.newer(map(repo.lookup, args))
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   286
    for chunk in repo.changegroup(newer):
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   287
        sys.stdout.write(chunk)
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   288
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   289
elif cmd == "debugaddchangegroup":
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   290
    data = sys.stdin.read()
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   291
    repo.addchangegroup(data)
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   292
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   293
elif cmd == "addremove":
29
4d3a5dcb6972 Make diffdir take a revision argument
mpm@selenic.com
parents: 24
diff changeset
   294
    (c, a, d) = repo.diffdir(repo.root, repo.current)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   295
    repo.add(a)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   296
    repo.remove(d)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   297
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   298
elif cmd == "history":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   299
    for i in range(repo.changelog.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   300
        n = repo.changelog.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   301
        changes = repo.changelog.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   302
        (p1, p2) = repo.changelog.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   303
        (h, h1, h2) = map(hg.hex, (n, p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   304
        (i1, i2) = map(repo.changelog.rev, (p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   305
        print "rev:      %4d:%s" % (i, h)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   306
        print "parents:  %4d:%s" % (i1, h1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   307
        if i2: print "          %4d:%s" % (i2, h2)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   308
        print "manifest: %4d:%s" % (repo.manifest.rev(changes[0]),
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   309
                                    hg.hex(changes[0]))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   310
        print "user:", changes[1]
21
54a57a5ebcb1 Show date in history
mpm@selenic.com
parents: 18
diff changeset
   311
        print "date:", time.asctime(
54a57a5ebcb1 Show date in history
mpm@selenic.com
parents: 18
diff changeset
   312
            time.localtime(float(changes[2].split(' ')[0])))
123
b93cc016eec9 hg history: don't print file list without -v switch
mpm@selenic.com
parents: 122
diff changeset
   313
        if ui.verbose: print "files:", " ".join(changes[3])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   314
        print "description:"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   315
        print changes[4]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   316
89
4cd9145d5b53 Add tip command
mpm@selenic.com
parents: 88
diff changeset
   317
elif cmd == "tip":
4cd9145d5b53 Add tip command
mpm@selenic.com
parents: 88
diff changeset
   318
    n = repo.changelog.tip()
4cd9145d5b53 Add tip command
mpm@selenic.com
parents: 88
diff changeset
   319
    t = repo.changelog.rev(n)
4cd9145d5b53 Add tip command
mpm@selenic.com
parents: 88
diff changeset
   320
    ui.status("%d:%s\n" % (t, hg.hex(n)))
4cd9145d5b53 Add tip command
mpm@selenic.com
parents: 88
diff changeset
   321
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   322
elif cmd == "log":
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   323
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   324
    if len(args) == 1:
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   325
        if relpath:
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   326
            args[0] = os.path.join(relpath, args[0])
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   327
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   328
        r = repo.file(args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   329
        for i in range(r.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   330
            n = r.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   331
            (p1, p2) = r.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   332
            (h, h1, h2) = map(hg.hex, (n, p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   333
            (i1, i2) = map(r.rev, (p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   334
            cr = r.linkrev(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   335
            cn = hg.hex(repo.changelog.node(cr))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   336
            print "rev:       %4d:%s" % (i, h)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   337
            print "changeset: %4d:%s" % (cr, cn)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   338
            print "parents:   %4d:%s" % (i1, h1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   339
            if i2: print "           %4d:%s" % (i2, h2)
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   340
            changes = repo.changelog.read(repo.changelog.node(cr))
105
6eeb50050486 Date on its own line in file log
mpm@selenic.com
parents: 104
diff changeset
   341
            print "user: %s" % changes[1]
6eeb50050486 Date on its own line in file log
mpm@selenic.com
parents: 104
diff changeset
   342
            print "date: %s" % time.asctime(
106
e8d4bbf4c9e2 Don't diff unknown files
mpm@selenic.com
parents: 105
diff changeset
   343
                time.localtime(float(changes[2].split(' ')[0])))
103
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   344
            print "description:"
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   345
            print changes[4]
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   346
            print
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   347
    elif len(args) > 1:
33500fe7d56c adding subdir support for log and status commands
jake@edge2.net
parents: 70
diff changeset
   348
        print "too many args"
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   349
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   350
        print "missing filename"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   351
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   352
elif cmd == "dump":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   353
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   354
        r = repo.file(args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   355
        n = r.tip()
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   356
        if len(args) > 1: n = r.lookup(args[1])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   357
        sys.stdout.write(r.read(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   358
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   359
        print "missing filename"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   360
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   361
elif cmd == "dumpmanifest":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   362
    n = repo.manifest.tip()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   363
    if len(args) > 0:
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   364
        n = repo.manifest.lookup(args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   365
    m = repo.manifest.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   366
    files = m.keys()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   367
    files.sort()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   368
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   369
    for f in files:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   370
        print hg.hex(m[f]), f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   371
107
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
   372
elif cmd == "debugprompt":
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
   373
    print ui.prompt(args[0], args[1], args[2])
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
   374
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   375
elif cmd == "debughash":
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   376
    f = repo.file(args[0])
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   377
    print f.encodepath(args[0])
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   378
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   379
elif cmd == "debugindex":
91
1c212bbb38d5 hack so that debugindex takes filenames
mpm@selenic.com
parents: 89
diff changeset
   380
    if ".hg" not in args[0]:
1c212bbb38d5 hack so that debugindex takes filenames
mpm@selenic.com
parents: 89
diff changeset
   381
        args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i"
1c212bbb38d5 hack so that debugindex takes filenames
mpm@selenic.com
parents: 89
diff changeset
   382
    
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   383
    r = hg.revlog(open, args[0], "")
70
ce080e8eccd7 Fix debugindex formatting for large repos
mpm@selenic.com
parents: 69
diff changeset
   384
    print "   rev    offset  length   base linkrev"+\
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   385
          " p1           p2           nodeid"
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   386
    for i in range(r.count()):
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   387
        e = r.index[i]
70
ce080e8eccd7 Fix debugindex formatting for large repos
mpm@selenic.com
parents: 69
diff changeset
   388
        print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % (
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   389
            i, e[0], e[1], e[2], e[3],
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   390
            hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   391
92
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   392
elif cmd == "debugindexdot":
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   393
    if ".hg" not in args[0]:
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   394
        args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i"
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   395
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   396
    r = hg.revlog(open, args[0], "")
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   397
    print "digraph G {"
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   398
    for i in range(r.count()):
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   399
        e = r.index[i]
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   400
        print "\t%d -> %d" % (r.rev(e[4]), i)
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   401
        if e[5] != hg.nullid:
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   402
            print "\t%d -> %d" % (r.rev(e[5]), i)
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   403
    print "}"
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   404
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   405
elif cmd == "merge":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   406
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   407
        other = hg.repository(ui, args[0])
88
d9913355961d Missing newline in "requesting changegroup"
mpm@selenic.com
parents: 87
diff changeset
   408
        ui.status("requesting changegroup\n")
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   409
        cg = repo.getchangegroup(other)
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   410
        repo.addchangegroup(cg)
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   411
    else:
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   412
        print "missing source repository"
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   413
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   414
elif cmd == "tags":
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   415
    repo.lookup(0) # prime the cache
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   416
    i = repo.tags.items()
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   417
    i.sort()
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   418
    for k, n in i:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   419
        try:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   420
            r = repo.changelog.rev(n)
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   421
        except KeyError:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   422
            r = "?"
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   423
        print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n))
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   424
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   425
elif cmd == "verify":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   426
    filelinkrevs = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   427
    filenodes = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   428
    manifestchangeset = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   429
    changesets = revisions = files = 0
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   430
    errors = 0
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   431
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   432
    ui.status("checking changesets\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   433
    for i in range(repo.changelog.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   434
        changesets += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   435
        n = repo.changelog.node(i)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   436
        for p in repo.changelog.parents(n):
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   437
            if p not in repo.changelog.nodemap:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   438
                ui.warn("changeset %s has unknown parent %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   439
                        (hg.short(n), hg.short(p)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   440
                errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   441
        try:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   442
            changes = repo.changelog.read(n)
145
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   443
        except Exception, inst:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   444
            ui.warn("unpacking changeset %s: %s\n" % (short(n), inst))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   445
            errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   446
            
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   447
        manifestchangeset[changes[0]] = n
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   448
        for f in changes[3]:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   449
            revisions += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   450
            filelinkrevs.setdefault(f, []).append(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   451
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   452
    ui.status("checking manifests\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   453
    for i in range(repo.manifest.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   454
        n = repo.manifest.node(i)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   455
        for p in repo.manifest.parents(n):
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   456
            if p not in repo.manifest.nodemap:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   457
                ui.warn("manifest %s has unknown parent %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   458
                        (hg.short(n), hg.short(p)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   459
                errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   460
        ca = repo.changelog.node(repo.manifest.linkrev(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   461
        cc = manifestchangeset[n]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   462
        if ca != cc:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   463
            ui.warn("manifest %s points to %s, not %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   464
                    (hg.hex(n), hg.hex(ca), hg.hex(cc)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   465
            errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   466
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   467
        try:
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   468
            delta = mdiff.patchtext(repo.manifest.delta(n))
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   469
        except KeyboardInterrupt:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   470
            print "aborted"
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   471
            sys.exit(0)
93
0b0efe409d79 Fix two bugs in verify
mpm@selenic.com
parents: 92
diff changeset
   472
        except Exception, inst:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   473
            ui.warn("unpacking manifest %s: %s\n" % (hg.short(n), inst))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   474
            errors += 1
142
529bf610092e Prettify the web interface
mpm@selenic.com
parents: 130
diff changeset
   475
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   476
        ff = [ l.split('\0') for l in delta.splitlines() ]
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   477
        for f, fn in ff:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   478
            filenodes.setdefault(f, {})[hg.bin(fn)] = 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   479
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   480
    ui.status("crosschecking files in changesets and manifests\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   481
    for f in filenodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   482
        if f not in filelinkrevs:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   483
            ui.warn("file %s in manifest but not in changesets\n" % f)
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   484
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   485
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   486
    for f in filelinkrevs:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   487
        if f not in filenodes:
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   488
            ui.warn("file %s in changeset but not in manifest\n" % f)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   489
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   490
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   491
    ui.status("checking files\n")
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   492
    ff = filenodes.keys()
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   493
    ff.sort()
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   494
    for f in ff:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   495
        if f == "/dev/null": continue
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   496
        files += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   497
        fl = repo.file(f)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   498
        nodes = { hg.nullid: 1 }
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   499
        for i in range(fl.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   500
            n = fl.node(i)
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   501
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   502
            if n not in filenodes[f]:
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   503
                ui.warn("%s: %d:%s not in manifests\n" % (f, i, hg.short(n)))
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   504
                print len(filenodes[f].keys()), fl.count(), f
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   505
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   506
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   507
                del filenodes[f][n]
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   508
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   509
            flr = fl.linkrev(n)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   510
            if flr not in filelinkrevs[f]:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   511
                ui.warn("%s:%s points to unexpected changeset rev %d\n"
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   512
                        % (f, hg.short(n), fl.linkrev(n)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   513
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   514
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   515
                filelinkrevs[f].remove(flr)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   516
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   517
            # verify contents
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   518
            try:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   519
                t = fl.read(n)
145
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   520
            except Exception, inst:
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   521
                ui.warn("unpacking file %s %s: %s\n" % (f, hg.short(n), inst))
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   522
                errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   523
            
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   524
            # verify parents
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   525
            (p1, p2) = fl.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   526
            if p1 not in nodes:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   527
                ui.warn("file %s:%s unknown parent 1 %s" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   528
                        (f, hg.short(n), hg.short(p1)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   529
                errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   530
            if p2 not in nodes:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   531
                ui.warn("file %s:%s unknown parent 2 %s" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   532
                        (f, hg.short(n), hg.short(p1)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   533
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   534
            nodes[n] = 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   535
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   536
        # cross-check
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   537
        for flr in filelinkrevs[f]:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   538
            ui.warn("changeset rev %d not in %s\n" % (flr, f))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   539
            errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   540
            
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   541
        for node in filenodes[f]:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   542
            ui.warn("node %s in manifests not in %s\n" % (hg.hex(n), f))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   543
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   544
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   545
    ui.status("%d files, %d changesets, %d total revisions\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   546
              (files, changesets, revisions))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   547
    
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   548
    if errors:
93
0b0efe409d79 Fix two bugs in verify
mpm@selenic.com
parents: 92
diff changeset
   549
        ui.warn("%d integrity errors encountered!\n" % errors)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   550
        sys.exit(1)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   551
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   552
else:
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   553
    print "unknown command\n"
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   554
    help()
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   555
    sys.exit(1)