예제 #1
0
    def export_threads(self, root_transport):
        """Export the threads in this loom as branches.

        :param root_transport: Transport for the directory to place branches
            under.  Defaults to branch root transport.
        """
        threads = self.get_loom_state().get_threads()
        for thread_name, thread_revision, _parents in threads:
            thread_transport = root_transport.clone(thread_name)
            user_location = urlutils.unescape_for_display(
                thread_transport.base, 'utf-8')
            try:
                control_dir = controldir.ControlDir.open(
                    thread_transport.base,
                    possible_transports=[thread_transport])
                tree, branch = control_dir._get_tree_branch()
            except errors.NotBranchError:
                trace.note('Creating branch at %s' % user_location)
                branch = controldir.ControlDir.create_branch_convenience(
                    thread_transport.base,
                    possible_transports=[thread_transport])
                tree, branch = branch.controldir.open_tree_or_branch(
                    thread_transport.base)
            else:
                if thread_revision == branch.last_revision():
                    trace.note('Skipping up-to-date branch at %s' %
                               user_location)
                    continue
                else:
                    trace.note('Updating branch at %s' % user_location)
            if tree is not None:
                tree.pull(self, stop_revision=thread_revision)
            else:
                branch.pull(self, stop_revision=thread_revision)
예제 #2
0
 def __init__(self, dirname, parity, branch):
     self.dirname = dirname
     self.parity = parity
     self.branch = branch
     if branch is not None:
         # If a branch is empty, bzr raises an exception when trying this
         try:
             self.last_change = datetime.datetime.utcfromtimestamp(
                 branch.repository.get_revision(
                     branch.last_revision()).timestamp)
         except:
             self.last_change = None
예제 #3
0
 def __init__(self, dirname, parity, branch):
     self.dirname = urlutils.unquote(dirname)
     self.parity = parity
     self.branch = branch
     if branch is not None:
         # If a branch is empty, bzr raises an exception when trying this
         try:
             self.last_revision = branch.repository.get_revision(branch.last_revision())
             self.last_change_time = datetime.datetime.utcfromtimestamp(self.last_revision.timestamp)
         except errors.NoSuchRevision:
             self.last_revision = None
             self.last_change_time = None
예제 #4
0
 def test_commit_nicks(self):
     """Nicknames are committed to the revision"""
     self.get_transport().mkdir('bzr.dev')
     wt = self.make_branch_and_tree('bzr.dev')
     branch = wt.branch
     branch.nick = "My happy branch"
     wt.commit('My commit respect da nick.')
     committed = branch.repository.get_revision(branch.last_revision())
     if branch.repository._format.supports_storing_branch_nick:
         self.assertEqual(committed.properties["branch-nick"],
                          "My happy branch")
     else:
         self.assertNotIn("branch-nick", committed.properties)
예제 #5
0
    def __init__(self,
                 branch,
                 whole_history_data_cache,
                 revinfo_disk_cache=None,
                 cache_key=None):
        assert branch.is_locked(), (
            "Can only construct a History object with a read-locked branch.")
        self._branch = branch
        self._branch_tags = None
        self._inventory_cache = {}
        self._branch_nick = self._branch.get_config().get_nickname()
        self.log = logging.getLogger('loggerhead.%s' % (self._branch_nick, ))

        self.last_revid = branch.last_revision()

        caches = [RevInfoMemoryCache(whole_history_data_cache)]
        if revinfo_disk_cache:
            caches.append(revinfo_disk_cache)
        self._load_whole_history_data(caches, cache_key)