hg
author mpm@selenic.com
Sat, 04 Jun 2005 12:14:14 -0800
changeset 246 96cde50a746f
parent 245 fef0f8e041aa
child 247 863b508c5b36
permissions -rw-r--r--
Migrate rawcommit, import, export, history, and merge -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Migrate rawcommit, import, export, history, and merge manifest hash: f932108ee40e34b460e94b6fe60d6a06ac9f760c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCoguVywK+sNU5EO8RAtohAKCe9Qr5R+YeLRluJlTxRGrJW/nnoQCfW/+F I0BSOeNpb6jdUxTZY1jV0xo= =hNXm -----END PGP SIGNATURE-----
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
193
0a28dfe59f8f Bump the version number to 0.5b for the protocol change
mpm@selenic.com
parents: 192
diff changeset
     4
# v0.5b "katje"
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
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
    19
import sys
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    20
from mercurial import hg, mdiff, fancyopts, ui, commands
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    21
209
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    22
try:
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    23
    sys.exit(commands.dispatch(sys.argv[1:]))
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    24
except commands.UnknownCommand:
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    25
    # fall through
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    26
    pass
63af1db35611 Beginning of new command parsing interface
mpm@selenic.com
parents: 207
diff changeset
    27
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    28
options = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    29
opts = [('v', 'verbose', None, 'verbose'),
83
9fd5b35cfc45 Add -q quiet option
mpm@selenic.com
parents: 81
diff changeset
    30
        ('d', 'debug', None, 'debug'),
107
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    31
        ('q', 'quiet', None, 'quiet'),
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    32
        ('y', 'noninteractive', None, 'run non-interactively'),
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    33
        ]
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    34
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    35
args = fancyopts.fancyopts(sys.argv[1:], opts, options,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    36
                           'hg [options] <command> [command options] [files]')
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    37
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    38
try:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    39
    cmd = args[0]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    40
    args = args[1:]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    41
except:
206
3295b6b508de hg: don't complain about missing repo with no args
mpm@selenic.com
parents: 203
diff changeset
    42
    cmd = "help"
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    43
207
ec327cf0d3a9 Move ui class to its own module
mpm@selenic.com
parents: 206
diff changeset
    44
ui = ui.ui(options["verbose"], options["debug"], options["quiet"],
107
707a7481a861 Make prompting go
mpm@selenic.com
parents: 106
diff changeset
    45
           not options["noninteractive"])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    46
    
213
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 210
diff changeset
    47
try:
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 210
diff changeset
    48
    repo = hg.repository(ui=ui)
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 210
diff changeset
    49
