示例#1
0
 def readerr(self):
     while 1:
         size = util.fstat(self.pipee).st_size
         if size == 0: break
         l = self.pipee.readline()
         if not l: break
         self.ui.status(_("remote: "), l)
示例#2
0
 def readerr(self):
     while 1:
         size = util.fstat(self.pipee).st_size
         if size == 0: break
         l = self.pipee.readline()
         if not l: break
         self.ui.status(_("remote: "), l)
示例#3
0
    def write(self):
        if not self._dirty:
            return
        st = self._opener("dirstate", "w", atomictemp=True)

        try:
            gran = int(self._ui.config('dirstate', 'granularity', 1))
        except ValueError:
            gran = 1
        limit = sys.maxint
        if gran > 0:
            limit = util.fstat(st).st_mtime - gran

        cs = cStringIO.StringIO()
        copymap = self._copymap
        pack = struct.pack
        write = cs.write
        write("".join(self._pl))
        for f, e in self._map.iteritems():
            if f in copymap:
                f = "%s\0%s" % (f, copymap[f])
            if e[3] > limit and e[0] == 'n':
                e = (e[0], 0, -1, -1, 0)
            e = pack(_format, e[0], e[1], e[2], e[3], len(f))
            write(e)
            write(f)
        st.write(cs.getvalue())
        st.rename()
        self._dirty = self._dirtypl = False
示例#4
0
    def write(self):
        if not self._dirty:
            return
        st = self._opener("dirstate", "w", atomictemp=True)

        try:
            gran = int(self._ui.config('dirstate', 'granularity', 1))
        except ValueError:
            gran = 1
        limit = sys.maxint
        if gran > 0:
            limit = util.fstat(st).st_mtime - gran

        cs = cStringIO.StringIO()
        copymap = self._copymap
        pack = struct.pack
        write = cs.write
        write("".join(self._pl))
        for f, e in self._map.iteritems():
            if f in copymap:
                f = "%s\0%s" % (f, copymap[f])
            if e[3] > limit and e[0] == 'n':
                e = (e[0], 0, -1, -1)
            e = pack(_format, e[0], e[1], e[2], e[3], len(f))
            write(e)
            write(f)
        st.write(cs.getvalue())
        st.rename()
        self._dirty = self._dirtypl = False
示例#5
0
 def _writedirstate(self, st):
     # use the modification time of the newly created temporary file as the
     # filesystem's notion of 'now'
     now = util.statmtimesec(util.fstat(st)) & _rangemask
     st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
     st.close()
     self._lastnormaltime = 0
     self._dirty = self._dirtypl = False
示例#6
0
 def _writedirstate(self, st):
     # use the modification time of the newly created temporary file as the
     # filesystem's notion of 'now'
     now = util.statmtimesec(util.fstat(st)) & _rangemask
     st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl,
                                    now))
     st.close()
     self._lastnormaltime = 0
     self._dirty = self._dirtypl = False
示例#7
0
 def readerr(self):
     while True:
         size = util.fstat(self.pipee).st_size
         if size == 0:
             break
         s = self.pipee.read(size)
         if not s:
             break
         for l in s.splitlines():
             self.ui.status(_("remote: "), l, '\n')
示例#8
0
 def readerr(self):
     while 1:
         size = util.fstat(self.pipee).st_size
         if size == 0:
             break
         s = self.pipee.read(size)
         if not s:
             break
         for l in s.splitlines():
             self.ui.status(_("remote: "), l, '\n')
示例#9
0
 def write(self):
     if not self._dirty:
         return
     st = self._opener("dirstate", "w", atomictemp=True)
     # use the modification time of the newly created temporary file as the
     # filesystem's notion of 'now'
     now = util.fstat(st).st_mtime
     st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
     st.close()
     self._lastnormaltime = 0
     self._dirty = self._dirtypl = False
示例#10
0
 def __init__(self, dataf):
     try:
         size = util.fstat(dataf).st_size
     except AttributeError:
         size = 0
     self.dataf = dataf
     self.s = struct.calcsize(indexformatng)
     self.datasize = size
     self.l = size / self.s
     self.index = [None] * self.l
     self.map = {nullid: nullrev}
     self.allmap = 0
     self.all = 0
     self.mapfind_count = 0
