##// END OF EJS Templates
transform a bunch of print statements to appropriate ui calls
Matt Mackall -
r5878:d39af2ea default
parent child Browse files
Show More
@@ -45,7 +45,7 b''
45 45 # Revisions context menu will now display additional entries to fire
46 46 # vdiff on hovered and selected revisions.
47 47
48 import sys, os
48 import os
49 49 from mercurial import hg, fancyopts, commands, ui, util, patch, revlog
50 50
51 51 def difftree(ui, repo, node1=None, node2=None, *files, **opts):
@@ -61,17 +61,14 b' def difftree(ui, repo, node1=None, node2'
61 61
62 62 for f in modified:
63 63 # TODO get file permissions
64 print ":100664 100664 %s %s M\t%s\t%s" % (hg.short(mmap[f]),
65 hg.short(mmap2[f]),
66 f, f)
64 ui.write(":100664 100664 %s %s M\t%s\t%s\n" %
65 (hg.short(mmap[f]), hg.short(mmap2[f]), f, f))
67 66 for f in added:
68 print ":000000 100664 %s %s N\t%s\t%s" % (empty,
69 hg.short(mmap2[f]),
70 f, f)
67 ui.write(":000000 100664 %s %s N\t%s\t%s\n" %
68 (empty, hg.short(mmap2[f]), f, f))
71 69 for f in removed:
72 print ":100664 000000 %s %s D\t%s\t%s" % (hg.short(mmap[f]),
73 empty,
74 f, f)
70 ui.write(":100664 000000 %s %s D\t%s\t%s\n" %
71 (hg.short(mmap[f]), empty, f, f))
75 72 ##
76 73
77 74 while True:
@@ -93,7 +90,7 b' def difftree(ui, repo, node1=None, node2'
93 90 node1 = repo.changelog.parents(node1)[0]
94 91 if opts['patch']:
95 92 if opts['pretty']:
96 catcommit(repo, node2, "")
93 catcommit(ui, repo, node2, "")
97 94 patch.diff(repo, node1, node2,
98 95 files=files,
99 96 opts=patch.diffopts(ui, {'git': True}))
@@ -102,14 +99,14 b' def difftree(ui, repo, node1=None, node2'
102 99 if not opts['stdin']:
103 100 break
104 101
105 def catcommit(repo, n, prefix, ctx=None):
102 def catcommit(ui, repo, n, prefix, ctx=None):
106 103 nlprefix = '\n' + prefix;
107 104 if ctx is None:
108 105 ctx = repo.changectx(n)
109 106 (p1, p2) = ctx.parents()
110 print "tree %s" % (hg.short(ctx.changeset()[0])) # use ctx.node() instead ??
111 if p1: print "parent %s" % (hg.short(p1.node()))
112 if p2: print "parent %s" % (hg.short(p2.node()))
107 ui.write("tree %s\n" % hg.short(ctx.changeset()[0])) # use ctx.node() instead ??
108 if p1: ui.write("parent %s\n" % hg.short(p1.node()))
109 if p2: ui.write("parent %s\n" % hg.short(p2.node()))
113 110 date = ctx.date()
114 111 description = ctx.description().replace("\0", "")
115 112 lines = description.splitlines()
@@ -118,24 +115,24 b' def catcommit(repo, n, prefix, ctx=None)'
118 115 else:
119 116 committer = ctx.user()
120 117
121 print "author %s %s %s" % (ctx.user(), int(date[0]), date[1])
122 print "committer %s %s %s" % (committer, int(date[0]), date[1])
123 print "revision %d" % ctx.rev()
124 print "branch %s" % ctx.branch()
125 print ""
118 ui.write("author %s %s %s\n" % (ctx.user(), int(date[0]), date[1]))
119 ui.write("committer %s %s %s\n" % (committer, int(date[0]), date[1]))
120 ui.write("revision %d\n" % ctx.rev())
121 ui.write("branch %s\n\n" % ctx.branch())
122
126 123 if prefix != "":
127 print "%s%s" % (prefix, description.replace('\n', nlprefix).strip())
124 ui.write("%s%s\n" % (prefix, description.replace('\n', nlprefix).strip()))
128 125 else:
129 print description
126 ui.write(description + "\n")
130 127 if prefix:
131 sys.stdout.write('\0')
128 ui.write('\0')
132 129
133 130 def base(ui, repo, node1, node2):
134 131 """Output common ancestor information"""
135 132 node1 = repo.lookup(node1)
136 133 node2 = repo.lookup(node2)
137 134 n = repo.changelog.ancestor(node1, node2)
138 print hg.short(n)
135 ui.write(hg.short(n) + "\n")
139 136
140 137 def catfile(ui, repo, type=None, r=None, **opts):
141 138 """cat a specific revision"""
@@ -158,10 +155,10 b' def catfile(ui, repo, type=None, r=None,'
158 155
159 156 while r:
160 157 if type != "commit":
161 sys.stderr.write("aborting hg cat-file only understands commits\n")
162 sys.exit(1);
158 ui.warn("aborting hg cat-file only understands commits\n")
159 return 1;
163 160 n = repo.lookup(r)
164 catcommit(repo, n, prefix)
161 catcommit(ui, repo, n, prefix)
165 162 if opts['stdin']:
166 163 try:
167 164 (type, r) = raw_input().split(' ');
@@ -175,7 +172,7 b' def catfile(ui, repo, type=None, r=None,'
175 172 # telling you which commits are reachable from the supplied ones via
176 173 # a bitmask based on arg position.
177 174 # you can specify a commit to stop at by starting the sha1 with ^
178 def revtree(args, repo, full="tree", maxnr=0, parents=False):
175 def revtree(ui, args, repo, full="tree", maxnr=0, parents=False):
179 176 def chlogwalk():
180 177 count = repo.changelog.count()
181 178 i = count
@@ -260,24 +257,24 b' def revtree(args, repo, full="tree", max'
260 257 if pp[1] != hg.nullid:
261 258 parentstr += " " + hg.short(pp[1])
262 259 if not full:
263 print hg.short(n) + parentstr
260 ui.write("%s%s\n" % (hg.short(n), parentstr))
264 261 elif full == "commit":
265 print hg.short(n) + parentstr
266 catcommit(repo, n, ' ', ctx)
262 ui.write("%s%s\n" % (hg.short(n), parentstr))
263 catcommit(ui, repo, n, ' ', ctx)
267 264 else:
268 265 (p1, p2) = repo.changelog.parents(n)
269 266 (h, h1, h2) = map(hg.short, (n, p1, p2))
270 267 (i1, i2) = map(repo.changelog.rev, (p1, p2))
271 268
272 269 date = ctx.date()[0]
273 print "%s %s:%s" % (date, h, mask),
270 ui.write("%s %s:%s" % (date, h, mask))
274 271 mask = is_reachable(want_sha1, reachable, p1)
275 272 if i1 != hg.nullrev and mask > 0:
276 print "%s:%s " % (h1, mask),
273 ui.write("%s:%s " % (h1, mask)),
277 274 mask = is_reachable(want_sha1, reachable, p2)
278 275 if i2 != hg.nullrev and mask > 0:
279 print "%s:%s " % (h2, mask),
280 print ""
276 ui.write("%s:%s " % (h2, mask))
277 ui.write("\n")
281 278 if maxnr and count >= maxnr:
282 279 break
283 280 count += 1
@@ -305,7 +302,7 b' def revlist(ui, repo, *revs, **opts):'
305 302 else:
306 303 full = None
307 304 copy = [x for x in revs]
308 revtree(copy, repo, full, opts['max_count'], opts['parents'])
305 revtree(ui, copy, repo, full, opts['max_count'], opts['parents'])
309 306
310 307 def config(ui, repo, **opts):
311 308 """print extension options"""
@@ -224,7 +224,7 b' class queue:'
224 224 def write_list(items, path):
225 225 fp = self.opener(path, 'w')
226 226 for i in items:
227 print >> fp, i
227 fp.write("%s\n" % i)
228 228 fp.close()
229 229 if self.applied_dirty: write_list(map(str, self.applied), self.status_path)
230 230 if self.series_dirty: write_list(self.full_series, self.series_path)
@@ -1267,7 +1267,7 b' class queue:'
1267 1267 self.ui.warn("saved queue repository parents: %s %s\n" %
1268 1268 (hg.short(qpp[0]), hg.short(qpp[1])))
1269 1269 if qupdate:
1270 print "queue directory updating"
1270 self.ui.status(_("queue directory updating\n"))
1271 1271 r = self.qrepo()
1272 1272 if not r:
1273 1273 self.ui.warn("Unable to load queue repository\n")
@@ -38,7 +38,6 b' def fancyopts(args, options, state):'
38 38 if isinstance(default, list):
39 39 state[name] = default[:]
40 40 elif callable(default):
41 print "whoa", name, default
42 41 state[name] = None
43 42 else:
44 43 state[name] = default
@@ -1372,7 +1372,8 b' def diffstat(patchlines):'
1372 1372 try:
1373 1373 p = popen2.Popen3('diffstat -p1 -w79 2>/dev/null > ' + name)
1374 1374 try:
1375 for line in patchlines: print >> p.tochild, line
1375 for line in patchlines:
1376 p.tochild.write(line + "\n")
1376 1377 p.tochild.close()
1377 1378 if p.wait(): return
1378 1379 fp = os.fdopen(fd, 'r')
General Comments 0
You need to be logged in to leave comments. Login now