except IOError:
d2172916ef6c commands: migrate status and branch
mpm@selenic.com
parents: 210
diff changeset
    50
    ui.warn("Unable to open repository\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    51
    sys.exit(0)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    52
246
96cde50a746f Migrate rawcommit, import, export, history, and merge
mpm@selenic.com
parents: 245
diff changeset
    53
if cmd == "debugchangegroup":
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
    54
    newer = repo.newer(map(repo.lookup, args))
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
    55
    for chunk in repo.changegroup(newer):
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
    56
        sys.stdout.write(chunk)
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    57
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    58
elif cmd == "debugaddchangegroup":
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    59
    data = sys.stdin.read()
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    60
    repo.addchangegroup(data)
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
    61
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    62
elif cmd == "dump":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    63
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    64
        r = repo.file(args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    65
        n = r.tip()
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
    66
        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
    67
        sys.stdout.write(r.read(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    68
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    69
        print "missing filename"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    70
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    71
elif cmd == "dumpmanifest":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    72
    n = repo.manifest.tip()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    73
    if len(args) > 0:
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
    74
        n = repo.manifest.lookup(args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    75
    m = repo.manifest.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    76
    files = m.keys()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    77
    files.sort()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    78
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    79
    for f in files:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    80
        print hg.hex(m[f]), f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    81
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    82
elif cmd == "debugindex":
91
1c212bbb38d5 hack so that debugindex takes filenames
mpm@selenic.com
parents: 89
diff changeset
    83
    if ".hg" not in args[0]:
1c212bbb38d5 hack so that debugindex takes filenames
mpm@selenic.com
parents: 89
diff changeset
    84
        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
    85
    
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    86
    r = hg.revlog(open, args[0], "")
70
ce080e8eccd7 Fix debugindex formatting for large repos
mpm@selenic.com
parents: 69
diff changeset
    87
    print "   rev    offset  length   base linkrev"+\
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    88
          " p1           p2           nodeid"
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    89
    for i in range(r.count()):
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    90
        e = r.index[i]
70
ce080e8eccd7 Fix debugindex formatting for large repos
mpm@selenic.com
parents: 69
diff changeset
    91
        print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % (
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    92
            i, e[0], e[1], e[2], e[3],
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
    93
            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
    94
92
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
    95
elif cmd == "debugindexdot":
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
    96
    if ".hg" not in args[0]:
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
    97
        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
    98
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
    99
    r = hg.revlog(open, args[0], "")
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   100
    print "digraph G {"
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   101
    for i in range(r.count()):
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   102
        e = r.index[i]
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   103
        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
   104
        if e[5] != hg.nullid:
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   105
            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
   106
    print "}"
e6fc7ff52246 Add debugindexdot to generate graphviz dot files from indexes
mpm@selenic.com
parents: 91
diff changeset
   107
67
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   108
elif cmd == "tags":
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   109
    repo.lookup(0) # prime the cache
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   110
    i = repo.tags.items()
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   111
    i.sort()
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   112
    for k, n in i:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   113
        try:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   114
            r = repo.changelog.rev(n)
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   115
        except KeyError:
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   116
            r = "?"
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   117
        print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n))
a182f2561c8e Add tag support
mpm@selenic.com
parents: 65
diff changeset
   118
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   119
elif cmd == "verify":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   120
    filelinkrevs = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   121
    filenodes = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   122
    manifestchangeset = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   123
    changesets = revisions = files = 0
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   124
    errors = 0
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   125
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   126
    ui.status("checking changesets\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   127
    for i in range(repo.changelog.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   128
        changesets += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   129
        n = repo.changelog.node(i)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   130
        for p in repo.changelog.parents(n):
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   131
            if p not in repo.changelog.nodemap:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   132
                ui.warn("changeset %s has unknown parent %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   133
                        (hg.short(n), hg.short(p)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   134
                errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   135
        try:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   136
            changes = repo.changelog.read(n)
145
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   137
        except Exception, inst:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   138
            ui.warn("unpacking changeset %s: %s\n" % (short(n), inst))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   139
            errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   140
            
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   141
        manifestchangeset[changes[0]] = n
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   142
        for f in changes[3]:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   143
            filelinkrevs.setdefault(f, []).append(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   144
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   145
    ui.status("checking manifests\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   146
    for i in range(repo.manifest.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   147
        n = repo.manifest.node(i)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   148
        for p in repo.manifest.parents(n):
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   149
            if p not in repo.manifest.nodemap:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   150
                ui.warn("manifest %s has unknown parent %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   151
                        (hg.short(n), hg.short(p)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   152
                errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   153
        ca = repo.changelog.node(repo.manifest.linkrev(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   154
        cc = manifestchangeset[n]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   155
        if ca != cc:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   156
            ui.warn("manifest %s points to %s, not %s\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   157
                    (hg.hex(n), hg.hex(ca), hg.hex(cc)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   158
            errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   159
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   160
        try:
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   161
            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
   162
        except KeyboardInterrupt:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   163
            print "aborted"
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   164
            sys.exit(0)
93
0b0efe409d79 Fix two bugs in verify
mpm@selenic.com
parents: 92
diff changeset
   165
        except Exception, inst:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   166
            ui.warn("unpacking manifest %s: %s\n" % (hg.short(n), inst))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   167
            errors += 1
142
529bf610092e Prettify the web interface
mpm@selenic.com
parents: 130
diff changeset
   168
121
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   169
        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
   170
        for f, fn in ff:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   171
            filenodes.setdefault(f, {})[hg.bin(fn)] = 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   172
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   173
    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
   174
    for f in filenodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   175
        if f not in filelinkrevs:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   176
            ui.warn("file %s in manifest but not in changesets\n" % f)
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   177
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   178
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   179
    for f in filelinkrevs:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   180
        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
   181
            ui.warn("file %s in changeset but not in manifest\n" % f)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   182
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   183
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   184
    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
   185
    ff = filenodes.keys()
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   186
    ff.sort()
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   187
    for f in ff:
66fb61d9d97d Use revlog.delta and mdiff.patchtext to massively speed up processing
mpm@selenic.com
parents: 107
diff changeset
   188
        if f == "/dev/null": continue
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   189
        files += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   190
        fl = repo.file(f)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   191
        nodes = { hg.nullid: 1 }
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   192
        for i in range(fl.count()):
224
ccbcc4d76f81 fix bad assumption about uniqueness of file versions
mpm@selenic.com
parents: 220
diff changeset
   193
            revisions += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   194
            n = fl.node(i)
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   195
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   196
            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
   197
                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
   198
                print len(filenodes[f].keys()), fl.count(), f
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   199
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   200
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   201
                del filenodes[f][n]
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   202
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   203
            flr = fl.linkrev(n)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   204
            if flr not in filelinkrevs[f]:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   205
                ui.warn("%s:%s points to unexpected changeset rev %d\n"
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   206
                        % (f, hg.short(n), fl.linkrev(n)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   207
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   208
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   209
                filelinkrevs[f].remove(flr)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   210
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   211
            # verify contents
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   212
            try:
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   213
                t = fl.read(n)
145
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   214
            except Exception, inst:
fbce9fc531d2 Minor fixes to verify
mpm@selenic.com
parents: 142
diff changeset
   215
                ui.warn("unpacking file %s %s: %s\n" % (f, hg.short(n), inst))
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   216
                errors += 1
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   217
            
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   218
            # verify parents
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   219
            (p1, p2) = fl.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   220
            if p1 not in nodes:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   221
                ui.warn("file %s:%s unknown parent 1 %s" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   222
                        (f, hg.short(n), hg.short(p1)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   223
                errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   224
            if p2 not in nodes:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   225
                ui.warn("file %s:%s unknown parent 2 %s" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   226
                        (f, hg.short(n), hg.short(p1)))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   227
                errors += 1
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   228
            nodes[n] = 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   229
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   230
        # cross-check
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   231
        for node in filenodes[f]:
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   232
            ui.warn("node %s in manifests not in %s\n" % (hg.hex(n), f))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   233
            errors += 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   234
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   235
    ui.status("%d files, %d changesets, %d total revisions\n" %
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   236
              (files, changesets, revisions))
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   237
    
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   238
    if errors:
93
0b0efe409d79 Fix two bugs in verify
mpm@selenic.com
parents: 92
diff changeset
   239
        ui.warn("%d integrity errors encountered!\n" % errors)
87
b2b3fdbd79f4 Verify improvements:
mpm@selenic.com
parents: 83
diff changeset
   240
        sys.exit(1)
158
be7103467d2e Add 'hg serve' command for stand-alone server
mpm@selenic.com
parents: 155
diff changeset
   241
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   242
else:
175
0eb6e2c9800d hg: remove some debug commands, improve help messages, add .hgpaths file
mpm@selenic.com
parents: 174
diff changeset
   243
    if cmd: ui.warn("unknown command\n\n")
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   244
    sys.exit(1)