示例#11
0
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        s = self.size
        cache = None
        index = []
        nodemap = {nullid: nullrev}
        n = off = 0
        # if we're not using lazymap, always read the whole index
        data = fp.read()
        l = len(data) - s
        append = index.append
        if inline:
            cache = (0, data)
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                if e[1] < 0:
                    break
                off += e[1] + s
        else:
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                off += s

        e = list(index[0])
        type = gettype(e[0])
        e[0] = offset_type(0, type)
        index[0] = e

        return index, nodemap, cache
示例#12
0
文件: revlog.py 项目: c0ns0le/cygwin
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        s = self.size
        cache = None
        index = []
        nodemap =  {nullid: nullrev}
        n = off = 0
        # if we're not using lazymap, always read the whole index
        data = fp.read()
        l = len(data) - s
        append = index.append
        if inline:
            cache = (0, data)
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                if e[1] < 0:
                    break
                off += e[1] + s
        else:
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                off += s

        e = list(index[0])
        type = gettype(e[0])
        e[0] = offset_type(0, type)
        index[0] = e

        return index, nodemap, cache
 def __init__(self, dataf):
     try:
         size = util.fstat(dataf).st_size
     except AttributeError:
         size = 0
     self.dataf = dataf
     self.s = struct.calcsize(indexformatng)
     self.datasize = size
     self.l = size // self.s
     self.index = [None] * self.l
     self.map = {nullid: nullrev}
     self.allmap = 0
     self.all = 0
     self.mapfind_count = 0
