Exemple #1
0
def _p4_empty(ctx):
    """
    Is our client view completely empty, no files, not even deleted or purged?
    """
    r = ctx.p4.run('files', '-m1',
                   p4gf_path.slash_dot_dot_dot(ctx.config.p4client))
    return not r
def _p4_empty(ctx):
    """
    Is our client view completely empty, no files, not even deleted or purged?
    """
    ### wanted to avoid doing the expensive client-creation-view-switching thing
    ### and use the code below, but couldn't work around the spaces-in-paths issue
    # p4map = p4gf_branch.calc_branch_union_client_view(ctx.config.p4client, ctx.branch_dict())
    # cmd = ['files', '-m1'] + p4map.lhs()
    # r = p4gf_util.p4run_logged(ctx.p4, cmd)
    with ctx.switched_to_union():
        r = ctx.p4.run('files', '-m1',
                       p4gf_path.slash_dot_dot_dot(ctx.p4.client))
    return not r
Exemple #3
0
    def test_block_push(self):
        """Test hook to temporarily block and let test script
        introduce conflicting changes.
        """
        s = p4gf_util.test_vars().get(p4gf_const.P4GF_TEST_BLOCK_PUSH)
        if not s:
            return

        log = logging.getLogger("test_block_push")
        block_dict = p4gf_util.test_var_to_dict(s)
        log.debug(block_dict)

        # Fetch ALL the submitted changelists as of right now.
        log.debug("p4 changes {}".format(
            p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client)))
        cl_ay = self.ctx.p4.run(
            'changes', '-l',
            p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client))

        # Don't block until after something?
        after = block_dict['after']
        if after:
            if not contains_desc(after, cl_ay):
                log.debug("Do not block until after: {}".format(after))
                return

        until = block_dict['until']
        log.debug("BLOCKING. Seen        'after': {}".format(after))
        log.debug("BLOCKING. Waiting for 'until': {}".format(until))

        changes_path_at = ("{path}@{change},now".format(
            path=p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client),
            change=cl_ay[-1]['change']))

        while not contains_desc(until, cl_ay):
            time.sleep(1)
            cl_ay = self.ctx.p4.run('changes', changes_path_at)

        log.debug("Block released")
    def test_block_push(self):
        """Test hook to temporarily block and let test script
        introduce conflicting changes.
        """
        s = p4gf_util.test_vars().get(p4gf_const.P4GF_TEST_BLOCK_PUSH)
        if not s:
            return

        log = logging.getLogger("test_block_push")
        block_dict = p4gf_util.test_var_to_dict(s)
        log.debug(block_dict)

        # Fetch ALL the submitted changelists as of right now.
        log.debug("p4 changes {}".format(p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client)))
        cl_ay = self.ctx.p4.run('changes',
                                '-l',
                                p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client))

        # Don't block until after something?
        after = block_dict['after']
        if after:
            if not contains_desc(after, cl_ay):
                log.debug("Do not block until after: {}".format(after))
                return

        until = block_dict['until']
        log.debug("BLOCKING. Seen        'after': {}".format(after))
        log.debug("BLOCKING. Waiting for 'until': {}".format(until))

        changes_path_at = ("{path}@{change},now"
                           .format(path=p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client),
                                   change=cl_ay[-1]['change']))

        while not contains_desc(until, cl_ay):
            time.sleep(1)
            cl_ay = self.ctx.p4.run('changes', changes_path_at)

        log.debug("Block released")
Exemple #5
0
    def check(self):
        """Query Perforce for recent changes, if any submitted changes
        are not ours, then a conflict has occurred and it is time to
        stop copying.

        Return None if no conflict, or first conflicting p4 changelist number.
        """

        # job058596: On play:1999, @now is NOT reporting the most recently
        # submitted changelist, causing 'p4 changes //client/....@change,now'
        # to not report the recent change, and find_Conflict_index() to
        # (correctly!) report a conflict because we claim there should be a
        # changelist in self.good but fail to see it in changes. Work around
        # this @now bug by using a date far in the future, but not so far that
        # Perforce rejects it as a bogus date. PS: Note to self: if we're
        # still using this code in the year 2030, try ',now' instead of
        # ',2030/12/31' and if that works, remove this hack.
        future = "2030/12/31"

        path = p4gf_path.slash_dot_dot_dot(self.ctx.config.p4client)
        path_at = None
        if self.last_good_change_number:
            path_at = ("{path}@{change},{future}"
                       .format(path=path,
                               change=self.last_good_change_number,
                               future=future))
        else:
            path_at = "{path}@0,{future}".format(path=path,
                                                 future=future)

        # -m5: don't fetch more than 5 changes. As long as we run
        # immediately before or after our git-to-perforce submit,
        # any conflict will be within the most recent 2 changes.
        cmd = ['changes', '-m5', '-ssubmitted', path_at]
        changelist_list = self.ctx.p4.run(cmd)
        LOG.debug('p4 changes -m5 -ssubmitted {} returned r={}'.format(path_at, changelist_list))

        self.first_conflict_index = self.find_conflict_index(changelist_list)

        if self.first_conflict_index == None:
            return None

        for i in range(0, len(self.good)):
            e = self.good[i]
            LOG.error("  {i}: g={g} p={p}"
                      .format(i=i, g=e.git_commit_sha1, p=e.p4_changelist_number))
        LOG.error("at index {}".format(self.first_conflict_index))

        return self.good[self.first_conflict_index].p4_changelist_number
def _p4_empty(ctx):
    """
    Is our client view completely empty, no files, not even deleted or purged?
    """
    r = ctx.p4.run('files', '-m1', p4gf_path.slash_dot_dot_dot(ctx.config.p4client))
    return not r