mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
Remove all remaining print statements
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Remove all remaining print statements Convert most prints to ui.warn or ui.write Pass a write function into transactions manifest hash: d1b0af7a344fc087a5acfe3ae87b782c20d043e0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCx1Q3ywK+sNU5EO8RAqSTAJwM5t/m+JOlf2ZXOjuItCSdFiubcwCdFm3G HoicikSYpTgfCj2pIRfyLjo= =Loqo -----END PGP SIGNATURE-----
This commit is contained in:
parent
57e171d1a4
commit
4394004b4a
@ -400,22 +400,22 @@ def debugcheckdirstate(ui, repo):
|
||||
for f in dc:
|
||||
state = repo.dirstate.state(f)
|
||||
if state in "nr" and f not in m1:
|
||||
print "%s in state %s, but not listed in manifest1" % (f, state)
|
||||
ui.warn("%s in state %s, but not in manifest1\n" % (f, state))
|
||||
errors += 1
|
||||
if state in "a" and f in m1:
|
||||
print "%s in state %s, but also listed in manifest1" % (f, state)
|
||||
ui.warn("%s in state %s, but also in manifest1\n" % (f, state))
|
||||
errors += 1
|
||||
if state in "m" and f not in m1 and f not in m2:
|
||||
print "%s in state %s, but not listed in either manifest" % \
|
||||
(f, state)
|
||||
ui.warn("%s in state %s, but not in either manifest\n" %
|
||||
(f, state))
|
||||
errors += 1
|
||||
for f in m1:
|
||||
state = repo.dirstate.state(f)
|
||||
if state not in "nrm":
|
||||
print "%s in manifest1, but listed as state %s" % (f, state)
|
||||
ui.warn("%s in manifest1, but listed as state %s" % (f, state))
|
||||
errors += 1
|
||||
if errors:
|
||||
print ".hg/dirstate inconsistent with current parent's manifest"
|
||||
ui.warn(".hg/dirstate inconsistent with current parent's manifest\n")
|
||||
sys.exit(1)
|
||||
|
||||
def debugdumpdirstate(ui, repo):
|
||||
@ -424,27 +424,27 @@ def debugdumpdirstate(ui, repo):
|
||||
keys = dc.keys()
|
||||
keys.sort()
|
||||
for file in keys:
|
||||
print "%s => %c" % (file, dc[file][0])
|
||||
ui.write("%c %s\n" % (dc[file][0], file))
|
||||
|
||||
def debugindex(ui, file):
|
||||
r = hg.revlog(hg.opener(""), file, "")
|
||||
print " rev offset length base linkrev"+\
|
||||
" p1 p2 nodeid"
|
||||
ui.write(" rev offset length base linkrev" +
|
||||
" p1 p2 nodeid\n")
|
||||
for i in range(r.count()):
|
||||
e = r.index[i]
|
||||
print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % (
|
||||
i, e[0], e[1], e[2], e[3],
|
||||
hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5]))
|
||||
ui.write("% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s..\n" % (
|
||||
i, e[0], e[1], e[2], e[3],
|
||||
hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])))
|
||||
|
||||
def debugindexdot(ui, file):
|
||||
r = hg.revlog(hg.opener(""), file, "")
|
||||
print "digraph G {"
|
||||
ui.write("digraph G {\n")
|
||||
for i in range(r.count()):
|
||||
e = r.index[i]
|
||||
print "\t%d -> %d" % (r.rev(e[4]), i)
|
||||
ui.write("\t%d -> %d\n" % (r.rev(e[4]), i))
|
||||
if e[5] != hg.nullid:
|
||||
print "\t%d -> %d" % (r.rev(e[5]), i)
|
||||
print "}"
|
||||
ui.write("\t%d -> %d\n" % (r.rev(e[5]), i))
|
||||
ui.write("}\n")
|
||||
|
||||
def diff(ui, repo, *files, **opts):
|
||||
"""diff working directory (or selected files)"""
|
||||
@ -502,15 +502,14 @@ def doexport(ui, repo, changeset, seqno, total, revwidth, opts):
|
||||
else:
|
||||
fp = sys.stdout
|
||||
|
||||
print >> fp, "# HG changeset patch"
|
||||
print >> fp, "# User %s" % change[1]
|
||||
print >> fp, "# Node ID %s" % hg.hex(node)
|
||||
print >> fp, "# Parent %s" % hg.hex(prev)
|
||||
print >> fp
|
||||
fp.write("# HG changeset patch\n")
|
||||
fp.write("# User %s\n" % change[1])
|
||||
fp.write("# Node ID %s\n" % hg.hex(node))
|
||||
fp.write("# Parent %s\n" % hg.hex(prev))
|
||||
if other != hg.nullid:
|
||||
print >> fp, "# Parent %s" % hg.hex(other)
|
||||
print >> fp, change[4].rstrip()
|
||||
print >> fp
|
||||
fp.write("# Parent %s\n" % hg.hex(other))
|
||||
fp.write(change[4].rstrip())
|
||||
fp.write("\n\n")
|
||||
|
||||
dodiff(fp, ui, repo, None, prev, node)
|
||||
|
||||
@ -715,7 +714,7 @@ def rawcommit(ui, repo, *flist, **rc):
|
||||
try: text = open(rc['logfile']).read()
|
||||
except IOError: pass
|
||||
if not text and not rc['logfile']:
|
||||
print "missing commit text"
|
||||
ui.warn("abort: missing commit text\n")
|
||||
return 1
|
||||
|
||||
files = relpath(repo, list(flist))
|
||||
@ -754,10 +753,10 @@ def status(ui, repo):
|
||||
(c, a, d, u) = repo.changes(None, None)
|
||||
(c, a, d, u) = map(lambda x: relfilter(repo, x), (c, a, d, u))
|
||||
|
||||
for f in c: print "C", f
|
||||
for f in a: print "A", f
|
||||
for f in d: print "R", f
|
||||
for f in u: print "?", f
|
||||
for f in c: ui.write("C ", f, "\n")
|
||||
for f in a: ui.write("A ", f, "\n")
|
||||
for f in d: ui.write("R ", f, "\n")
|
||||
for f in u: ui.write("? ", f, "\n")
|
||||
|
||||
def tag(ui, repo, name, rev = None, **opts):
|
||||
"""add a tag for the current tip or a given revision"""
|
||||
|
@ -520,7 +520,8 @@ class localrepository:
|
||||
ds = ""
|
||||
self.opener("undo.dirstate", "w").write(ds)
|
||||
|
||||
return transaction.transaction(self.opener, self.join("journal"),
|
||||
return transaction.transaction(self.ui.warn,
|
||||
self.opener, self.join("journal"),
|
||||
self.join("undo"))
|
||||
|
||||
def recover(self):
|
||||
@ -1350,7 +1351,7 @@ class localrepository:
|
||||
try:
|
||||
delta = mdiff.patchtext(self.manifest.delta(n))
|
||||
except KeyboardInterrupt:
|
||||
print "aborted"
|
||||
self.ui.warn("aborted")
|
||||
sys.exit(0)
|
||||
except Exception, inst:
|
||||
self.ui.warn("unpacking manifest %s: %s\n"
|
||||
@ -1392,7 +1393,6 @@ class localrepository:
|
||||
if n not in filenodes[f]:
|
||||
self.ui.warn("%s: %d:%s not in manifests\n"
|
||||
% (f, i, short(n)))
|
||||
print len(filenodes[f].keys()), fl.count(), f
|
||||
errors += 1
|
||||
else:
|
||||
del filenodes[f][n]
|
||||
|
@ -54,7 +54,7 @@ def up(p):
|
||||
return up + "/"
|
||||
|
||||
def httphdr(type):
|
||||
print 'Content-type: %s\n' % type
|
||||
sys.stdout.write('Content-type: %s\n\n' % type)
|
||||
|
||||
def write(*things):
|
||||
for thing in things:
|
||||
|
@ -88,7 +88,6 @@ def diff(a, b, sorted=0):
|
||||
try:
|
||||
d = sortdiff(a, b)
|
||||
except:
|
||||
print a, b
|
||||
raise
|
||||
else:
|
||||
d = difflib.SequenceMatcher(None, a, b).get_matching_blocks()
|
||||
|
@ -15,13 +15,14 @@ import os
|
||||
import util
|
||||
|
||||
class transaction:
|
||||
def __init__(self, opener, journal, after = None):
|
||||
def __init__(self, report, opener, journal, after = None):
|
||||
self.journal = None
|
||||
|
||||
# abort here if the journal already exists
|
||||
if os.path.exists(journal):
|
||||
raise "journal already exists - run hg recover"
|
||||
|
||||
self.report = report
|
||||
self.opener = opener
|
||||
self.after = after
|
||||
self.entries = []
|
||||
@ -57,17 +58,17 @@ class transaction:
|
||||
def abort(self):
|
||||
if not self.entries: return
|
||||
|
||||
print "transaction abort!"
|
||||
self.report("transaction abort!\n")
|
||||
|
||||
for f, o in self.entries:
|
||||
try:
|
||||
self.opener(f, "a").truncate(o)
|
||||
except:
|
||||
print "failed to truncate", f
|
||||
self.report("failed to truncate %s\n" % f)
|
||||
|
||||
self.entries = []
|
||||
|
||||
print "rollback completed"
|
||||
self.report("rollback completed\n")
|
||||
|
||||
def rollback(opener, file):
|
||||
for l in open(file).readlines():
|
||||
|
Loading…
Reference in New Issue
Block a user