示例#14
0
    def write(self):
        if not self._dirty:
            return
        st = self._opener("dirstate", "w", atomictemp=True)

        def finish(s):
            st.write(s)
            st.close()
            self._lastnormaltime = 0
            self._dirty = self._dirtypl = False

        # use the modification time of the newly created temporary file as the
        # filesystem's notion of 'now'
        now = util.fstat(st).st_mtime
        finish(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
示例#15
0
文件: ui.py 项目: guitao/hg-stable
    def _trusted(self, fp, f):
        st = util.fstat(fp)
        if util.isowner(st):
            return True

        tusers, tgroups = self._trustusers, self._trustgroups
        if "*" in tusers or "*" in tgroups:
            return True

        user = util.username(st.st_uid)
        group = util.groupname(st.st_gid)
        if user in tusers or group in tgroups or user == util.username():
            return True

        if self._reportuntrusted:
            self.warn(_("not trusting file %s from untrusted " "user %s, group %s\n") % (f, user, group))
        return False
示例#16
0
    def _trusted(self, fp, f):
        st = util.fstat(fp)
        if util.isowner(st):
            return True

        tusers, tgroups = self._trustusers, self._trustgroups
        if '*' in tusers or '*' in tgroups:
            return True

        user = util.username(st.st_uid)
        group = util.groupname(st.st_gid)
        if user in tusers or group in tgroups or user == util.username():
            return True

        if self._reportuntrusted:
            self.warn(_('Not trusting file %s from untrusted '
                        'user %s, group %s\n') % (f, user, group))
        return False
示例#17
0
    def write(self):
        if not self._dirty:
            return

        # enough 'delaywrite' prevents 'pack_dirstate' from dropping
        # timestamp of each entries in dirstate, because of 'now > mtime'
        delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
        if delaywrite:
            import time # to avoid useless import
            time.sleep(delaywrite)

        st = self._opener("dirstate", "w", atomictemp=True)
        # use the modification time of the newly created temporary file as the
        # filesystem's notion of 'now'
        now = util.fstat(st).st_mtime
        st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
        st.close()
        self._lastnormaltime = 0
        self._dirty = self._dirtypl = False
示例#18
0
    def write(self):
        if not self._dirty:
            return

        # enough 'delaywrite' prevents 'pack_dirstate' from dropping
        # timestamp of each entries in dirstate, because of 'now > mtime'
        delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
        if delaywrite > 0:
            import time # to avoid useless import
            time.sleep(delaywrite)

        st = self._opener(self._filename, "w", atomictemp=True)
        # use the modification time of the newly created temporary file as the
        # filesystem's notion of 'now'
        now = util.fstat(st).st_mtime
        st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
        st.close()
        self._lastnormaltime = 0
        self._dirty = self._dirtypl = False
示例#19
0
 def _is_trusted(self, fp, f, warn=True):
     if not self.check_trusted:
         return True
     st = util.fstat(fp)
     if util.isowner(fp, st):
         return True
     tusers = self.trusted_users
     tgroups = self.trusted_groups
     if not tusers:
         user = util.username()
         if user is not None:
             self.trusted_users[user] = 1
             self.fixconfig(section="trusted")
     if (tusers or tgroups) and "*" not in tusers and "*" not in tgroups:
         user = util.username(st.st_uid)
         group = util.groupname(st.st_gid)
         if user not in tusers and group not in tgroups:
             if warn and self.report_untrusted:
                 self.warn(_("Not trusting file %s from untrusted " "user %s, group %s\n") % (f, user, group))
             return False
     return True
示例#20
0
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        data = fp.read()
        # call the C implementation to parse the index data
        index, nodemap, cache = parsers.parse_index(data, inline)
        return index, nodemap, cache
示例#21
0
 def _is_trusted(self, fp, f, warn=True):
     if not self.check_trusted:
         return True
     st = util.fstat(fp)
     if util.isowner(fp, st):
         return True
     tusers = self.trusted_users
     tgroups = self.trusted_groups
     if not tusers:
         user = util.username()
         if user is not None:
             self.trusted_users[user] = 1
             self.fixconfig(section='trusted')
     if (tusers or tgroups) and '*' not in tusers and '*' not in tgroups:
         user = util.username(st.st_uid)
         group = util.groupname(st.st_gid)
         if user not in tusers and group not in tgroups:
             if warn and self.report_untrusted:
                 self.warn(_('Not trusting file %s from untrusted '
                             'user %s, group %s\n') % (f, user, group))
             return False
     return True
示例#22
0
    def write(self):
        if not self._dirty:
            return
        st = self._opener("dirstate", "w", atomictemp=True)

        # use the modification time of the newly created temporary file as the
        # filesystem's notion of 'now'
        now = int(util.fstat(st).st_mtime)

        cs = cStringIO.StringIO()
        copymap = self._copymap
        pack = struct.pack
        write = cs.write
        write("".join(self._pl))
        for f, e in self._map.iteritems():
            if e[0] == 'n' and e[3] == now:
                # The file was last modified "simultaneously" with the current
                # write to dirstate (i.e. within the same second for file-
                # systems with a granularity of 1 sec). This commonly happens
                # for at least a couple of files on 'update'.
                # The user could change the file without changing its size
                # within the same second. Invalidate the file's stat data in
                # dirstate, forcing future 'status' calls to compare the
                # contents of the file. This prevents mistakenly treating such
                # files as clean.
                e = (e[0], 0, -1, -1)  # mark entry as 'unset'
                self._map[f] = e

            if f in copymap:
                f = "%s\0%s" % (f, copymap[f])
            e = pack(_format, e[0], e[1], e[2], e[3], len(f))
            write(e)
            write(f)
        st.write(cs.getvalue())
        st.close()
        self._lastnormaltime = None
        self._dirty = self._dirtypl = False
示例#23
0
    def write(self):
        if not self._dirty:
            return
        st = self._opener("dirstate", "w", atomictemp=True)

        # use the modification time of the newly created temporary file as the
        # filesystem's notion of 'now'
        now = int(util.fstat(st).st_mtime)

        cs = cStringIO.StringIO()
        copymap = self._copymap
        pack = struct.pack
        write = cs.write
        write("".join(self._pl))
        for f, e in self._map.iteritems():
            if e[0] == 'n' and e[3] == now:
                # The file was last modified "simultaneously" with the current
                # write to dirstate (i.e. within the same second for file-
                # systems with a granularity of 1 sec). This commonly happens
                # for at least a couple of files on 'update'.
                # The user could change the file without changing its size
                # within the same second. Invalidate the file's stat data in
                # dirstate, forcing future 'status' calls to compare the
                # contents of the file. This prevents mistakenly treating such
                # files as clean.
                e = (e[0], 0, -1, -1)   # mark entry as 'unset'
                self._map[f] = e

            if f in copymap:
                f = "%s\0%s" % (f, copymap[f])
            e = pack(_format, e[0], e[1], e[2], e[3], len(f))
            write(e)
            write(f)
        st.write(cs.getvalue())
        st.rename()
        self._lastnormaltime = None
        self._dirty = self._dirtypl = False
示例#24
0
 def __init__(self, fp, buf):
     self.data = buf
     self.fp = fp
     self.offset = fp.tell()
     self.size = util.fstat(fp).st_size
示例#25
0
 def fstat(self, fp):
     return util.fstat(fp)
示例#26
0
 def fstat(self, fp):
     return util.fstat(fp)
 def __init__(self, fp, buf):
     self.data = buf
     self.fp = fp
     self.offset = fp.tell()
     self.size = util.fstat(fp).st_size