Пример #1
0
    def outputStat(self, h):
        """save path of current file"""
        self.flush()
        self.rev = P4File.create_from_print(h)
        #self.change_set.add(self.rev.change)

                        # Not sure I want to bump this for every single file
                        # revision. That's frequent enough to slow down this
                        # print phase.
        #ProgressReporter.increment('MC Copying file revisions')

                        # This doubles our log output. Merge this with flush(),
                        # uncomment only when you need to debug PrintHandler itself.
                        #
                        # Spaces here to align depot path with flush() Printed.
        #_debug3( 'PrintHandler.outputStat() ch={:<5}'
        #         '                               {}#{}'
        #       , self.rev.change
        #       , self.rev.depot_path
        #       , self.rev.revision )

        if self.tempfile:
            self.tempfile.seek(0)
            self.tempfile.truncate()
        else:
            self.tempfile = tempfile.TemporaryFile(buffering=10000000, dir=self.tempdir,
                                                   prefix='p2g-print-')
        return OutputHandler.HANDLED
Пример #2
0
    def outputStat(self, h):
        """save path of current file"""
        self.flush()
        self.rev = P4File.create_from_print(h)
        #self.change_set.add(self.rev.change)

        # Not sure I want to bump this for every single file
        # revision. That's frequent enough to slow down this
        # print phase.
        #ProgressReporter.increment('MC Copying file revisions')

        # This doubles our log output. Merge this with flush(),
        # uncomment only when you need to debug PrintHandler itself.
        #
        # Spaces here to align depot path with flush() Printed.
        #_debug3( 'PrintHandler.outputStat() ch={:<5}'
        #         '                               {}#{}'
        #       , self.rev.change
        #       , self.rev.depot_path
        #       , self.rev.revision )

        if self.tempfile:
            self.tempfile.seek(0)
            self.tempfile.truncate()
        else:
            self.tempfile = tempfile.TemporaryFile(buffering=10000000,
                                                   dir=self.tempdir,
                                                   prefix='p2g-print-')
        return OutputHandler.HANDLED
def maybe_create_lfs_attrs(ctx, changelist, p4file_list, branch):
    """Create the initial .gitattributes file for an LFS-enabled repo.

    Does nothing if the git-lfs-initial-track configurable is not set.

    :param ctx: Git Fusion context.
    :param changelist: the P4Changelist.
    :param p4file_list: list of P4File.
    :param branch: the Branch to contain this file.

    :return: modified p4file_list

    """
    # Check if we have an initial-tracking setting or not.
    initial_tracking = generate_initial_lfs_attrs(ctx)
    if not initial_tracking:
        return p4file_list

    # Check if a .gitattributes file already exists or not.
    with ctx.switched_to_branch(branch):
        depot_path = ctx.gwt_to_depot_path(p4gf_const.GITATTRIBUTES)
        if not depot_path:
            return p4file_list
    for p4file in p4file_list:
        if p4file.depot_path == depot_path:
            # A .gitattributes already exists, nothing to do.
            return p4file_list

    # If a .gitattributes file ever existed in Perforce but was deleted by
    # the time we got to this changelist, honor that deletion. Do not insert.
    r = ctx.p4run('files', "{}@{}".format(depot_path, changelist.change))
    if p4gf_util.first_dict_with_key(r, "depotFile"):
        return p4file_list

    # "Print" the attributes file into the repository.
    sha1 = add_attributes_to_repo(initial_tracking, ctx.repo)
    if sha1 is None:
        return p4file_list

    # Save the SHA1 in the gitmirror list of pending blobs to cache.
    ctx.mirror.add_blob(sha1)

    # Construct a P4File and add to the list of files for this change.
    vardict = {
        'depotFile': depot_path,
        'action': 'add',
        'rev': 1,
        'type': 'text',
        'change': changelist.change
    }
    p4file = P4File.create_from_print(vardict)
    p4file.sha1 = sha1
    p4file_list.append(p4file)
    return p4file_list
 def outputStat(self, h):
     """save path of current file"""
     self.flush()
     self.rev = P4File.create_from_print(h)
     self.change_set.add(self.rev.change)
     ProgressReporter.increment(_('Copying files'))
     LOG.debug2("PrintHandler.outputStat() ch={} {}#{}".format(
         self.rev.change, self.rev.depot_path, self.rev.revision))
     # use the git working tree so we can use create_blob_fromfile()
     tmpdir = os.getcwd()
     self.tempfile = tempfile.NamedTemporaryFile(
         buffering=10000000, prefix='p2g-print-', dir=tmpdir, delete=False)
     return OutputHandler.HANDLED
 def outputStat(self, h):
     """save path of current file"""
     self.flush()
     self.rev = P4File.create_from_print(h)
     self.revs.append(self.rev)
     self.progress.progress_increment('Copying files')
     LOG.debug("PrintHandler.outputStat() ch={} {}"
               .format(h['change'], h["depotFile"] + "#" + h["rev"]))
     if self.tempfile:
         self.tempfile.seek(0)
         self.tempfile.truncate()
     else:
         self.tempfile = tempfile.TemporaryFile(buffering=10000000, dir=self.tempdir)
     return OutputHandler.HANDLED
Пример #6
0
 def outputStat(self, h):
     """save path of current file"""
     self.flush()
     self.rev = P4File.create_from_print(h)
     self.revs.append(self.rev)
     self.progress.progress_increment('Copying files')
     LOG.debug("PrintHandler.outputStat() ch={} {}".format(
         h['change'], h["depotFile"] + "#" + h["rev"]))
     if self.tempfile:
         self.tempfile.seek(0)
         self.tempfile.truncate()
     else:
         self.tempfile = tempfile.TemporaryFile(buffering=10000000,
                                                dir=self.tempdir)
     return OutputHandler.HANDLED
Пример #7
0
 def outputStat(self, h):
     """Save path of current file."""
     try:
         self.flush()
         self.rev = P4File.create_from_print(h)
         self.change_set.add(self.rev.change)
         ProgressReporter.increment(_('Copying files'))
         LOG.debug2("PrintHandler.outputStat() ch={} {}#{}".format(
             self.rev.change, self.rev.depot_path, self.rev.revision))
         # use the git working tree so we can use create_blob_fromfile()
         tmpdir = os.getcwd()
         self.temp_file = tempfile.NamedTemporaryFile(buffering=10000000,
                                                      prefix='p2g-print-',
                                                      dir=tmpdir,
                                                      delete=False)
         LOG.debug3('outputStat() temporary file created: {}'.format(
             self.temp_file.name))
     except Exception:  # pylint: disable=broad-except
         LOG.exception("outputStat")
     return OutputHandler.HANDLED