Exemplo n.º 1
0
 def execCmd(sub, cmd, kind):
     """if sub == None, cmd is executed inside repo; else, inside sub.
     If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). 
     Else, do either print0 or the debugging message, then execute the command.
     kind is the type of the (sub)repo.
     """
     if sub == None:
         envargdict = dict(HG_SUBPATH='.',
                           HG_SUBURL='.',
                           HG_SUBSTATE=repo['.'].hex(),
                           HG_REPO=repo.root,
                           HG_SUBTYPE=kind)
         relpath = '.'
         cmdwd = repo.root
     else:
         # subrepo.relpath was renamed to subrepo.subrelpath in
         # 18b5b6392fcf.
         if hasattr(subrepo, 'relpath'):
             relpath = subrepo.relpath(sub)
         else:
             relpath = subrepo.subrelpath(sub)
         envargdict = dict(HG_SUBPATH=relpath,
                           HG_SUBURL=sub._path,
                           HG_SUBSTATE=sub._state[1],
                           HG_REPO=repo.root,
                           HG_SUBTYPE=kind)
         cmdwd = os.path.join(repo.root, relpath)
     if cmd != None and (repotypefilter == '' or repotypefilter == kind):
         if print0:
             ui.write(relpath, "\0")
         if cmd != '':
             if not print0: ui.note(_("executing '%s' in %s\n") % (cmd, relpath))
             util.system(cmd, environ=envargdict, cwd=cmdwd, onerr=onerr,
                         errprefix=_('terminated onsub in %s') % relpath)
Exemplo n.º 2
0
def foreach(ui, repo, cmd, depthfirst, maxdepth, print0, ignoreerrors):
    """execute cmd in repo.root and in each subrepository"""
    ctx = repo['.']
    work = [(1, ctx.sub(subpath)) for subpath in sorted(ctx.substate)]
    if depthfirst:
        work.reverse()

    while work:
        if depthfirst:
            (depth, sub) = work.pop()
        else:
            (depth, sub) = work.pop(0)
        if depth > maxdepth >= 0:
            continue

        # subrepo.relpath was renamed to subrepo.subrelpath in
        # 18b5b6392fcf.
        if hasattr(subrepo, 'relpath'):
            relpath = subrepo.relpath(sub)
        else:
            relpath = subrepo.subrelpath(sub)

        if print0:
            ui.write(relpath, "\0")
        else:
            ui.note(_("executing '%s' in %s\n") % (cmd, relpath))
        if ignoreerrors:
            onerr = None
        else:
            onerr = util.Abort
        util.system(cmd,
                    environ=dict(HG_SUBPATH=relpath,
                                 HG_SUBURL=sub._path,
                                 HG_SUBSTATE=sub._state[1],
                                 HG_REPO=repo.root),
                    cwd=os.path.join(repo.root, relpath),
                    onerr=onerr,
                    errprefix=_('terminated onsub in %s') % relpath)

        if isinstance(sub, subrepo.hgsubrepo):
            rev = sub._state[1]
            ctx = sub._repo[rev]
            w = [(depth + 1, ctx.sub(subpath))
                 for subpath in sorted(ctx.substate)]
            if depthfirst:
                w.reverse()
            work.extend(w)
Exemplo n.º 3
0
def foreach(ui, repo, cmd, depthfirst, maxdepth, print0, ignoreerrors):
    """execute cmd in repo.root and in each subrepository"""
    ctx = repo['.']
    work = [(1, ctx.sub(subpath)) for subpath in sorted(ctx.substate)]
    if depthfirst:
        work.reverse()

    while work:
        if depthfirst:
            (depth, sub) = work.pop()
        else:
            (depth, sub) = work.pop(0)
        if depth > maxdepth >= 0:
            continue

        # subrepo.relpath was renamed to subrepo.subrelpath in
        # 18b5b6392fcf.
        if hasattr(subrepo, 'relpath'):
            relpath = subrepo.relpath(sub)
        else:
            relpath = subrepo.subrelpath(sub)

        if print0:
            ui.write(relpath, "\0")
        else:
            ui.note(_("executing '%s' in %s\n") % (cmd, relpath))
        if ignoreerrors:
            onerr = None
        else:
            onerr = util.Abort
        util.system(cmd, environ=dict(HG_SUBPATH=relpath,
                                      HG_SUBURL=sub._path,
                                      HG_SUBSTATE=sub._state[1],
                                      HG_REPO=repo.root),
                    cwd=os.path.join(repo.root, relpath),
                    onerr=onerr,
                    errprefix=_('terminated onsub in %s') % relpath)

        if isinstance(sub, subrepo.hgsubrepo):
            rev = sub._state[1]
            ctx = sub._repo[rev]
            w = [(depth + 1, ctx.sub(subpath))
                 for subpath in sorted(ctx.substate)]
            if depthfirst:
                w.reverse()
            work.extend(w)
Exemplo n.º 4
0
 def execCmd(sub, cmd, kind):
     """if sub == None, cmd is executed inside repo; else, inside sub.
     If cmd == None, do nothing. If cmd == '', do only the print0 (if needed). 
     Else, do either print0 or the debugging message, then execute the command.
     kind is the type of the (sub)repo.
     """
     if sub == None:
         envargdict = dict(HG_SUBPATH='.',
                           HG_SUBURL='.',
                           HG_SUBSTATE=repo['.'].hex(),
                           HG_REPO=repo.root,
                           HG_SUBTYPE=kind)
         relpath = '.'
         cmdwd = repo.root
     else:
         # subrepo.relpath was renamed to subrepo.subrelpath in
         # 18b5b6392fcf.
         if hasattr(subrepo, 'relpath'):
             relpath = subrepo.relpath(sub)
         else:
             relpath = subrepo.subrelpath(sub)
         envargdict = dict(HG_SUBPATH=relpath,
                           HG_SUBURL=sub._path,
                           HG_SUBSTATE=sub._state[1],
                           HG_REPO=repo.root,
                           HG_SUBTYPE=kind)
         cmdwd = os.path.join(repo.root, relpath)
     if cmd != None and (repotypefilter == '' or repotypefilter == kind):
         if print0:
             ui.write(relpath, "\0")
         if cmd != '':
             if not print0:
                 ui.write(_("executing '%s' in %s\n") % (cmd, relpath))
             util.system(cmd,
                         environ=envargdict,
                         cwd=cmdwd,
                         onerr=onerr,
                         errprefix=_('terminated onsub in %s') % relpath)