示例#1
0
 def getfilectx(repo, memctx, f):
     of = files[f]
     if 'deleted' in of:
         if check_version(3, 2):
             return None
         else:
             raise IOError
     if 'ctx' in of:
         if mode == 'hg':
             ctx = of['ctx']
             is_exec = ctx.isexec()
             is_link = ctx.islink()
             if check_version(3, 1):
                 return context.memfilectx(repo, f, ctx.data(),
                         is_link, is_exec)
             else:
                 return context.memfilectx(f, ctx.data(),
                         is_link, is_exec)
         else:
             return of['ctx']
     is_exec = of['mode'] == 'x'
     is_link = of['mode'] == 'l'
     rename = of.get('rename', None)
     if check_version(3, 1):
         return context.memfilectx(repo, f, of['data'],
                 is_link, is_exec, rename)
     else:
         return context.memfilectx(f, of['data'],
                 is_link, is_exec, rename)
示例#2
0
文件: hg.py 项目: lukaszb/vcs
        def filectxfn(_repo, memctx, path):
            """
            Marks given path as added/changed/removed in a given _repo. This is
            for internal mercurial commit function.
            """

            # check if this path is removed
            if path in (node.path for node in self.removed):
                # Raising exception is a way to mark node for removal
                raise IOError(errno.ENOENT, "%s is deleted" % path)

            # check if this path is added
            for node in self.added:
                if node.path == path:
                    return memfilectx(
                        path=node.path,
                        data=node.content.encode("utf8"),
                        islink=False,
                        isexec=node.is_executable,
                        copied=False,
                    )

            # or changed
            for node in self.changed:
                if node.path == path:
                    return memfilectx(
                        path=node.path,
                        data=node.content.encode("utf8"),
                        islink=False,
                        isexec=node.is_executable,
                        copied=False,
                    )

            raise RepositoryError("Given path haven't been marked as added," "changed or removed (%s)" % path)
示例#3
0
    def getfilectx(repo, memctx, f):
        if bfutil.is_standin(f):
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            srcfname = bfutil.split_standin(f)
            try:
                fctx = ctx.filectx(srcfname)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                # standin is always a bfile because bfileness
                # doesn't change after rename or copy
                renamed = bfutil.standin(renamed[0])

            return context.memfilectx(f, bfiletohash[srcfname], 'l' in fctx.flags(),
                                      'x' in fctx.flags(), renamed)
        else:
            try:
                fctx = ctx.filectx(f)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                renamed = renamed[0]

            data = fctx.data()
            if f == '.hgtags':
                newdata = []
                for line in data.splitlines():
                    id, name = line.split(' ', 1)
                    newdata.append('%s %s\n' % (node.hex(revmap[node.bin(id)]), name))
                data = ''.join(newdata)
            return context.memfilectx(f, data, 'l' in fctx.flags(),
                                      'x' in fctx.flags(), renamed)
def makememfilectx(repo, path, data, islink, isexec, copied):
    """Return a memfilectx

    Works around memfilectx() adding a repo argument between 3.0 and 3.1.
    """
    from mercurial import context
    try:
        return context.memfilectx(repo, path, data, islink, isexec, copied)
    except TypeError:
        return context.memfilectx(path, data, islink, isexec, copied)
