Example #1
0
def _computehidden(repo):
    hidden = repoview.filterrevs(repo, 'visible')
    cl = repo.changelog
    dynamic = hidden & repo._explicitaccess
    if dynamic:
        blocked = cl.ancestors(dynamic, inclusive=True)
        hidden = frozenset(r for r in hidden if r not in blocked)
    return hidden
Example #2
0
def _computehidden(repo):
    hidden = repoview.filterrevs(repo, 'visible')
    cl = repo.changelog
    dynamic = hidden & repo._explicitaccess
    if dynamic:
        blocked = cl.ancestors(dynamic, inclusive=True)
        hidden = frozenset(r for r in hidden if r not in blocked)
    return hidden
Example #3
0
 def d():
     repo.invalidatevolatilesets()
     repoview.filterrevs(repo, name)
Example #4
0
def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
            newincludes, newexcludes, force):
    oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
    newmatch = narrowspec.match(repo.root, newincludes, newexcludes)

    # This is essentially doing "hg outgoing" to find all local-only
    # commits. We will then check that the local-only commits don't
    # have any changes to files that will be untracked.
    unfi = repo.unfiltered()
    outgoing = discovery.findcommonoutgoing(unfi, remote,
                                            commoninc=commoninc)
    ui.status(_('looking for local changes to affected paths\n'))
    localnodes = []
    for n in itertools.chain(outgoing.missing, outgoing.excluded):
        if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
            localnodes.append(n)
    revstostrip = unfi.revs('descendants(%ln)', localnodes)
    hiddenrevs = repoview.filterrevs(repo, 'visible')
    visibletostrip = list(repo.changelog.node(r)
                          for r in (revstostrip - hiddenrevs))
    if visibletostrip:
        ui.status(_('The following changeset(s) or their ancestors have '
                    'local changes not on the remote:\n'))
        maxnodes = 10
        if ui.verbose or len(visibletostrip) <= maxnodes:
            for n in visibletostrip:
                ui.status('%s\n' % node.short(n))
        else:
            for n in visibletostrip[:maxnodes]:
                ui.status('%s\n' % node.short(n))
            ui.status(_('...and %d more, use --verbose to list all\n') %
                      (len(visibletostrip) - maxnodes))
        if not force:
            raise error.Abort(_('local changes found'),
                              hint=_('use --force-delete-local-changes to '
                                     'ignore'))

    with ui.uninterruptable():
        if revstostrip:
            tostrip = [unfi.changelog.node(r) for r in revstostrip]
            if repo['.'].node() in tostrip:
                # stripping working copy, so move to a different commit first
                urev = max(repo.revs('(::%n) - %ln + null',
                                     repo['.'].node(), visibletostrip))
                hg.clean(repo, urev)
            overrides = {('devel', 'strip-obsmarkers'): False}
            with ui.configoverride(overrides, 'narrow'):
                repair.strip(ui, unfi, tostrip, topic='narrow')

        todelete = []
        for f, f2, size in repo.store.datafiles():
            if f.startswith('data/'):
                file = f[5:-2]
                if not newmatch(file):
                    todelete.append(f)
            elif f.startswith('meta/'):
                dir = f[5:-13]
                dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
                include = True
                for d in dirs:
                    visit = newmatch.visitdir(d)
                    if not visit:
                        include = False
                        break
                    if visit == 'all':
                        break
                if not include:
                    todelete.append(f)

        repo.destroying()

        with repo.transaction("narrowing"):
            for f in todelete:
                ui.status(_('deleting %s\n') % f)
                util.unlinkpath(repo.svfs.join(f))
                repo.store.markremoved(f)

            _narrowcleanupwdir(repo, oldincludes, oldexcludes, newincludes,
                               newexcludes, oldmatch, newmatch)
            repo.setnarrowpats(newincludes, newexcludes)

        repo.destroyed()
Example #5
0
 def _updateShowHiddenBtnState(self):
     hashidden = bool(repoview.filterrevs(self._repo, 'visible'))
     self.showHiddenBtn.setEnabled(hashidden)
