Exemple #1
0
 def needs_manual_check(revmeta):
     if (prefix is not None and not changes.path_is_child(
             prefix, revmeta.metarev.branch_path)):
         # Parent branch path is outside of prefix; we need to
         # check manually
         return True
     if revmeta.metarev.revnum < from_revnum:
         return True
     return False
Exemple #2
0
 def _get_ids(self, path, rev, revprops):
     revmeta, mapping = self._related_revs[rev]
     revmeta.metarev._revprops = revprops
     path = path.strip("/")
     if not changes.path_is_child(revmeta.metarev.branch_path, path):
         raise KeyError(path)
     ip = path[len(revmeta.metarev.branch_path):].strip("/")
     idmap = self._repository.get_fileid_map(revmeta, mapping)
     return idmap.lookup(mapping, ip)
Exemple #3
0
def get_local_changes(paths, branch):
    """Obtain all of the changes relative to a particular path
    (usually a branch path).

    :param paths: Changes
    :param branch: Path under which to select changes
    """
    new_paths = {}
    for p in sorted(paths.keys(), reverse=False):
        if not changes.path_is_child(branch, p):
            continue
        data = paths[p]
        new_p = p[len(branch):].strip(u"/")
        if data[1] is not None:
            # Branch copy
            if new_p == u"":
                data = ('M', None)
            else:
                data = (data[0], (data[1], data[2]))
        else:
            data = (data[0], None)
        new_paths[new_p] = data
    return new_paths
Exemple #4
0
    def do(self):
        """Yield revisions and deleted branches.

        This is where the *real* magic happens.
        """
        assert self.from_revnum >= self.to_revnum
        count = self.from_revnum-self.to_revnum
        for (paths, revnum, revprops) in self._iter_log:
            assert all(isinstance(p, text_type) for p in paths), "%r" % paths
            assert revnum <= self.from_revnum
            if self._pb:
                self._pb.update("discovering revisions",
                        abs(self.from_revnum-revnum), count)

            if self._last_revnum is not None:
                # Import all metabranches_history where key > revnum
                for x in xrange(self._last_revnum, revnum-1, -1):
                    for bp in self._pending_ancestors[x].keys():
                        self._ancestors[bp].update(self._pending_ancestors[x][bp])
                    del self._pending_ancestors[x]
                    self._unusual.update(self._unusual_history[x])
                    del self._unusual_history[x]
                    if self._prefixes is not None:
                        self._prefixes.update(self._pending_prefixes[x])

            # Eliminate anything that's not under prefixes/
            if self._prefixes is not None:
                for bp in self._ancestors.keys():
                    if not changes.under_prefixes(bp, self._prefixes):
                        del self._ancestors[bp]
                        self._unusual.discard(bp)

            changed_bps = set()
            deletes = []

            if paths == {}:
                paths = {u"": ("M", None, -1, NODE_DIR)}

            # Find out what branches have changed
            for p in sorted(paths):
                if (self._prefixes is not None and
                    not changes.under_prefixes(p, self._prefixes)):
                    continue
                action = paths[p][0]
                try:
                    (_, bp, ip) = self.layout.split_project_path(p, self._project)
                except svn_errors.NotSvnBranchPath:
                    pass
                else:
                    # Did something change inside a branch?
                    if action != 'D' or ip != u"":
                        changed_bps.add(bp)
                for u in self._unusual:
                    if (p == u and not action in ('D', 'R')) or changes.path_is_child(u, p):
                        changed_bps.add(u)
                if action in ('R', 'D') and (
                    self.layout.is_branch_or_tag(p, self._project) or
                    self.layout.is_branch_or_tag_parent(p, self._project)):
                    deletes.append(p)

            # Mention deletes
            for d in deletes:
                yield ("delete", (p, revnum))

            # Dictionary with the last revision known for each branch
            # Report the new revisions
            for bp in changed_bps:
                metarev = MetaRevision(self._graph,
                    self._graph._log._transport.get_uuid(), bp, revnum, paths=paths,
                    revprops=revprops)
                assert metarev is not None
                for c in self._ancestors[bp]:
                    c._set_lhs_parent(metarev)
                del self._ancestors[bp]
                self._ancestors[bp] = set([metarev])
                # If this branch was started here, terminate it
                if (bp in paths and paths[bp][0] in ('A', 'R') and
                    paths[bp][1] is None):
                    metarev._set_lhs_parent(None)
                    del self._ancestors[bp]
                yield "revision", metarev

            # Apply reverse renames and the like for the next round
            for new_name, old_name, old_rev, kind in changes.apply_reverse_changes(
                self._ancestors.keys(), paths):
                self._unusual.discard(new_name)
                if old_name is None:
                    # Didn't exist previously, mark as beginning and remove.
                    for rev in self._ancestors[new_name]:
                        if rev.branch_path != new_name:
                            raise AssertionError("Revision %d has invalid branch path %s, expected %s" % (revnum, rev.branch_path, new_name))
                        rev._set_lhs_parent(None)
                    del self._ancestors[new_name]
                else:
                    # was originated somewhere else
                    data = self._ancestors[new_name]
                    del self._ancestors[new_name]
                    self._pending_ancestors[old_rev][old_name].update(data)
                    if not self.layout.is_branch_or_tag(old_name, self._project):
                        self._unusual_history[old_rev].add(old_name)

            # Update the prefixes, if necessary
            if self._prefixes:
                for new_name, old_name, old_rev, kind in changes.apply_reverse_changes(
                    self._prefixes, paths):
                    if old_name is None:
                        # Didn't exist previously, terminate prefix
                        self._prefixes.discard(new_name)
                        if len(self._prefixes) == 0:
                            return
                    else:
                        self._prefixes.discard(new_name)
                        self._pending_prefixes[old_rev].add(old_name)

            self._last_revnum = revnum
Exemple #5
0
 def test_unrelated(self):
     self.assertFalse(path_is_child(u"bla", u"bar"))
Exemple #6
0
 def test_child_empty_bp(self):
     self.assertTrue(path_is_child(u"", u"bar"))
Exemple #7
0
 def test_self(self):
     self.assertTrue(path_is_child(u"trunk", u"trunk"))
Exemple #8
0
 def test_child_path(self):
     self.assertTrue(path_is_child(u"trunk", u"trunk/bar"))
Exemple #9
0
 def test_both_empty(self):
     self.assertTrue(path_is_child(u"", u""))