Show More
@@ -400,22 +400,22 def debugcheckdirstate(ui, repo): | |||||
400 | for f in dc: |
|
400 | for f in dc: | |
401 | state = repo.dirstate.state(f) |
|
401 | state = repo.dirstate.state(f) | |
402 | if state in "nr" and f not in m1: |
|
402 | if state in "nr" and f not in m1: | |
403 |
|
|
403 | ui.warn("%s in state %s, but not in manifest1\n" % (f, state)) | |
404 | errors += 1 |
|
404 | errors += 1 | |
405 | if state in "a" and f in m1: |
|
405 | if state in "a" and f in m1: | |
406 |
|
|
406 | ui.warn("%s in state %s, but also in manifest1\n" % (f, state)) | |
407 | errors += 1 |
|
407 | errors += 1 | |
408 | if state in "m" and f not in m1 and f not in m2: |
|
408 | if state in "m" and f not in m1 and f not in m2: | |
409 |
|
|
409 | ui.warn("%s in state %s, but not in either manifest\n" % | |
410 | (f, state) |
|
410 | (f, state)) | |
411 | errors += 1 |
|
411 | errors += 1 | |
412 | for f in m1: |
|
412 | for f in m1: | |
413 | state = repo.dirstate.state(f) |
|
413 | state = repo.dirstate.state(f) | |
414 | if state not in "nrm": |
|
414 | if state not in "nrm": | |
415 |
|
|
415 | ui.warn("%s in manifest1, but listed as state %s" % (f, state)) | |
416 | errors += 1 |
|
416 | errors += 1 | |
417 | if errors: |
|
417 | if errors: | |
418 |
|
|
418 | ui.warn(".hg/dirstate inconsistent with current parent's manifest\n") | |
419 | sys.exit(1) |
|
419 | sys.exit(1) | |
420 |
|
420 | |||
421 | def debugdumpdirstate(ui, repo): |
|
421 | def debugdumpdirstate(ui, repo): | |
@@ -424,27 +424,27 def debugdumpdirstate(ui, repo): | |||||
424 | keys = dc.keys() |
|
424 | keys = dc.keys() | |
425 | keys.sort() |
|
425 | keys.sort() | |
426 | for file in keys: |
|
426 | for file in keys: | |
427 |
|
|
427 | ui.write("%c %s\n" % (dc[file][0], file)) | |
428 |
|
428 | |||
429 | def debugindex(ui, file): |
|
429 | def debugindex(ui, file): | |
430 | r = hg.revlog(hg.opener(""), file, "") |
|
430 | r = hg.revlog(hg.opener(""), file, "") | |
431 |
|
|
431 | ui.write(" rev offset length base linkrev" + | |
432 | " p1 p2 nodeid" |
|
432 | " p1 p2 nodeid\n") | |
433 | for i in range(r.count()): |
|
433 | for i in range(r.count()): | |
434 | e = r.index[i] |
|
434 | e = r.index[i] | |
435 |
|
|
435 | ui.write("% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s..\n" % ( | |
436 | i, e[0], e[1], e[2], e[3], |
|
436 | i, e[0], e[1], e[2], e[3], | |
437 | hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) |
|
437 | hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))) | |
438 |
|
438 | |||
439 | def debugindexdot(ui, file): |
|
439 | def debugindexdot(ui, file): | |
440 | r = hg.revlog(hg.opener(""), file, "") |
|
440 | r = hg.revlog(hg.opener(""), file, "") | |
441 |
|
|
441 | ui.write("digraph G {\n") | |
442 | for i in range(r.count()): |
|
442 | for i in range(r.count()): | |
443 | e = r.index[i] |
|
443 | e = r.index[i] | |
444 |
|
|
444 | ui.write("\t%d -> %d\n" % (r.rev(e[4]), i)) | |
445 | if e[5] != hg.nullid: |
|
445 | if e[5] != hg.nullid: | |
446 |
|
|
446 | ui.write("\t%d -> %d\n" % (r.rev(e[5]), i)) | |
447 |
|
|
447 | ui.write("}\n") | |
448 |
|
448 | |||
449 | def diff(ui, repo, *files, **opts): |
|
449 | def diff(ui, repo, *files, **opts): | |
450 | """diff working directory (or selected files)""" |
|
450 | """diff working directory (or selected files)""" | |
@@ -502,15 +502,14 def doexport(ui, repo, changeset, seqno, | |||||
502 | else: |
|
502 | else: | |
503 | fp = sys.stdout |
|
503 | fp = sys.stdout | |
504 |
|
504 | |||
505 |
|
|
505 | fp.write("# HG changeset patch\n") | |
506 |
|
|
506 | fp.write("# User %s\n" % change[1]) | |
507 |
|
|
507 | fp.write("# Node ID %s\n" % hg.hex(node)) | |
508 |
|
|
508 | fp.write("# Parent %s\n" % hg.hex(prev)) | |
509 | print >> fp |
|
|||
510 | if other != hg.nullid: |
|
509 | if other != hg.nullid: | |
511 |
|
|
510 | fp.write("# Parent %s\n" % hg.hex(other)) | |
512 |
|
|
511 | fp.write(change[4].rstrip()) | |
513 | print >> fp |
|
512 | fp.write("\n\n") | |
514 |
|
513 | |||
515 | dodiff(fp, ui, repo, None, prev, node) |
|
514 | dodiff(fp, ui, repo, None, prev, node) | |
516 |
|
515 | |||
@@ -715,7 +714,7 def rawcommit(ui, repo, *flist, **rc): | |||||
715 | try: text = open(rc['logfile']).read() |
|
714 | try: text = open(rc['logfile']).read() | |
716 | except IOError: pass |
|
715 | except IOError: pass | |
717 | if not text and not rc['logfile']: |
|
716 | if not text and not rc['logfile']: | |
718 |
|
|
717 | ui.warn("abort: missing commit text\n") | |
719 | return 1 |
|
718 | return 1 | |
720 |
|
719 | |||
721 | files = relpath(repo, list(flist)) |
|
720 | files = relpath(repo, list(flist)) | |
@@ -754,10 +753,10 def status(ui, repo): | |||||
754 | (c, a, d, u) = repo.changes(None, None) |
|
753 | (c, a, d, u) = repo.changes(None, None) | |
755 | (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) |
|
754 | (c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u)) | |
756 |
|
755 | |||
757 |
for f in c: |
|
756 | for f in c: ui.write("C ", f, "\n") | |
758 |
for f in a: |
|
757 | for f in a: ui.write("A ", f, "\n") | |
759 |
for f in d: |
|
758 | for f in d: ui.write("R ", f, "\n") | |
760 |
for f in u: |
|
759 | for f in u: ui.write("? ", f, "\n") | |
761 |
|
760 | |||
762 | def tag(ui, repo, name, rev = None, **opts): |
|
761 | def tag(ui, repo, name, rev = None, **opts): | |
763 | """add a tag for the current tip or a given revision""" |
|
762 | """add a tag for the current tip or a given revision""" |
@@ -520,7 +520,8 class localrepository: | |||||
520 | ds = "" |
|
520 | ds = "" | |
521 | self.opener("undo.dirstate", "w").write(ds) |
|
521 | self.opener("undo.dirstate", "w").write(ds) | |
522 |
|
522 | |||
523 |
return transaction.transaction(self. |
|
523 | return transaction.transaction(self.ui.warn, | |
|
524 | self.opener, self.join("journal"), | |||
524 | self.join("undo")) |
|
525 | self.join("undo")) | |
525 |
|
526 | |||
526 | def recover(self): |
|
527 | def recover(self): | |
@@ -1350,7 +1351,7 class localrepository: | |||||
1350 | try: |
|
1351 | try: | |
1351 | delta = mdiff.patchtext(self.manifest.delta(n)) |
|
1352 | delta = mdiff.patchtext(self.manifest.delta(n)) | |
1352 | except KeyboardInterrupt: |
|
1353 | except KeyboardInterrupt: | |
1353 |
|
|
1354 | self.ui.warn("aborted") | |
1354 | sys.exit(0) |
|
1355 | sys.exit(0) | |
1355 | except Exception, inst: |
|
1356 | except Exception, inst: | |
1356 | self.ui.warn("unpacking manifest %s: %s\n" |
|
1357 | self.ui.warn("unpacking manifest %s: %s\n" | |
@@ -1392,7 +1393,6 class localrepository: | |||||
1392 | if n not in filenodes[f]: |
|
1393 | if n not in filenodes[f]: | |
1393 | self.ui.warn("%s: %d:%s not in manifests\n" |
|
1394 | self.ui.warn("%s: %d:%s not in manifests\n" | |
1394 | % (f, i, short(n))) |
|
1395 | % (f, i, short(n))) | |
1395 | print len(filenodes[f].keys()), fl.count(), f |
|
|||
1396 | errors += 1 |
|
1396 | errors += 1 | |
1397 | else: |
|
1397 | else: | |
1398 | del filenodes[f][n] |
|
1398 | del filenodes[f][n] |
@@ -54,7 +54,7 def up(p): | |||||
54 | return up + "/" |
|
54 | return up + "/" | |
55 |
|
55 | |||
56 | def httphdr(type): |
|
56 | def httphdr(type): | |
57 |
|
|
57 | sys.stdout.write('Content-type: %s\n\n' % type) | |
58 |
|
58 | |||
59 | def write(*things): |
|
59 | def write(*things): | |
60 | for thing in things: |
|
60 | for thing in things: |
@@ -88,7 +88,6 def diff(a, b, sorted=0): | |||||
88 | try: |
|
88 | try: | |
89 | d = sortdiff(a, b) |
|
89 | d = sortdiff(a, b) | |
90 | except: |
|
90 | except: | |
91 | print a, b |
|
|||
92 | raise |
|
91 | raise | |
93 | else: |
|
92 | else: | |
94 | d = difflib.SequenceMatcher(None, a, b).get_matching_blocks() |
|
93 | d = difflib.SequenceMatcher(None, a, b).get_matching_blocks() |
@@ -15,13 +15,14 import os | |||||
15 | import util |
|
15 | import util | |
16 |
|
16 | |||
17 | class transaction: |
|
17 | class transaction: | |
18 | def __init__(self, opener, journal, after = None): |
|
18 | def __init__(self, report, opener, journal, after = None): | |
19 | self.journal = None |
|
19 | self.journal = None | |
20 |
|
20 | |||
21 | # abort here if the journal already exists |
|
21 | # abort here if the journal already exists | |
22 | if os.path.exists(journal): |
|
22 | if os.path.exists(journal): | |
23 | raise "journal already exists - run hg recover" |
|
23 | raise "journal already exists - run hg recover" | |
24 |
|
24 | |||
|
25 | self.report = report | |||
25 | self.opener = opener |
|
26 | self.opener = opener | |
26 | self.after = after |
|
27 | self.after = after | |
27 | self.entries = [] |
|
28 | self.entries = [] | |
@@ -57,17 +58,17 class transaction: | |||||
57 | def abort(self): |
|
58 | def abort(self): | |
58 | if not self.entries: return |
|
59 | if not self.entries: return | |
59 |
|
60 | |||
60 |
|
|
61 | self.report("transaction abort!\n") | |
61 |
|
62 | |||
62 | for f, o in self.entries: |
|
63 | for f, o in self.entries: | |
63 | try: |
|
64 | try: | |
64 | self.opener(f, "a").truncate(o) |
|
65 | self.opener(f, "a").truncate(o) | |
65 | except: |
|
66 | except: | |
66 |
print |
|
67 | self.report("failed to truncate %s\n" % f) | |
67 |
|
68 | |||
68 | self.entries = [] |
|
69 | self.entries = [] | |
69 |
|
70 | |||
70 |
|
|
71 | self.report("rollback completed\n") | |
71 |
|
72 | |||
72 | def rollback(opener, file): |
|
73 | def rollback(opener, file): | |
73 | for l in open(file).readlines(): |
|
74 | for l in open(file).readlines(): |
General Comments 0
You need to be logged in to leave comments.
Login now