Example #6
0
def revision_grapher(repo, **opts):
    """incremental revision grapher

    param repo       The repository
    opt   start_rev  Tip-most revision of range to graph
    opt   stop_rev   0-most revision of range to graph
    opt   follow     True means graph only ancestors of start_rev
    opt   revset     set of revisions to graph.
                     If used, then start_rev, stop_rev, and follow is ignored
    opt   branch     Only graph this branch
    opt   allparents If set in addition to branch, then cset outside the
                     branch that are ancestors to some cset inside the branch
                     is also graphed

    This generator function walks through the revision history from
    revision start_rev to revision stop_rev (which must be less than
    or equal to start_rev) and for each revision emits tuples with the
    following elements:

      - current revision
      - column of the current node in the set of ongoing edges
      - color of the node (?)
      - lines: a list of (col, next_col, color_no, line_type, children, parent)
          children: tuple of revs which connected to top of this line.
                    (or current rev if node is on the line.)
          parent:   rev which connected to bottom of this line.
        defining the edges between the current row and the next row
      - parent revisions of current revision
    """

    revset = opts.get("revset", None)
    branch = opts.get("branch", None)
    showhidden = opts.get("showhidden", None)
    if showhidden:
        revhidden = []
    else:
        revhidden = repoview.filterrevs(repo, "visible")
    if revset:
        start_rev = max(revset)
        stop_rev = min(revset)
        follow = False
        hidden = lambda rev: (rev not in revset) or (rev in revhidden)
    else:
        start_rev = opts.get("start_rev", None)
        stop_rev = opts.get("stop_rev", 0)
        follow = opts.get("follow", False)
        hidden = lambda rev: rev in revhidden

    assert start_rev is None or start_rev >= stop_rev

    curr_rev = start_rev
    revs = []
    children = [()]
    links = []  # smallest link type that applies

    if opts.get("allparents") or not branch:

        def getparents(ctx):
            return [x for x in ctx.parents() if x]

    else:

        def getparents(ctx):
            return [x for x in ctx.parents() if x and x.branch() == branch]

    rev_color = RevColorPalette(getparents)

    while curr_rev is None or curr_rev >= stop_rev:
        if hidden(curr_rev):
            curr_rev -= 1
            continue

        # Compute revs and next_revs.
        ctx = repo[curr_rev]
        if curr_rev not in revs:
            if branch and ctx.branch() != branch:
                if curr_rev is None:
                    curr_rev = len(repo)
                else:
                    curr_rev -= 1
                yield None
                continue

            # New head.
            if start_rev and follow and curr_rev != start_rev:
                curr_rev -= 1
                continue
            revs.append(curr_rev)
            links.append(LINE_TYPE_PARENT)
            children.append(())
            rev_color.addheadctx(ctx)
        curcolor = rev_color[curr_rev]
        rev_index = revs.index(curr_rev)
        next_revs = revs[:]
        next_links = links[:]
        next_children = children[:]

        # Add parents to next_revs.
        parents = [(p.rev(), LINE_TYPE_PARENT) for p in getparents(ctx) if not hidden(p.rev())]
        if "source" in ctx.extra():
            src_rev_str = ctx.extra()["source"]
            if src_rev_str in repo:
                src_rev = repo[src_rev_str].rev()
                if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
                    parents.append((src_rev, LINE_TYPE_GRAFT))
        parents_to_add = []
        links_to_add = []
        children_to_add = []
        if len(parents) > 1:
            preferred_color = None
        else:
            preferred_color = curcolor
        for parent, link_type in parents:
            if parent not in next_revs:
                parents_to_add.append(parent)
                links_to_add.append(link_type)
                children_to_add.append((curr_rev,))
                if parent not in rev_color:
                    rev_color.assigncolor(parent, preferred_color)
                    preferred_color = None
            else:
                # Merging lines should have the most solid style
                #  (= lowest style value)
                i = next_revs.index(parent)
                next_links[i] = min(next_links[i], link_type)
                next_children[i] += (curr_rev,)
            preferred_color = None

        # parents_to_add.sort()
        next_revs[rev_index : rev_index + 1] = parents_to_add
        next_links[rev_index : rev_index + 1] = links_to_add
        next_children[rev_index : rev_index + 1] = children_to_add

        lines = []
        for i, rev in enumerate(revs):
            if rev in next_revs:
                color = rev_color[rev]
                lines.append((i, next_revs.index(rev), color, links[i], children[i], rev))
            elif rev == curr_rev:
                for parent, link_type in parents:
                    color = rev_color[parent]
                    lines.append((i, next_revs.index(parent), color, link_type, (curr_rev,), parent))

        yield GraphNode(curr_rev, rev_index, curcolor, lines, parents)
        revs = next_revs
        links = next_links
        children = next_children
        if curr_rev is None:
            curr_rev = len(repo)
        else:
            curr_rev -= 1
Example #7
0
 def d():
     repo.invalidatevolatilesets()
     repoview.filterrevs(repo, name)