示例#5
0
 def getfilectx(repo, memctx, f):
     try:
         fctx = tip.filectx(f)
         data = fctx.data()
     except error.ManifestLookupError:
         data = ""
     content = data + "%s %s\n" % (node, tag)
     if check_version(3, 1):
         return context.memfilectx(repo, f, content, False, False, None)
     else:
         return context.memfilectx(f, content, False, False, None)
 def file_callback(repo, memctx, path):
     if path == 'adding_file':
         return context.memfilectx(path=path,
                                   data='foo',
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     elif path == 'adding_binary':
         return context.memfilectx(path=path,
                                   data='\0binary',
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
示例#7
0
    def getfilectx(repo, memctx, f):
        if lfutil.standin(f) in files:
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            try:
                fctx = ctx.filectx(lfutil.standin(f))
            except error.LookupError:
                return None
            renamed = fctx.renamed()
            if renamed:
                renamed = lfutil.splitstandin(renamed[0])

            hash = fctx.data().strip()
            path = lfutil.findfile(rsrc, hash)

            # If one file is missing, likely all files from this rev are
            if path is None:
                cachelfiles(ui, rsrc, ctx.node())
                path = lfutil.findfile(rsrc, hash)

                if path is None:
                    raise util.Abort(_("missing largefile '%s' from revision %s") % (f, node.hex(ctx.node())))

            data = ""
            fd = None
            try:
                fd = open(path, "rb")
                data = fd.read()
            finally:
                if fd:
                    fd.close()
            return context.memfilectx(repo, f, data, "l" in fctx.flags(), "x" in fctx.flags(), renamed)
        else:
            return _getnormalcontext(repo, ctx, f, revmap)
示例#8
0
        def getfilectx(repo, memctx, f):
            info = files.get(f)
            if info != None:
                # it's a file reported as modified from Git
                delete, mode, sha = info
                if delete:
                    raise IOError

                if not sha: # indicates there's no git counterpart
                    e = ''
                    copied_path = None
                    if '.hgsubstate' == f:
                        data = util.serialize_hgsubstate(hgsubstate)
                    elif '.hgsub' == f:
                        data = util.serialize_hgsub(hgsub)
                else:
                    data = self.git[sha].data
                    copied_path = hg_renames.get(f)
                    e = self.convert_git_int_mode(mode)
            else:
                # it's a converged file
                fc = context.filectx(self.repo, f, changeid=memctx.p1().rev())
                data = fc.data()
                e = fc.flags()
                copied_path = fc.renamed()

            return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
示例#9
0
    def filectxfn(repo, memctx, path):
        if path in files_data and files_data[path] is None:
            raise IOError(errno.ENOENT, '%s is deleted' % path)

        if path in binary_files or path in unknown_files:
            pa = path
            if branchpath:
                pa = branchpath + '/' + path
            data, mode = svn.get_file(pa, r.revnum)
            isexe = 'x' in mode
            islink = 'l' in mode
        else:
            isexe = exec_files.get(path, 'x' in parentctx.flags(path))
            islink = link_files.get(path, 'l' in parentctx.flags(path))
            data = ''
            if path in files_data:
                data = files_data[path]
                if islink:
                    data = data[len('link '):]
            elif path in parentctx:
                data = parentctx[path].data()

        copied = copies.get(path)
        # TODO this branch feels like it should not be required,
        # and this may actually imply a bug in getcopies
        if copied not in parentctx.manifest():
            copied = None
        return context.memfilectx(path=path, data=data, islink=islink,
                                  isexec=isexe, copied=copied)
示例#10
0
    def getfilectx(repo, memctx, f):
        if lfutil.standin(f) in files:
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            try:
                fctx = ctx.filectx(lfutil.standin(f))
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                renamed = lfutil.splitstandin(renamed[0])

            hash = fctx.data().strip()
            path = lfutil.findfile(rsrc, hash)
            ### TODO: What if the file is not cached?
            data = ""
            fd = None
            try:
                fd = open(path, "rb")
                data = fd.read()
            finally:
                if fd:
                    fd.close()
            return context.memfilectx(f, data, "l" in fctx.flags(), "x" in fctx.flags(), renamed)
        else:
            return _getnormalcontext(repo.ui, ctx, f, revmap)
示例#11
0
 def hgtagsfn(repo, memctx, path):
     assert path == '.hgtags'
     return context.memfilectx(path=path,
                               data=tagdata,
                               islink=False,
                               isexec=False,
                               copied=False)
示例#12
0
文件: hg.py 项目: MezzLabs/mercurial
 def getfilectx(repo, memctx, f):
     v = files[f]
     data, mode = source.getfile(f, v)
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     return context.memfilectx(f, data, 'l' in mode, 'x' in mode,
                               copies.get(f))
示例#13
0
    def filectxfn(repo, memctx, path):
        try:
            fctx = oldctx.filectx(path)

            # This wonky pattern is copied from memctx.__init__.
            copied = fctx.renamed()
            if copied:
                copied = copied[0]

            # isexec and islink didn't exist until Mercurial 3.2.
            islink = 'l' in fctx.flags()
            isexec = 'x' in fctx.flags()

            # TRACKING hg45 memctx argument was renamed to changectx and
            # converted from a named argument to positional argument in 4.5.
            spec = inspect.getargspec(context.memfilectx.__init__)

            if 'changectx' in spec.args:
                # TRACKING hg50
                # `copied` renamed to `copysource`
                if util.versiontuple(n=2) >= (5, 0):
                    return context.memfilectx(repo,
                                              memctx,
                                              path,
                                              fctx.data(),
                                              islink=islink,
                                              isexec=isexec,
                                              copysource=copied)
                else:
                    return context.memfilectx(repo,
                                              memctx,
                                              path,
                                              fctx.data(),
                                              islink=islink,
                                              isexec=isexec,
                                              copied=copied)
            else:
                return context.memfilectx(repo,
                                          path,
                                          fctx.data(),
                                          islink=islink,
                                          isexec=isexec,
                                          copied=copied,
                                          memctx=memctx)
        except KeyError:
            return None
示例#14
0
 def getfilectx(repo, memctx, f):
     try:
         fctx = tip.filectx(f)
         data = fctx.data()
     except error.ManifestLookupError:
         data = ""
     content = data + "%s %s\n" % (node, tag)
     return context.memfilectx(f, content, False, False, None)
示例#15
0
 def file_callback(repo, memctx, path):
     if path == 'gamma':
         return context.memfilectx(path=path,
                                   data='foo',
                                   islink=True,
                                   isexec=False,
                                   copied=False)
     raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
示例#16
0
 def file_callback(repo, memctx, path):
     if path == 'adding_file':
         return context.memfilectx(path=path,
                                   data='foo',
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     raise IOError()
 def cb(repo, memctx, path):
     if path == data:
         return context.memfilectx(path=path,
                                   data=data,
                                   islink=False,
                                   isexec=False,
                                   copied=False)
     raise IOError(errno.EINVAL, 'Invalid operation: ' + path)
示例#18
0
文件: hgimport.py 项目: Grahack/git
 def getfilectx(repo, memctx, name):
     fileid = files[name]
     if fileid is None:  # deleted file
         raise IOError
     data = self.getblob(fileid)
     ctx = context.memfilectx(name, data, 'l' in modes,
                              'x' in modes, copies.get(name))
     return ctx
示例#19
0
 def getfilectx(repo, memctx, f):
     v = files[f]
     data = source.getfile(f, v)
     e = source.getmode(f, v)
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     return context.memfilectx(f, data, 'l' in e, 'x' in e,
                               copies.get(f))
示例#20
0
 def file_callback(repo, memctx, path):
     return context.memfilectx(
         path=path,
         data=items[path],
         islink=False,
         isexec=False,
         copied=False,
         )
示例#21
0
 def filectxfn(repo, ctx, path):
     if path in headmf:
         fctx = last[path]
         flags = fctx.flags()
         mctx = context.memfilectx(
             fctx.path(), fctx.data(), islink="l" in flags, isexec="x" in flags, copied=copied.get(path)
         )
         return mctx
     raise IOError()
示例#22
0
文件: stupid.py 项目: avuori/dotfiles
 def filectxfn(repo, memctx, path):
     if path in externals:
         if externals[path] is None:
             raise IOError(errno.ENOENT, "no externals")
         return context.memfilectx(path=path, data=externals[path], islink=False, isexec=False, copied=None)
     for bad in bad_branch_paths[b]:
         if path.startswith(bad):
             raise IOError(errno.ENOENT, "Path %s is bad" % path)
     return filectxfn2(repo, memctx, path)
 def filectxfn(repo, memctx, path, contentctx=ctx, redirect=()):
     if path not in contentctx:
         return None
     fctx = contentctx[path]
     mctx = context.memfilectx(repo, memctx, fctx.path(), fctx.data(),
                               fctx.islink(),
                               fctx.isexec(),
                               copied=copied.get(path))
     return mctx
示例#24
0
 def getfilectx(repo, memctx, f):
     of = files[f]
     if 'deleted' in of:
         raise IOError
     if 'ctx' in of:
         return of['ctx']
     is_exec = of['mode'] == 'x'
     is_link = of['mode'] == 'l'
     rename = of.get('rename', None)
     return context.memfilectx(f, of['data'], is_link, is_exec, rename)
示例#25
0
    def getfilectx(repo, memctx, f):
        if lfutil.standin(f) in files:
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            try:
                fctx = ctx.filectx(lfutil.standin(f))
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                renamed = lfutil.splitstandin(renamed[0])

            hash = fctx.data().strip()
            path = lfutil.findfile(rsrc, hash)
            ### TODO: What if the file is not cached?
            data = ''
            fd = None
            try:
                fd = open(path, 'rb')
                data = fd.read()
            finally:
                if fd:
                    fd.close()
            return context.memfilectx(f, data, 'l' in fctx.flags(),
                                      'x' in fctx.flags(), renamed)
        else:
            try:
                fctx = ctx.filectx(f)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                renamed = renamed[0]
            data = fctx.data()
            if f == '.hgtags':
                newdata = []
                for line in data.splitlines():
                    id, name = line.split(' ', 1)
                    newdata.append('%s %s\n' % (node.hex(revmap[node.bin(id)]),
                        name))
                data = ''.join(newdata)
            return context.memfilectx(f, data, 'l' in fctx.flags(),
                                      'x' in fctx.flags(), renamed)
示例#26
0
 def filectxfn(repo, memctx, path):
     if path == '.hgsvnexternals':
         if not externals:
             raise IOError(errno.ENOENT, 'no externals')
         return context.memfilectx(path=path, data=externals.write(),
                                   islink=False, isexec=False, copied=None)
     for bad in bad_branch_paths[b]:
         if path.startswith(bad):
             raise IOError(errno.ENOENT, 'Path %s is bad' % path)
     return filectxfn2(repo, memctx, path)
示例#27
0
 def filectxfn(repo, ctx, path):
     if path in headmf:
         fctx = head[path]
         flags = fctx.flags()
         mctx = context.memfilectx(repo, ctx, fctx.path(), fctx.data(),
                                   islink='l' in flags,
                                   isexec='x' in flags,
                                   copied=copied.get(path))
         return mctx
     return None
示例#28
0
        def getfilectx(repo, memctx, f):
            delete, mode, sha = files[f]
            if delete:
                raise IOError

            data = self.git[sha].data
            copied_path = hg_renames.get(f)
            e = self.convert_git_int_mode(mode)

            return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
示例#29
0
 def get_filectx(repo, memctx, file):
     filespec = files[file]
     if 'deleted' in filespec:
         raise IOError
     if 'ctx' in filespec:
         return filespec['ctx']
     is_exec = filespec['mode'] == 'x'
     is_link = filespec['mode'] == 'l'
     rename = filespec.get('rename', None)
     return memfilectx(file, filespec['data'], is_link, is_exec, rename)
示例#30
0
        def getfilectx(repo, memctx, f):
            delete, mode, sha = files[f]
            if delete:
                raise IOError

            data = self.git[sha].data
            copied_path = hg_renames.get(f)
            e = self.convert_git_int_mode(mode)

            return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
示例#31
0
 def filectxfn(repo, memctx, path):
     if path in removed:
         raise IOError(errno.ENOENT, 'File "%s" no longer exists' % path)
     entry = [e for e in changes if path == e[1]][0]
     source, dest, newdata = entry
     if newdata is None:
         newdata = parentctx[source].data()
     copied = None
     if source != dest:
         copied = source
     return context.memfilectx(path=dest, data=newdata, islink=False, isexec=False, copied=copied)
示例#32
0
 def get_filectx(repo, memctx, file):
     filespec = files[file]
     if 'deleted' in filespec:
         raise IOError
     if 'ctx' in filespec:
         return filespec['ctx']
     is_exec = filespec['mode'] == 'x'
     is_link = filespec['mode'] == 'l'
     rename = filespec.get('rename', None)
     return memfilectx(file, filespec['data'],
             is_link, is_exec, rename)
示例#33
0
 def filectxfn(repo, ctx, path):
     if path in headmf:
         fctx = last[path]
         flags = fctx.flags()
         mctx = context.memfilectx(repo,
                                   fctx.path(), fctx.data(),
                                   islink='l' in flags,
                                   isexec='x' in flags,
                                   copied=copied.get(path))
         return mctx
     return None
示例#34
0
 def _filectxfn(repo, memctx, path):
     if path in mf:
         fctx = ctx[path]
         flags = fctx.flags()
         return context.memfilectx(
             fctx.path(),
             fctx.data(),
             islink='l' in flags,
             isexec='x' in flags,
             copied=copied.get(path))
     raise IOError
示例#35
0
 def getfilectx(repo, memctx, f):
     of = files[f]
     if 'deleted' in of:
         raise IOError
     if 'ctx' in of:
         return of['ctx']
     is_exec = of['mode'] == 'x'
     is_link = of['mode'] == 'l'
     rename = of.get('rename', None)
     return context.memfilectx(f, of['data'],
             is_link, is_exec, rename)
示例#36
0
 def getfilectx(repo, memctx, f):
     try:
         (mode, sha, data) = self.git.get_file(commit, f)
         e = self.convert_git_int_mode(mode)
     except TypeError:
         raise IOError()
     if f in hg_renames:
         copied_path = hg_renames[f]
     else:
         copied_path = None
     return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
示例#37
0
def _getnormalcontext(repo, ctx, f, revmap):
    try:
        fctx = ctx.filectx(f)
    except error.LookupError:
        return None
    renamed = fctx.copysource()

    data = fctx.data()
    if f == b'.hgtags':
        data = _converttags(repo.ui, revmap, data)
    return context.memfilectx(repo, ctx, f, data, b'l' in fctx.flags(), b'x'
                              in fctx.flags(), renamed)
示例#38
0
 def getfilectx(repo, memctx, f):
     try:
         v = files[f]
     except KeyError:
         return None
     data, mode = source.getfile(f, v)
     if data is None:
         return None
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     return context.memfilectx(self.repo, f, data, 'l' in mode,
                               'x' in mode, copies.get(f))
示例#39
0
 def filectxfn(repo, memctx, path):
     if path not in ctx:
         return None
     fctx = ctx[path]
     copysource = fctx.copysource()
     return context.memfilectx(repo,
                               memctx,
                               path=fctx.path(),
                               data=filedata.get(path, fctx.data()),
                               islink=fctx.islink(),
                               isexec=fctx.isexec(),
                               copysource=copysource)
示例#40
0
文件: hg.py 项目: zeroincombenze/VME
 def getfilectx(repo, memctx, f):
     try:
         v = files[f]
     except KeyError:
         return None
     data, mode = source.getfile(f, v)
     if data is None:
         return None
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     return context.memfilectx(self.repo, f, data, 'l' in mode,
                               'x' in mode, copies.get(f))
示例#41
0
def makememfilectx(repo, memctx, path, data, islink, isexec, copied):
    """Return a memfilectx

    Works around API change by 8a0cac20a1ad (first in 4.5).
    """
    from mercurial import context
    try:
        return context.memfilectx(repo=repo,
                                  path=path,
                                  data=data,
                                  islink=islink,
                                  isexec=isexec,
                                  copied=copied,
                                  changectx=memctx)
    except TypeError:
        return context.memfilectx(repo=repo,
                                  path=path,
                                  data=data,
                                  islink=islink,
                                  isexec=isexec,
                                  copied=copied)
示例#42
0
    def filectxfn(repo, memctx, path):
        try:
            fctx = oldctx.filectx(path)

            # This wonky pattern is copied from memctx.__init__.
            copied = fctx.renamed()
            if copied:
                copied = copied[0]

            # isexec and islink didn't exist until Mercurial 3.2.
            islink = "l" in fctx.flags()
            isexec = "x" in fctx.flags()

            # TRACKING hg45 memctx argument was renamed to changectx and
            # converted from a named argument to positional argument in 4.5.
            spec = inspect.getargspec(context.memfilectx.__init__)

            if "changectx" in spec.args:
                return context.memfilectx(
                    repo,
                    memctx,
                    path,
                    fctx.data(),
                    islink=islink,
                    isexec=isexec,
                    copied=copied,
                )
            else:
                return context.memfilectx(
                    repo,
                    path,
                    fctx.data(),
                    islink=islink,
                    isexec=isexec,
                    copied=copied,
                    memctx=memctx,
                )
        except KeyError:
            return None
示例#43
0
 def getfilectx(repo, memctx, path):
     if path in m:
         fctx = rev[path]
         flags = fctx.flags()
         copied = fctx.renamed()
         if copied:
             copied = copied[0]
         return context.memfilectx(repo, fctx.path(), fctx.data(),
                           islink='l' in flags,
                           isexec='x' in flags,
                           copied=copied)
     else:
         return None
示例#44
0
 def getfilectx(repo, memctx, f):
     fpath = os.path.join(repo.root, f)
     data = None
     try:
         with open(fpath) as fp:
             data = fp.read()
         return context.memfilectx(repo, f, data,
                                   bool(os.path.islink(fpath)),
                                   bool(os.access(fpath, os.X_OK)),
                                   renames.get(f))
     except IOError:
         pass
     return None
示例#45
0
        def filectxfn(repository, ctx, fname):
            fctx = active.localtip.filectx(fname)
            data = fctx.data()

            #
            # .hgtags is a special case, tags referring to active list
            # component changesets should be elided.
            #
            if fname == '.hgtags':
                data = '\n'.join(active.prune_tags(data.splitlines()))

            return context.memfilectx(fname, data, 'l' in fctx.flags(), 'x'
                                      in fctx.flags(),
                                      active[fname].parentname)
def _getnormalcontext(repo, ctx, f, revmap):
    try:
        fctx = ctx.filectx(f)
    except error.LookupError:
        return None
    renamed = fctx.renamed()
    if renamed:
        renamed = renamed[0]

    data = fctx.data()
    if f == '.hgtags':
        data = _converttags (repo.ui, revmap, data)
    return context.memfilectx(repo, ctx, f, data, 'l' in fctx.flags(),
                              'x' in fctx.flags(), renamed)
示例#47
0
文件: fix.py 项目: pombredanne/hg
 def filectxfn(repo, memctx, path):
     if path not in ctx:
         return None
     fctx = ctx[path]
     copied = fctx.renamed()
     if copied:
         copied = copied[0]
     return context.memfilectx(repo,
                               memctx,
                               path=fctx.path(),
                               data=filedata.get(path, fctx.data()),
                               islink=fctx.islink(),
                               isexec=fctx.isexec(),
                               copied=copied)
    def filectxfn(repo, memctx, path):
        sourcepath = path[len(prefix):]
        if sourcepath not in sourceman:
            return None

        node, flags = sourceman.find(sourcepath)
        sourcefl = sourcerepo.file(sourcepath)
        data = sourcefl.read(node)

        islink = 'l' in flags
        isexec = 'x' in flags

        copied = None
        renamed = sourcefl.renamed(node)
        if renamed:
            copied = '%s%s' % (prefix, renamed[0])

        # TRACKING hg45 Mercurial 4.5 renamed memctx to changectx and made
        # the argument positional instead of named.
        spec = inspect.getargspec(context.memfilectx.__init__)

        if 'changectx' in spec.args:
            return context.memfilectx(repo,
                                      memctx,
                                      path,
                                      data,
                                      islink=islink,
                                      isexec=isexec,
                                      copied=copied)
        else:
            return context.memfilectx(repo,
                                      path,
                                      data,
                                      islink=islink,
                                      isexec=isexec,
                                      copied=copied,
                                      memctx=memctx)
示例#49
0
    def getfilectx(repo, memctx, f):
        if bfutil.is_standin(f):
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            srcfname = bfutil.split_standin(f)
            try:
                fctx = ctx.filectx(srcfname)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                # standin is always a bfile because bfileness
                # doesn't change after rename or copy
                renamed = bfutil.standin(renamed[0])

            return context.memfilectx(f, bfiletohash[srcfname], 'l'
                                      in fctx.flags(), 'x' in fctx.flags(),
                                      renamed)
        else:
            try:
                fctx = ctx.filectx(f)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                renamed = renamed[0]

            data = fctx.data()
            if f == '.hgtags':
                newdata = []
                for line in data.splitlines():
                    id, name = line.split(' ', 1)
                    newdata.append('%s %s\n' %
                                   (node.hex(revmap[node.bin(id)]), name))
                data = ''.join(newdata)
            return context.memfilectx(f, data, 'l' in fctx.flags(), 'x'
                                      in fctx.flags(), renamed)
示例#50
0
 def getfilectx(repo, memctx, f):
     if p2ctx and f in cleanp2 and f not in copies:
         self.ui.debug('reusing %s from p2\n' % f)
         return p2ctx[f]
     try:
         v = files[f]
     except KeyError:
         return None
     data, mode = source.getfile(f, v)
     if data is None:
         return None
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     return context.memfilectx(self.repo, f, data, 'l' in mode,
                               'x' in mode, copies.get(f))
示例#51
0
    def filectxfn(repo, memctx, path):
        try:
            fctx = oldctx.filectx(path)

            # This wonky pattern is copied from memctx.__init__.
            copied = fctx.renamed()
            if copied:
                copied = copied[0]

            # isexec and islink didn't exist until Mercurial 3.2.
            islink = 'l' in fctx.flags()
            isexec = 'x' in fctx.flags()
            return context.memfilectx(repo, path, fctx.data(),
                                      islink=islink,
                                      isexec=isexec,
                                      copied=copied,
                                      memctx=memctx)
        except KeyError:
            return None
    def getfilectx(repo, memctx, f):
        if lfutil.isstandin(f):
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            srcfname = lfutil.splitstandin(f)
            try:
                fctx = ctx.filectx(srcfname)
            except error.LookupError:
                raise IOError()
            renamed = fctx.renamed()
            if renamed:
                # standin is always a largefile because largefile-ness
                # doesn't change after rename or copy
                renamed = lfutil.standin(renamed[0])

            return context.memfilectx(f, lfiletohash[srcfname] + '\n', 'l' in
                fctx.flags(), 'x' in fctx.flags(), renamed)
        else:
            return _getnormalcontext(repo.ui, ctx, f, revmap)
示例#53
0
    def commit(self, user, message, rev, filedata):
        """Commit a change.

        Copied from mecurial.commands
        """
        from mercurial.context import memctx, memfilectx

        ctx = memctx(
            repo=self.repo,
            parents=(rev, None),
            text=message,
            files=filedata.keys(),
            filectxfn=lambda repo, memctx, path: memfilectx(
                path, filedata[path], False, False, None),
            user=user,
        )

        node = self.repo.commitctx(ctx)
        return str(self.repo[node])
示例#54
0
        def getfilectx(repo, memctx, f):
            info = files.get(f)
            if info != None:
                # it's a file reported as modified from Git
                delete, mode, sha = info
                if delete:
                    raise IOError

                data = self.git[sha].data
                copied_path = hg_renames.get(f)
                e = self.convert_git_int_mode(mode)
            else:
                # it's a converged file
                fc = context.filectx(self.repo, f, changeid=memctx.p1().rev())
                data = fc.data()
                e = fc.flags()
                copied_path = fc.renamed()

            return context.memfilectx(f, data, 'l' in e, 'x' in e, copied_path)
示例#55
0
    def filectxfn(repo, memctx, path):
        sourcepath = path[len(prefix):]
        if sourcepath not in sourceman:
            return None

        node, flags = sourceman.find(sourcepath)
        sourcefl = sourcerepo.file(sourcepath)
        data = sourcefl.read(node)

        copied = None
        renamed = sourcefl.renamed(node)
        if renamed:
            copied = '%s%s' % (prefix, renamed[0])

        return context.memfilectx(repo,
                                  path,
                                  data,
                                  islink='l' in flags,
                                  isexec='x' in flags,
                                  copied=copied,
                                  memctx=memctx)
示例#56
0
 def filectxfn(repo, memctx, path):
     current_file = files[path]
     if current_file in current.deleted:
         raise IOError(errno.ENOENT, '%s is deleted' % path)
     copied = current.copies.get(current_file)
     flags = parentctx.flags(path)
     is_exec = current.execfiles.get(current_file, 'x' in flags)
     is_link = current.symlinks.get(current_file, 'l' in flags)
     if current_file in current.files:
         data = current.files[current_file]
         if is_link and data.startswith('link '):
             data = data[len('link '):]
         elif is_link:
             ui.debug('file marked as link, but may contain data: '
                      '%s (%r)\n' % (current_file, flags))
     else:
         data = parentctx.filectx(path).data()
     return context.memfilectx(path=path,
                               data=data,
                               islink=is_link,
                               isexec=is_exec,
                               copied=copied)
示例#57
0
 def getfilectx(repo, memctx, f):
     if p2ctx and f in p2files and f not in copies:
         self.ui.debug('reusing %s from p2\n' % f)
         try:
             return p2ctx[f]
         except error.ManifestLookupError:
             # If the file doesn't exist in p2, then we're syncing a
             # delete, so just return None.
             return None
     try:
         v = files[f]
     except KeyError:
         return None
     data, mode = source.getfile(f, v)
     if data is None:
         return None
     if f == '.hgtags':
         data = self._rewritetags(source, revmap, data)
     if f == '.hgsubstate':
         data = self._rewritesubstate(source, data)
     return context.memfilectx(self.repo, f, data, 'l' in mode,
                               'x' in mode, copies.get(f))
示例#58
0
    def getfilectx(repo, memctx, f):
        if lfutil.standin(f) in files:
            # if the file isn't in the manifest then it was removed
            # or renamed, raise IOError to indicate this
            try:
                fctx = ctx.filectx(lfutil.standin(f))
            except error.LookupError:
                raise IOError
            renamed = fctx.renamed()
            if renamed:
                renamed = lfutil.splitstandin(renamed[0])

            hash = fctx.data().strip()
            path = lfutil.findfile(rsrc, hash)

            # If one file is missing, likely all files from this rev are
            if path is None:
                cachelfiles(ui, rsrc, ctx.node())
                path = lfutil.findfile(rsrc, hash)

                if path is None:
                    raise util.Abort(
                        _("missing largefile \'%s\' from revision %s") %
                        (f, node.hex(ctx.node())))

            data = ''
            fd = None
            try:
                fd = open(path, 'rb')
                data = fd.read()
            finally:
                if fd:
                    fd.close()
            return context.memfilectx(repo, f, data, 'l' in fctx.flags(), 'x'
                                      in fctx.flags(), renamed)
        else:
            return _getnormalcontext(repo, ctx, f, revmap)