Add -q quiet option
Make -d and -v do something
Add a bunch of debug and note messages
--- a/hg Tue May 17 10:13:00 2005 -0800
+++ b/hg Tue May 17 11:06:59 2005 -0800
@@ -89,7 +89,8 @@
options = {}
opts = [('v', 'verbose', None, 'verbose'),
- ('d', 'debug', None, 'debug')]
+ ('d', 'debug', None, 'debug'),
+ ('q', 'quiet', None, 'quiet')]
args = fancyopts.fancyopts(sys.argv[1:], opts, options,
'hg [options] <command> [command options] [files]')
@@ -100,7 +101,7 @@
except:
cmd = ""
-ui = hg.ui(options["verbose"], options["debug"])
+ui = hg.ui(options["verbose"], options["debug"], options["quiet"])
if cmd == "init":
repo = hg.repository(ui, ".", create=1)
@@ -115,7 +116,7 @@
try:
repo = hg.repository(ui=ui)
except IOError:
- print "Unable to open repository"
+ ui.warn("Unable to open repository\n")
sys.exit(0)
if cmd == "checkout" or cmd == "co":
@@ -176,9 +177,9 @@
elif cmd == "status":
(c, a, d) = repo.diffdir(repo.root, repo.current)
- for f in c: print "C", f
- for f in a: print "?", f
- for f in d: print "R", f
+ for f in c: ui.status("C %s\n" % f)
+ for f in a: ui.status("? %s\n" % f)
+ for f in d: ui.status("R %s\n" % f)
elif cmd == "diff":
revs = []
@@ -191,7 +192,7 @@
revs = map(lambda x: repo.lookup(x), doptions['revision'])
if len(revs) > 2:
- print "too many revisions to diff"
+ self.ui.warn("too many revisions to diff\n")
sys.exit(1)
if os.getcwd() != repo.root:
@@ -343,7 +344,7 @@
elif cmd == "merge":
if args:
other = hg.repository(ui, args[0])
- print "requesting changegroup"
+ ui.status("requesting changegroup")
cg = repo.getchangegroup(other)
repo.addchangegroup(cg)
else:
--- a/mercurial/hg.py Tue May 17 10:13:00 2005 -0800
+++ b/mercurial/hg.py Tue May 17 11:06:59 2005 -0800
@@ -468,6 +468,7 @@
new = {}
linkrev = self.changelog.count()
for f in update:
+ self.ui.note(f + "\n")
try:
t = file(f).read()
except IOError:
@@ -515,6 +516,7 @@
l.sort()
stats = []
for f in l:
+ self.ui.note(f + "\n")
r = self.file(f)
t = r.revision(mmap[f])
try:
@@ -656,23 +658,29 @@
def getchangegroup(self, remote):
tip = remote.branches([])[0]
+ self.ui.debug("remote tip branch is %s:%s\n" %
+ (short(tip[0]), short(tip[1])))
m = self.changelog.nodemap
unknown = [tip]
search = []
fetch = []
if tip[0] in m:
+ self.ui.note("nothing to do!\n")
return None
while unknown:
n = unknown.pop(0)
if n == nullid: break
if n[1] and n[1] in m: # do we know the base?
+ self.ui.debug("found incomplete branch %s\n" % short(n[1]))
search.append(n) # schedule branch range for scanning
else:
for b in remote.branches([n[2], n[3]]):
if b[0] in m:
if n[1] not in fetch:
+ self.ui.debug("found new changeset %s\n" %
+ short(n[1]))
fetch.append(n[1]) # earliest unknown
else:
unknown.append(b)
@@ -685,15 +693,22 @@
for i in l + [n[1]]:
if i in m:
if f <= 4:
+ self.ui.debug("found new branch changeset %s\n" %
+ short(p))
fetch.append(p)
else:
+ self.ui.debug("narrowed branch search to %s:%s\n"
+ % (short(p), short(i)))
search.append((p, i))
break
p, f = i, f * 2
for f in fetch:
if f in m:
- raise "already have", hex(f[:4])
+ raise "already have", short(f[:4])
+
+ self.ui.note("merging new changesets starting at " +
+ " ".join([short(f) for f in fetch]) + "\n")
return remote.changegroup(fetch)
@@ -752,13 +767,13 @@
tr = self.transaction()
simple = True
- print "merging changesets"
+ self.ui.status("merging changesets\n")
# pull off the changeset group
csg = getchunk()
co = self.changelog.tip()
cn = self.changelog.addgroup(csg, lambda x: self.changelog.count(), tr)
- print "merging manifests"
+ self.ui.status("merging manifests\n")
# pull off the manifest group
mfg = getchunk()
mo = self.manifest.tip()
@@ -770,7 +785,7 @@
resolverev = self.changelog.count()
# process the files
- print "merging files"
+ self.ui.status("merging files\n")
new = {}
while 1:
f = getchunk(4)
@@ -848,6 +863,7 @@
self.ui = ui
def do_cmd(self, cmd, **args):
+ self.ui.debug("sending %s command\n" % cmd)
q = {"cmd": cmd}
q.update(args)
qs = urllib.urlencode(q)
@@ -884,8 +900,10 @@
return localrepository(ui, path, create)
class ui:
- def __init__(self, verbose=False, debug=False):
- self.verbose = verbose
+ def __init__(self, verbose=False, debug=False, quiet=False):
+ self.quiet = quiet and not verbose and not debug
+ self.verbose = verbose or debug
+ self.debugflag = debug
def write(self, *args):
for a in args:
sys.stdout.write(str(a))
@@ -896,13 +914,13 @@
if re.match(pat, r):
return r
def status(self, *msg):
- self.write(*msg)
+ if not self.quiet: self.write(*msg)
def warn(self, msg):
self.write(*msg)
def note(self, msg):
if self.verbose: self.write(*msg)
def debug(self, msg):
- if self.debug: self.write(*msg)
+ if self.debugflag: self.write(*msg)
def edit(self, text):
(fd, name) = tempfile.mkstemp("hg")
f = os.fdopen(fd, "w")
--- a/mercurial/revlog.py Tue May 17 10:13:00 2005 -0800
+++ b/mercurial/revlog.py Tue May 17 11:06:59 2005 -0800
@@ -13,6 +13,7 @@
def hex(node): return binascii.hexlify(node)
def bin(node): return binascii.unhexlify(node)
+def short(node): return hex(node[:4])
def compress(text):
return zlib.compress(text)