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)
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
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
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
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')
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')
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
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
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
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))
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
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
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
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
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
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
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
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
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
def __init__(self, fp, buf): self.data = buf self.fp = fp self.offset = fp.tell() self.size = util.fstat(fp).st_size
def fstat(self, fp): return util.fstat(fp)