Example #8
0
def _narrow(
    ui,
    repo,
    remote,
    commoninc,
    oldincludes,
    oldexcludes,
    newincludes,
    newexcludes,
    force,
    backup,
):
    oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
    newmatch = narrowspec.match(repo.root, newincludes, newexcludes)

    # This is essentially doing "hg outgoing" to find all local-only
    # commits. We will then check that the local-only commits don't
    # have any changes to files that will be untracked.
    unfi = repo.unfiltered()
    outgoing = discovery.findcommonoutgoing(unfi, remote, commoninc=commoninc)
    ui.status(_(b'looking for local changes to affected paths\n'))
    progress = ui.makeprogress(
        topic=_(b'changesets'),
        unit=_(b'changesets'),
        total=len(outgoing.missing) + len(outgoing.excluded),
    )
    localnodes = []
    with progress:
        for n in itertools.chain(outgoing.missing, outgoing.excluded):
            progress.increment()
            if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
                localnodes.append(n)
    revstostrip = unfi.revs(b'descendants(%ln)', localnodes)
    hiddenrevs = repoview.filterrevs(repo, b'visible')
    visibletostrip = list(
        repo.changelog.node(r) for r in (revstostrip - hiddenrevs))
    if visibletostrip:
        ui.status(
            _(b'The following changeset(s) or their ancestors have '
              b'local changes not on the remote:\n'))
        maxnodes = 10
        if ui.verbose or len(visibletostrip) <= maxnodes:
            for n in visibletostrip:
                ui.status(b'%s\n' % short(n))
        else:
            for n in visibletostrip[:maxnodes]:
                ui.status(b'%s\n' % short(n))
            ui.status(
                _(b'...and %d more, use --verbose to list all\n') %
                (len(visibletostrip) - maxnodes))
        if not force:
            raise error.StateError(
                _(b'local changes found'),
                hint=_(b'use --force-delete-local-changes to ignore'),
            )

    with ui.uninterruptible():
        if revstostrip:
            tostrip = [unfi.changelog.node(r) for r in revstostrip]
            if repo[b'.'].node() in tostrip:
                # stripping working copy, so move to a different commit first
                urev = max(
                    repo.revs(
                        b'(::%n) - %ln + null',
                        repo[b'.'].node(),
                        visibletostrip,
                    ))
                hg.clean(repo, urev)
            overrides = {(b'devel', b'strip-obsmarkers'): False}
            if backup:
                ui.status(_(b'moving unwanted changesets to backup\n'))
            else:
                ui.status(_(b'deleting unwanted changesets\n'))
            with ui.configoverride(overrides, b'narrow'):
                repair.strip(ui, unfi, tostrip, topic=b'narrow', backup=backup)

        todelete = []
        for t, f, f2, size in repo.store.datafiles():
            if f.startswith(b'data/'):
                file = f[5:-2]
                if not newmatch(file):
                    todelete.append(f)
            elif f.startswith(b'meta/'):
                dir = f[5:-13]
                dirs = sorted(pathutil.dirs({dir})) + [dir]
                include = True
                for d in dirs:
                    visit = newmatch.visitdir(d)
                    if not visit:
                        include = False
                        break
                    if visit == b'all':
                        break
                if not include:
                    todelete.append(f)

        repo.destroying()

        with repo.transaction(b'narrowing'):
            # Update narrowspec before removing revlogs, so repo won't be
            # corrupt in case of crash
            repo.setnarrowpats(newincludes, newexcludes)

            for f in todelete:
                ui.status(_(b'deleting %s\n') % f)
                util.unlinkpath(repo.svfs.join(f))
                repo.store.markremoved(f)

            ui.status(_(b'deleting unwanted files from working copy\n'))
            with repo.dirstate.parentchange():
                narrowspec.updateworkingcopy(repo, assumeclean=True)
                narrowspec.copytoworkingcopy(repo)

        repo.destroyed()
Example #9
0
 def d():
     repo.invalidatevolatilesets()
     if opts['clear_obsstore']:
         clearfilecache(repo, 'obsstore')
     repoview.filterrevs(repo, name)
