contrib/shrink-revlog.py
branchstable
changeset 10496 45734b51c99b
parent 10440 b39b32c33269
child 10508 cc35ad583e66
equal deleted inserted replaced
10495:2c2d2f1354b4 10496:45734b51c99b
    30     root = []
    30     root = []
    31     # build children and roots
    31     # build children and roots
    32     ui.status('reading revs\n')
    32     ui.status('reading revs\n')
    33     try:
    33     try:
    34         for i in rl:
    34         for i in rl:
    35             ui.progress('reading', i, total=len(rl))
    35             ui.progress(_('reading'), i, total=len(rl))
    36             children[i] = []
    36             children[i] = []
    37             parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
    37             parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
    38             # in case of duplicate parents
    38             # in case of duplicate parents
    39             if len(parents) == 2 and parents[0] == parents[1]:
    39             if len(parents) == 2 and parents[0] == parents[1]:
    40                 del parents[1]
    40                 del parents[1]
    43                 children[p].append(i)
    43                 children[p].append(i)
    44 
    44 
    45             if len(parents) == 0:
    45             if len(parents) == 0:
    46                 root.append(i)
    46                 root.append(i)
    47     finally:
    47     finally:
    48         ui.progress('reading', None, total=len(rl))
    48         ui.progress(_('reading'), None, total=len(rl))
    49 
    49 
    50     # XXX this is a reimplementation of the 'branchsort' topo sort
    50     # XXX this is a reimplementation of the 'branchsort' topo sort
    51     # algorithm in hgext.convert.convcmd... would be nice not to duplicate
    51     # algorithm in hgext.convert.convcmd... would be nice not to duplicate
    52     # the algorithm
    52     # the algorithm
    53     ui.status('sorting revs\n')
    53     ui.status('sorting revs\n')
    73 
    73 
    74     ui.status('writing revs\n')
    74     ui.status('writing revs\n')
    75 
    75 
    76     count = [0]
    76     count = [0]
    77     def progress(*args):
    77     def progress(*args):
    78         ui.progress('writing', count[0], total=len(order))
    78         ui.progress(_('writing'), count[0], total=len(order))
    79         count[0] += 1
    79         count[0] += 1
    80 
    80 
    81     order = [r1.node(r) for r in order]
    81     order = [r1.node(r) for r in order]
    82 
    82 
    83     # this is a bit ugly, but it works
    83     # this is a bit ugly, but it works
    87     try:
    87     try:
    88         group = util.chunkbuffer(r1.group(order, lookup, progress))
    88         group = util.chunkbuffer(r1.group(order, lookup, progress))
    89         chunkiter = changegroup.chunkiter(group)
    89         chunkiter = changegroup.chunkiter(group)
    90         r2.addgroup(chunkiter, unlookup, tr)
    90         r2.addgroup(chunkiter, unlookup, tr)
    91     finally:
    91     finally:
    92         ui.progress('writing', None, len(order))
    92         ui.progress(_('writing'), None, len(order))
    93 
    93 
    94 def report(ui, olddatafn, newdatafn):
    94 def report(ui, olddatafn, newdatafn):
    95     oldsize = float(os.stat(olddatafn).st_size)
    95     oldsize = float(os.stat(olddatafn).st_size)
    96     newsize = float(os.stat(newdatafn).st_size)
    96     newsize = float(os.stat(newdatafn).st_size)
    97 
    97