# # # patch "monotone.py" # from [14703f12598029fee13c25072af45ea09d59fb87] # to [3fb788b372946354426762e6a39e4a901bd78c05] # # patch "plain.py" # from [e20493981c6d73984ac2900ff5eefba37e48f22a] # to [12effba80d8859a5a658224fd39adc1c21913a4b] # ============================================================ --- monotone.py 14703f12598029fee13c25072af45ea09d59fb87 +++ monotone.py 3fb788b372946354426762e6a39e4a901bd78c05 @@ -189,7 +189,7 @@ class Monotone: self.process = subprocess.Popen([self.executable, "--db", self.db, "automate", "stdio"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=None) + stderr=subprocess.PIPE) if self.process.poll() is not None: self.process.wait() self.process = None @@ -236,10 +236,14 @@ class Monotone: try: return parser(self.process.stdout) except MonotoneError, e: + error = strip_mtn_error_garbage(self.process.stderr.read()) import time time.sleep(0) if self.process.poll() != None: - raise MonotoneError, "monotone process died unexpectedly (exit code %i)" % self.process.poll() + if error: + raise MonotoneError, error + else: + raise MonotoneError, "monotone process died unexpectedly (exit code %i)" % self.process.poll() else: raise @@ -334,3 +338,6 @@ def decode_cert_packet_info(cert_packet) if not m: raise Exception("bad cert packet: %s..." % repr(cert_packet)) return (m.group(1), m.group(2), m.group(3)) + +def strip_mtn_error_garbage(str): + return "".join( line.lstrip("mtn:") for line in str.splitlines(True) ) ============================================================ --- plain.py e20493981c6d73984ac2900ff5eefba37e48f22a +++ plain.py 12effba80d8859a5a658224fd39adc1c21913a4b @@ -86,12 +86,23 @@ def getDefaultConfigFile(): homeDir = "." return os.path.normpath(os.path.join(homeDir, ".mtndumb")) +def print_prefixed(where, prefix, message): + prefix_str = "" + if prefix: + prefix_str = prefix + ": " + + for line in [ line.strip() for line in message.splitlines() if line ]: + print >> where, "%s: %s%s" % ("mtndumb", prefix_str, line) + def informative(message): - print "mtndumb: %s" % message + print_prefixed(sys.stdout, None, message) def verbose(message): - print "mtndumb: %s" % message + print_prefixed(sys.stdout, None, message) +def error(message): + print_prefixed(sys.stderr, "error", message) + def parseOpt(): par = OptionParser(usage= @@ -204,15 +215,18 @@ def main(): mtn = Dumbtone(options.db, options.verbose) - if action=="pull": - mtn.do_pull(url, branch_pattern, **optdict) - elif action=="push": - mtn.do_push(url, branch_pattern, **optdict) - elif action=="sync": - mtn.do_sync(url, branch_pattern, **optdict) - elif action=="clone": - mtn.monotone.ensure_db() - mtn.do_pull(url, branch_pattern, **optdict) + try: + if action=="pull": + mtn.do_pull(url, branch_pattern, **optdict) + elif action=="push": + mtn.do_push(url, branch_pattern, **optdict) + elif action=="sync": + mtn.do_sync(url, branch_pattern, **optdict) + elif action=="clone": + mtn.monotone.ensure_db() + mtn.do_pull(url, branch_pattern, **optdict) + except monotone.MonotoneError,e: + error(str(e)) saveConfig(options,config) if __name__ == "__main__":