hg
author mpm@selenic.com
Fri, 13 May 2005 11:47:16 -0800
changeset 65 d40cc5aacc31
parent 64 b3e2ddff0159
child 67 a182f2561c8e
permissions -rw-r--r--
Fix up a bunch of bugs in the new merge code Move getchangegroup/addchangegroup to generators
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
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
     4
# v0.4e "sabina"
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
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    26
 init                  create a new repository in this directory
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    27
 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
    28
 merge <path>          merge changes from <path> into local repository
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    29
 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
    30
 status                show new, missing, and changed files in working dir
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    31
 add [files...]        add the given files in the next commit
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    32
 remove [files...]     remove the given files in the next commit
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    33
 addremove             add all new files, delete all missing files
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    34
 commit                commit all changes to the repository
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    35
 history               show changeset history
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    36
 log <file>            show revision history of a single file
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    37
 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
    38
 dumpmanifest [rev]    dump the latest or given revision of the manifest
22
40b8c158c540 Document diff in help
mpm@selenic.com
parents: 21
diff changeset
    39
 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
    40
"""
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
    41
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    42
def filterfiles(list, files):
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    43
    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
    44
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    45
    for f in files:
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    46
        if f[-1] != os.sep: f += os.sep
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
    47
        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
    48
    return l
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
    49
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    50
def diff(files = None, node1 = None, node2 = None):
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    51
    def date(c):
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    52
        return time.asctime(time.gmtime(float(c[2].split(' ')[0])))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    53
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    54
    if node2:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    55
        change = repo.changelog.read(node2)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    56
        mmap2 = repo.manifest.read(change[0])
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    57
        (c, a, d) = repo.diffrevs(node1, node2)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    58
        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
    59
        date2 = date(change)
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    60
    else:
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    61
        date2 = time.asctime()
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    62
        if not node1:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    63
            node1 = repo.current
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    64
        (c, a, d) = repo.diffdir(repo.root, node1)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    65
        def read(f): return file(os.path.join(repo.root, f)).read()
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    66
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    67
    change = repo.changelog.read(node1)
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    68
    mmap = repo.manifest.read(change[0])
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    69
    date1 = date(change)
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    70
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    71
    if files:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    72
        (c, a, d) = map(lambda x: filterfiles(x, files), (c, a, d))
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    73
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    74
    for f in c:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    75
        to = repo.file(f).read(mmap[f])
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    76
        tn = read(f)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    77
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    78
    for f in a:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    79
        to = ""
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    80
        tn = read(f)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    81
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    82
    for f in d:
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    83
        to = repo.file(f).read(mmap[f])
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    84
        tn = ""
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
    85
        sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f))
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
    86
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    87
options = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    88
opts = [('v', 'verbose', None, 'verbose'),
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    89
        ('d', 'debug', None, 'debug')]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    90
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    91
args = fancyopts.fancyopts(sys.argv[1:], opts, options,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    92
                           'hg [options] <command> [command options] [files]')
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    93
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    94
try:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    95
    cmd = args[0]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    96
    args = args[1:]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    97
except:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    98
    cmd = ""
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
    99
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   100
ui = hg.ui(options["verbose"], options["debug"])
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
if cmd == "init":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   103
    repo = hg.repository(ui, ".", create=1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   104
    sys.exit(0)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   105
elif cmd == "branch" or cmd == "clone":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   106
    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
   107
    sys.exit(0)
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   108
elif cmd == "help":
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   109
    help()
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   110
    sys.exit(0)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   111
else:
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   112
    try:
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   113
        repo = hg.repository(ui=ui)
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   114
    except:
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   115
        print "Unable to open repository"
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   116
        sys.exit(0)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   117
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   118
if cmd == "checkout" or cmd == "co":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   119
    node = repo.changelog.tip()
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   120
    if args:
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   121
        node = repo.changelog.lookup(args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   122
    repo.checkout(node)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   123
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   124
elif cmd == "add":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   125
    repo.add(args)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   126
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   127
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
   128
    repo.remove(args)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   129
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   130
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
   131
    if 1:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   132
        if len(args) > 0:
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   133
            repo.commit(repo.current, args)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   134
        else:
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   135
            repo.commit(repo.current)
0
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 == "import" or cmd == "patch":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   138
    ioptions = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   139
    opts = [('p', 'strip', 1, 'path strip'),
50
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   140
            ('b', 'base', "", 'base path'),
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   141
            ('q', 'quiet', "", 'silence diff')
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   142
            ]
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   143
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   144
    args = fancyopts.fancyopts(args, opts, ioptions,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   145
                              'hg import [options] <patch names>')
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   146
    d = ioptions["base"]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   147
    strip = ioptions["strip"]
50
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   148
    quiet = ioptions["quiet"] and "> /dev/null" or ""
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
    for patch in args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   151
        ui.status("applying %s\n" % patch)
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   152
        pf = os.path.join(d, patch)
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   153
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   154
        text = ""
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   155
        for l in file(pf):
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   156
            if l[:3] == "---": break
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   157
            text += l
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   158
50
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   159
        if os.system("patch -p%d < %s %s" % (strip, pf, quiet)):
0263ce8be574 Add -q option to import
mpm@selenic.com
parents: 49
diff changeset
   160
            raise "patch failed!"
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   161
        f = os.popen("lsdiff --strip %d %s" % (strip, pf))
54
b24731008221 Fix lsdiff filtering
mpm@selenic.com
parents: 53
diff changeset
   162
        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
   163
        f.close()
49
14bff5d8e526 Import comments from patches
mpm@selenic.com
parents: 46
diff changeset
   164
        repo.commit(repo.current, files, text)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   165
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   166
elif cmd == "status":
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   167
    (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
   168
    for f in c: print "C", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   169
    for f in a: print "?", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   170
    for f in d: print "R", f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   171
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   172
elif cmd == "diff":
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   173
    revs = []
31
642058291e74 diffdir tidy in preparation for arg handling
mpm@selenic.com
parents: 29
diff changeset
   174
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   175
    if args:
38
ed1d3e3ca8e0 Add improved rev lookup to diff and export
mpm@selenic.com
parents: 34
diff changeset
   176
        doptions = {}
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   177
        opts = [('r', 'revision', [], 'revision')]
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   178
        args = fancyopts.fancyopts(args, opts, doptions,
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   179
                                   'hg diff [options] [files]')
38
ed1d3e3ca8e0 Add improved rev lookup to diff and export
mpm@selenic.com
parents: 34
diff changeset
   180
        revs = map(lambda x: repo.changelog.lookup(x), doptions['revision'])
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   181
    
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   182
    if len(revs) > 2:
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   183
        print "too many revisions to diff"
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   184
        sys.exit(1)
64
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   185
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   186
    if os.getcwd() != repo.root:
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   187
        relpath = os.getcwd()[len(repo.root) + 1: ]
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   188
        if not args: args = [ relpath ]
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   189
        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
   190
b3e2ddff0159 Diff in subdirectories from Jake Edge
mpm@selenic.com
parents: 62
diff changeset
   191
    diff(args, *revs)
33
98633e60067c Support for 0, 1, or 2 diff revs
mpm@selenic.com
parents: 31
diff changeset
   192
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   193
elif cmd == "export":
38
ed1d3e3ca8e0 Add improved rev lookup to diff and export
mpm@selenic.com
parents: 34
diff changeset
   194
    node = repo.changelog.lookup(args[0])
34
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   195
    prev = repo.changelog.parents(node)[0]
8708c75da2ac Add export command
mpm@selenic.com
parents: 33
diff changeset
   196
    diff(None, prev, node)
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   197
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   198
elif cmd == "debugchangegroup":
56
ad2ea1185f04 Add getchangegroup code to efficiently calculate and request a changegroup
mpm@selenic.com
parents: 54
diff changeset
   199
    newer = repo.newer(map(repo.changelog.lookup, args))
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   200
    for chunk in repo.changegroup(newer):
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   201
        sys.stdout.write(chunk)
46
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   202
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   203
elif cmd == "debugaddchangegroup":
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   204
    data = sys.stdin.read()
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   205
    repo.addchangegroup(data)
93e868fa0db8 Add changegroup support
mpm@selenic.com
parents: 39
diff changeset
   206
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   207
elif cmd == "addremove":
29
4d3a5dcb6972 Make diffdir take a revision argument
mpm@selenic.com
parents: 24
diff changeset
   208
    (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
   209
    repo.add(a)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   210
    repo.remove(d)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   211
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   212
elif cmd == "history":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   213
    for i in range(repo.changelog.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   214
        n = repo.changelog.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   215
        changes = repo.changelog.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   216
        (p1, p2) = repo.changelog.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   217
        (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
   218
        (i1, i2) = map(repo.changelog.rev, (p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   219
        print "rev:      %4d:%s" % (i, h)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   220
        print "parents:  %4d:%s" % (i1, h1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   221
        if i2: print "          %4d:%s" % (i2, h2)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   222
        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
   223
                                    hg.hex(changes[0]))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   224
        print "user:", changes[1]
21
54a57a5ebcb1 Show date in history
mpm@selenic.com
parents: 18
diff changeset
   225
        print "date:", time.asctime(
54a57a5ebcb1 Show date in history
mpm@selenic.com
parents: 18
diff changeset
   226
            time.localtime(float(changes[2].split(' ')[0])))
11
7f16aaeed62f Allow checkout by number or hash
oxymoron@cinder.waste.org
parents: 5
diff changeset
   227
        print "files:", " ".join(changes[3])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   228
        print "description:"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   229
        print changes[4]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   230
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   231
elif cmd == "log":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   232
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   233
        r = repo.file(args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   234
        for i in range(r.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   235
            n = r.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   236
            (p1, p2) = r.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   237
            (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
   238
            (i1, i2) = map(r.rev, (p1, p2))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   239
            cr = r.linkrev(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   240
            cn = hg.hex(repo.changelog.node(cr))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   241
            print "rev:       %4d:%s" % (i, h)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   242
            print "changeset: %4d:%s" % (cr, cn)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   243
            print "parents:   %4d:%s" % (i1, h1)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   244
            if i2: print "           %4d:%s" % (i2, h2)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   245
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   246
        print "missing filename"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   247
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   248
elif cmd == "dump":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   249
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   250
        r = repo.file(args[0])
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   251
        n = r.tip()
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   252
        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
   253
        sys.stdout.write(r.read(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   254
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   255
        print "missing filename"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   256
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   257
elif cmd == "dumpmanifest":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   258
    n = repo.manifest.tip()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   259
    if len(args) > 0:
39
adf70fffca9f Add lookup smarts everywhere
mpm@selenic.com
parents: 38
diff changeset
   260
        n = repo.manifest.lookup(args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   261
    m = repo.manifest.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   262
    files = m.keys()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   263
    files.sort()
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   264
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   265
    for f in files:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   266
        print hg.hex(m[f]), f
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   267
24
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   268
elif cmd == "debughash":
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   269
    f = repo.file(args[0])
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   270
    print f.encodepath(args[0])
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   271
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   272
elif cmd == "debugindex":
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   273
    r = hg.revlog(open, args[0], "")
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   274
    print "   rev    offset  length  base linkrev"+\
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   275
          " p1           p2           nodeid"
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   276
    for i in range(r.count()):
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   277
        e = r.index[i]
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   278
        print "% 6d % 9d % 7d % 5d % 7d %s.. %s.. %s.." % (
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   279
            i, e[0], e[1], e[2], e[3],
57a1eef79415 Add debughash and debugindex commands
mpm@selenic.com
parents: 23
diff changeset
   280
            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
   281
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   282
elif cmd == "merge":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   283
    if args:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   284
        other = hg.repository(ui, args[0])
65
d40cc5aacc31 Fix up a bunch of bugs in the new merge code
mpm@selenic.com
parents: 64
diff changeset
   285
        print "requesting changegroup"
62
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   286
        cg = repo.getchangegroup(other)
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   287
        repo.addchangegroup(cg)
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   288
    else:
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   289
        print "missing source repository"
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   290
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   291
elif cmd == "debugoldmerge":
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   292
    if args:
022d98aa0a2a Fix tabs
mpm@selenic.com
parents: 56
diff changeset
   293
        other = hg.repository(ui, args[0])
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   294
        repo.merge(other)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   295
    else:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   296
        print "missing source repository"
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 == "verify":
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   299
    filelinkrevs = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   300
    filenodes = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   301
    manifestchangeset = {}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   302
    changesets = revisions = files = 0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   303
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   304
    print "checking changesets"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   305
    for i in range(repo.changelog.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   306
        changesets += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   307
        n = repo.changelog.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   308
        changes = repo.changelog.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   309
        manifestchangeset[changes[0]] = n
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   310
        for f in changes[3]:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   311
            revisions += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   312
            filelinkrevs.setdefault(f, []).append(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   313
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   314
    print "checking manifests"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   315
    for i in range(repo.manifest.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   316
        n = repo.manifest.node(i)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   317
        ca = repo.changelog.node(repo.manifest.linkrev(n))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   318
        cc = manifestchangeset[n]
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   319
        if ca != cc:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   320
            print "manifest %s points to %s, not %s" % \
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   321
                  (hg.hex(n), hg.hex(ca), hg.hex(cc))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   322
        m = repo.manifest.read(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   323
        for f, fn in m.items():
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   324
            filenodes.setdefault(f, {})[fn] = 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   325
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   326
    print "crosschecking files in changesets and manifests"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   327
    for f in filenodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   328
        if f not in filelinkrevs:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   329
            print "file %s in manifest but not in changesets"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   330
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   331
    for f in filelinkrevs:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   332
        if f not in filenodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   333
            print "file %s in changeset but not in manifest"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   334
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   335
    print "checking files"
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   336
    for f in filenodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   337
        files += 1
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   338
        fl = repo.file(f)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   339
        nodes = {"\0"*20: 1}
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   340
        for i in range(fl.count()):
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   341
            n = fl.node(i)
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   342
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   343
            if n not in filenodes[f]:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   344
                print "%s:%s not in manifests" % (f, hg.hex(n))
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   345
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   346
                del filenodes[f][n]
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   347
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   348
            flr = fl.linkrev(n)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   349
            if flr not in filelinkrevs[f]:
11
7f16aaeed62f Allow checkout by number or hash
oxymoron@cinder.waste.org
parents: 5
diff changeset
   350
                print "%s:%s points to unexpected changeset rev %d" \
7f16aaeed62f Allow checkout by number or hash
oxymoron@cinder.waste.org
parents: 5
diff changeset
   351
                      % (f, hg.hex(n), fl.linkrev(n))
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   352
            else:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   353
                filelinkrevs[f].remove(flr)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   354
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   355
            # verify contents
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   356
            t = fl.read(n)
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   357
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   358
            # verify parents
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   359
            (p1, p2) = fl.parents(n)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   360
            if p1 not in nodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   361
                print "%s:%s unknown parent 1 %s" % (f, hg.hex(n), hg.hex(p1))
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   362
            if p2 not in nodes:
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   363
                print "file %s:%s unknown parent %s" % (f, hg.hex(n), hg.hex(p1))
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   364
            nodes[n] = 1
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   365
17
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   366
        # cross-check
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   367
        for flr in filelinkrevs[f]:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   368
            print "changeset rev %d not in %s" % (flr, f)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   369
            
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   370
        for node in filenodes[f]:
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   371
            print "node %s in manifests not in %s" % (hg.hex(n), f)
ffe6a5ca1a89 Make hg verify do more thorough cross-checking.
mpm@selenic.com
parents: 16
diff changeset
   372
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   373
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   374
    print "%d files, %d changesets, %d total revisions" % (files, changesets,
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   375
                                                           revisions)
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   376
    
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   377
else:
18
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   378
    print "unknown command\n"
2fd3e1e3783f Give a friendlier message when repo isn't found
mpm@selenic.com
parents: 17
diff changeset
   379
    help()
0
9117c6561b0b Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff changeset
   380
    sys.exit(1)