Ejemplo n.º 1
0
 def do_write(self):
     """Write all data to the bundle"""
     trace.note(ngettext('Bundling %d revision.', 'Bundling %d revisions.',
                         len(self.revision_ids)), len(self.revision_ids))
     self.repository.lock_read()
     try:
         self.bundle.begin()
         self.write_info()
         self.write_files()
         self.write_revisions()
         self.bundle.end()
     finally:
         self.repository.unlock()
     return self.revision_ids
    def run(self, location=None, committer=None, dry_run=False):
        if location is None:
            bzrdir = controldir.ControlDir.open_containing('.')[0]
        else:
            # Passed in locations should be exact
            bzrdir = controldir.ControlDir.open(location)
        branch = bzrdir.open_branch()
        repo = branch.repository
        branch_config = branch.get_config_stack()

        if committer is None:
            committer = branch_config.get('email')
        gpg_strategy = gpg.GPGStrategy(branch_config)

        count = 0
        repo.lock_write()
        try:
            graph = repo.get_graph()
            repo.start_write_group()
            try:
                for rev_id, parents in graph.iter_ancestry(
                    [branch.last_revision()]):
                    if _mod_revision.is_null(rev_id):
                        continue
                    if parents is None:
                        # Ignore ghosts
                        continue
                    if repo.has_signature_for_revision_id(rev_id):
                        continue
                    rev = repo.get_revision(rev_id)
                    if rev.committer != committer:
                        continue
                    # We have a revision without a signature who has a
                    # matching committer, start signing
                    self.outf.write("%s\n" % rev_id)
                    count += 1
                    if not dry_run:
                        repo.sign_revision(rev_id, gpg_strategy)
            except:
                repo.abort_write_group()
                raise
            else:
                repo.commit_write_group()
        finally:
            repo.unlock()
        self.outf.write(
            ngettext('Signed %d revision.\n', 'Signed %d revisions.\n', count)
            % count)
    def run(self, location=None, committer=None, dry_run=False):
        if location is None:
            bzrdir = controldir.ControlDir.open_containing('.')[0]
        else:
            # Passed in locations should be exact
            bzrdir = controldir.ControlDir.open(location)
        branch = bzrdir.open_branch()
        repo = branch.repository
        branch_config = branch.get_config_stack()

        if committer is None:
            committer = branch_config.get('email')
        gpg_strategy = gpg.GPGStrategy(branch_config)

        count = 0
        repo.lock_write()
        try:
            graph = repo.get_graph()
            repo.start_write_group()
            try:
                for rev_id, parents in graph.iter_ancestry(
                        [branch.last_revision()]):
                    if _mod_revision.is_null(rev_id):
                        continue
                    if parents is None:
                        # Ignore ghosts
                        continue
                    if repo.has_signature_for_revision_id(rev_id):
                        continue
                    rev = repo.get_revision(rev_id)
                    if rev.committer != committer:
                        continue
                    # We have a revision without a signature who has a
                    # matching committer, start signing
                    self.outf.write("%s\n" % rev_id)
                    count += 1
                    if not dry_run:
                        repo.sign_revision(rev_id, gpg_strategy)
            except:
                repo.abort_write_group()
                raise
            else:
                repo.commit_write_group()
        finally:
            repo.unlock()
        self.outf.write(
            ngettext('Signed %d revision.\n', 'Signed %d revisions.\n', count) %
            count)