Example #10
0
def revision_grapher(repo, **opts):
    """incremental revision grapher

    param repo       The repository
    opt   start_rev  Tip-most revision of range to graph
    opt   stop_rev   0-most revision of range to graph
    opt   follow     True means graph only ancestors of start_rev
    opt   revset     set of revisions to graph.
                     If used, then start_rev, stop_rev, and follow is ignored
    opt   branch     Only graph this branch
    opt   allparents If set in addition to branch, then cset outside the
                     branch that are ancestors to some cset inside the branch
                     is also graphed

    This generator function walks through the revision history from
    revision start_rev to revision stop_rev (which must be less than
    or equal to start_rev) and for each revision emits tuples with the
    following elements:

      - current revision
      - column of the current node in the set of ongoing edges
      - color of the node (?)
      - lines: a list of (col, next_col, color_no, line_type, children, parent)
          children: tuple of revs which connected to top of this line.
                    (or current rev if node is on the line.)
          parent:   rev which connected to bottom of this line.
        defining the edges between the current row and the next row
      - parent revisions of current revision
    """

    revset = opts.get('revset', None)
    branch = opts.get('branch', None)
    showhidden = opts.get('showhidden', None)
    if showhidden:
        revhidden = []
    else:
        revhidden = repoview.filterrevs(repo, 'visible')
    if revset:
        start_rev = max(revset)
        stop_rev = min(revset)
        follow = False
        hidden = lambda rev: (rev not in revset) or (rev in revhidden)
    else:
        start_rev = opts.get('start_rev', None)
        stop_rev = opts.get('stop_rev', 0)
        follow = opts.get('follow', False)
        hidden = lambda rev: rev in revhidden

    assert start_rev is None or start_rev >= stop_rev

    curr_rev = start_rev
    revs = []
    children = [()]
    links = []  # smallest link type that applies

    if opts.get('allparents') or not branch:

        def getparents(ctx):
            return [x for x in ctx.parents() if x]
    else:

        def getparents(ctx):
            return [x for x in ctx.parents() if x and x.branch() == branch]

    rev_color = RevColorPalette(getparents)

    while curr_rev is None or curr_rev >= stop_rev:
        if hidden(curr_rev):
            curr_rev -= 1
            continue

        # Compute revs and next_revs.
        ctx = repo[curr_rev]
        if curr_rev not in revs:
            if branch and ctx.branch() != branch:
                if curr_rev is None:
                    curr_rev = len(repo)
                else:
                    curr_rev -= 1
                yield None
                continue

            # New head.
            if start_rev and follow and curr_rev != start_rev:
                curr_rev -= 1
                continue
            revs.append(curr_rev)
            links.append(LINE_TYPE_PARENT)
            children.append(())
            rev_color.addheadctx(ctx)
        curcolor = rev_color[curr_rev]
        rev_index = revs.index(curr_rev)
        next_revs = revs[:]
        next_links = links[:]
        next_children = children[:]

        # Add parents to next_revs.
        parents = [(p.rev(), LINE_TYPE_PARENT) for p in getparents(ctx)
                   if not hidden(p.rev())]
        if 'source' in ctx.extra():
            src_rev_str = ctx.extra()['source']
            if src_rev_str in repo:
                src_rev = repo[src_rev_str].rev()
                if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
                    parents.append((src_rev, LINE_TYPE_GRAFT))
        parents_to_add = []
        links_to_add = []
        children_to_add = []
        if len(parents) > 1:
            preferred_color = None
        else:
            preferred_color = curcolor
        for parent, link_type in parents:
            if parent not in next_revs:
                parents_to_add.append(parent)
                links_to_add.append(link_type)
                children_to_add.append((curr_rev, ))
                if parent not in rev_color:
                    rev_color.assigncolor(parent, preferred_color)
                    preferred_color = None
            else:
                # Merging lines should have the most solid style
                #  (= lowest style value)
                i = next_revs.index(parent)
                next_links[i] = min(next_links[i], link_type)
                next_children[i] += (curr_rev, )
            preferred_color = None

        # parents_to_add.sort()
        next_revs[rev_index:rev_index + 1] = parents_to_add
        next_links[rev_index:rev_index + 1] = links_to_add
        next_children[rev_index:rev_index + 1] = children_to_add

        lines = []
        for i, rev in enumerate(revs):
            if rev in next_revs:
                color = rev_color[rev]
                lines.append((i, next_revs.index(rev), color, links[i],
                              children[i], rev))
            elif rev == curr_rev:
                for parent, link_type in parents:
                    color = rev_color[parent]
                    lines.append((i, next_revs.index(parent), color, link_type,
                                  (curr_rev, ), parent))

        yield GraphNode(curr_rev, rev_index, curcolor, lines, parents)
        revs = next_revs
        links = next_links
        children = next_children
        if curr_rev is None:
            curr_rev = len(repo)
        else:
            curr_rev -= 1
Example #11
0
 def _updateShowHiddenBtnState(self):
     hashidden = bool(repoview.filterrevs(self._repo, "visible"))
     self.showHiddenBtn.setEnabled(hashidden)