def update_batch(batch): '''updates thgstatus for all paths in batch''' roots, notifypaths = getrepos(batch) if roots: _ui = ui.ui(); failedroots = set() errorstream = cStringIO.StringIO() _stderr = sys.stderr sys.stderr = errorstream try: # Ensure that all unset dirstate entries can be updated. time.sleep(2) updated_any = False for r in sorted(roots): try: if shlib.update_thgstatus(_ui, r, wait=False): updated_any = True shlib.shell_notify([r], noassoc=True) logger.msg('Updated ' + r) except (IOError, OSError): print "IOError or OSError on updating %s (check permissions)" % r logger.msg('Failed updating %s (check permissions)' % r) failedroots.add(r) except (error.Abort, error.ConfigError, error.RepoError, error.RevlogError, ImportError), e: logger.msg('Failed updating %s (%s)' % (r, str(e))) failedroots.add(r) notifypaths -= failedroots if notifypaths: shlib.shell_notify(list(notifypaths), noassoc=not updated_any) logger.msg('Shell notified') errmsg = errorstream.getvalue() if errmsg: logger.msg('stderr: %s' % errmsg) finally:
def run(_ui, *pats, **opts): if opts.get('all'): roots = [] base = os.getcwd() for f in os.listdir(base): r = paths.find_root(os.path.join(base, f)) if r is not None: roots.append(r) for r in roots: _ui.note("%s\n" % r) shlib.update_thgstatus(_ui, r, wait=False) shlib.shell_notify([r]) return root = paths.find_root() if opts.get('repository'): root = opts.get('repository') if root is None: _ui.status("no repository\n") return repo = hg.repository(_ui, root) if opts.get('remove'): try: os.remove(cachefilepath(repo)) except OSError: pass return if opts.get('show'): try: f = open(cachefilepath(repo), 'rb') for e in f: _ui.status("%s %s\n" % (e[0], e[1:-1])) f.close() except IOError: _ui.status("*no status*\n") return wait = opts.get('delay') is not None shlib.update_thgstatus(_ui, root, wait=wait) if opts.get('notify'): shlib.shell_notify(opts.get('notify')) _ui.note("thgstatus updated\n")
def run(_ui, *pats, **opts): if opts.get('all'): roots = [] base = os.getcwd() for f in os.listdir(base): r = paths.find_root(os.path.join(base, f)) if r is not None: roots.append(r) for r in roots: _ui.note("%s\n" % r) shlib.update_thgstatus(_ui, r, wait=False) shlib.shell_notify([r]) return root = paths.find_root() if opts.get('repository'): root = opts.get('repository') if root is None: _ui.status("no repository\n") return repo = hg.repository(_ui, root) if opts.get('remove'): try: os.remove(cachefilepath(repo)) except OSError: pass return if opts.get('show'): try: f = open(cachefilepath(repo), 'rb') for e in f: _ui.status("%s %s\n" % (e[0], e[1:-1])) f.close() except IOError: _ui.status("*no status*\n") return wait = opts.get('delay') is not None shlib.update_thgstatus(_ui, root, wait=wait) if opts.get('notify'): shlib.shell_notify(opts.get('notify')) _ui.note("thgstatus updated\n")