contrib/rewrite-log
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
Mon, 16 Apr 2007 20:17:39 -0300
changeset 4359 2e3c54fb79a3
parent 3711 9ccc6be9ae4d
permissions -rwxr-xr-x
actually port simplemerge to hg - use bdiff instead of patiencediff; this is a larger change, since bdiff works on 2 multi-line strings, while patiencediff works on 2 lists; - rename the main class from Merge3 to Merge3Text and add a Merge3 class that derives from Merge3Text. This new Merge3 class has the same interface from the original class, so that the tests still work; - Merge3 uses util.binary to detect binary data and raises util.Abort instead of a specific exception; - don't use the @decorator syntax, to keep python2.3 compatibility; - the test uses unittest, which likes to print how long it took to run. This obviously doesn't play too well with hg's test suite, so we override time.time to fool unittest; - one test has a different (but still valid) output because of the different diff algorithm used; - the TestCase class used by bzr has some extras to help debugging. test-merge3.py used 2 of them: - log method to log some data - assertEqualDiff method to ease viewing diffs of diffs We add a dummy log method and use regular assertEquals instead of assertEqualDiff. - make simplemerge executable and add "#!/usr/bin/env python" header
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
141
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     1
#!/usr/bin/env python
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     2
import sys, os
3711
9ccc6be9ae4d update rewrite-log for tip ; chmod it
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3512
diff changeset
     3
from mercurial import revlog, transaction, node, util
141
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     4
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     5
f = sys.argv[1]
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     6
3711
9ccc6be9ae4d update rewrite-log for tip ; chmod it
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3512
diff changeset
     7
r1 = revlog.revlog(util.opener(os.getcwd(), audit=False), f + ".i", f + ".d")
9ccc6be9ae4d update rewrite-log for tip ; chmod it
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3512
diff changeset
     8
r2 = revlog.revlog(util.opener(os.getcwd(), audit=False), f + ".i2", f + ".d2")
141
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
     9
3711
9ccc6be9ae4d update rewrite-log for tip ; chmod it
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 3512
diff changeset
    10
tr = transaction.transaction(sys.stderr.write, open, "journal")
141
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    11
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    12
for i in xrange(r1.count()):
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    13
    n = r1.node(i)
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    14
    p1, p2 = r1.parents(n)
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    15
    l = r1.linkrev(n)
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    16
    t = r1.revision(n)
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    17
    n2 = r2.addrevision(t, tr, l, p1, p2)
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    18
tr.close()
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    19
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    20
os.rename(f + ".i", f + ".i.old")
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    21
os.rename(f + ".d", f + ".d.old")
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    22
os.rename(f + ".i2", f + ".i")
5f471a75d607 Simple script to recompress a log file
mpm@selenic.com
parents:
diff changeset
    23
os.rename(f + ".d2", f + ".d")