예제 #1
0
 def test_simple_rename(self):
     self.assertEquals(
         [(u"newname", u"oldname", 2, NODE_DIR)],
         list(
             apply_reverse_changes(
                 [u"newname"],
                 {u"newname": (u"A", u"oldname", 2, NODE_DIR)})))
예제 #2
0
 def test_parent_rename(self):
     self.assertEquals(
         [(u'tags/2.5-M2', u'geotools/tags/2.5-M2', 5617, NODE_DIR)],
         list(
             apply_reverse_changes(
                 [u'trunk/geotools2', u'tags/2.5-M2', u'trunk'], {
                     u'tags': (u'A', u'geotools/tags', 5617, NODE_DIR),
                     u'geotools/tags': (u'D', None, -1, NODE_DIR)
                 })))
예제 #3
0
 def test_chaco(self):
     self.assertEquals([(u'packages/enthought-chaco2/trunk',
                         u'packages/chaco2/trunk', 3, NODE_DIR)],
                       list(
                           apply_reverse_changes(
                               [u'packages/enthought-chaco2/trunk'], {
                                   u"packages/chaco2":
                                   ("D", None, -1, NODE_DIR),
                                   u"packages/enthought-chaco2":
                                   ("A", u"packages/chaco2", 3, NODE_DIR),
                                   u"packages/enthought-chaco2/trunk":
                                   ("D", None, -1, NODE_DIR)
                               })))
예제 #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
예제 #5
0
 def test_add(self):
     self.assertEquals([],
                       list(
                           apply_reverse_changes(
                               [u"somename"],
                               {u"somename": (u"A", None, -1, NODE_DIR)})))
예제 #6
0
 def test_delete(self):
     self.assertEquals([(u"somename/bloe", None, -1, NODE_DIR)],
                       list(
                           apply_reverse_changes(
                               [u"somename/bloe"],
                               {u"somename": (u"D", None, -1, NODE_DIR)})))