def putfile(self, filename, flags, data): if 'l' in flags: self.wopener.symlink(data, filename) else: try: if os.path.islink(self.wjoin(filename)): os.unlink(filename) except OSError: pass self.wopener.write(filename, data) if self.is_exec: was_exec = self.is_exec(self.wjoin(filename)) else: # On filesystems not supporting execute-bit, there is no way # to know if it is set but asking subversion. Setting it # systematically is just as expensive and much simpler. was_exec = 'x' not in flags util.setflags(self.wjoin(filename), False, 'x' in flags) if was_exec: if 'x' not in flags: self.delexec.append(filename) else: if 'x' in flags: self.setexec.append(filename)
def __init__(self, ui, path): converter_sink.__init__(self, ui, path) commandline.__init__(self, ui, 'svn') self.delete = [] self.setexec = [] self.delexec = [] self.copies = [] self.wc = None self.cwd = os.getcwd() path = os.path.realpath(path) created = False if os.path.isfile(os.path.join(path, '.svn', 'entries')): self.wc = path self.run0('update') else: wcpath = os.path.join(os.getcwd(), os.path.basename(path) + '-wc') if os.path.isdir(os.path.dirname(path)): if not os.path.exists(os.path.join(path, 'db', 'fs-type')): ui.status( _('initializing svn repository %r\n') % os.path.basename(path)) commandline(ui, 'svnadmin').run0('create', path) created = path path = util.normpath(path) if not path.startswith('/'): path = '/' + path path = 'file://' + path ui.status( _('initializing svn working copy %r\n') % os.path.basename(wcpath)) self.run0('checkout', path, wcpath) self.wc = wcpath self.opener = scmutil.opener(self.wc) self.wopener = scmutil.opener(self.wc) self.childmap = mapfile(ui, self.join('hg-childmap')) self.is_exec = util.checkexec(self.wc) and util.isexec or None if created: hook = os.path.join(created, 'hooks', 'pre-revprop-change') fp = open(hook, 'w') fp.write(pre_revprop_change) fp.close() util.setflags(hook, False, True) output = self.run0('info') self.uuid = self.uuid_re.search(output).group(1).strip()
def __init__(self, ui, path): checktool('svn', debname='subversion') checktool('svnadmin', debname='subversion') converter_sink.__init__(self, ui, path) commandline.__init__(self, ui, 'svn') self.delete = [] self.setexec = [] self.delexec = [] self.copies = [] self.wc = None self.cwd = os.getcwd() created = False if os.path.isfile(os.path.join(path, '.svn', 'entries')): self.wc = os.path.realpath(path) self.run0('update') else: if not re.search(r'^(file|http|https|svn|svn\+ssh)\://', path): path = os.path.realpath(path) if os.path.isdir(os.path.dirname(path)): if not os.path.exists(os.path.join(path, 'db', 'fs-type')): ui.status(_('initializing svn repository %r\n') % os.path.basename(path)) commandline(ui, 'svnadmin').run0('create', path) created = path path = util.normpath(path) if not path.startswith('/'): path = '/' + path path = 'file://' + path wcpath = os.path.join(os.getcwd(), os.path.basename(path) + '-wc') ui.status(_('initializing svn working copy %r\n') % os.path.basename(wcpath)) self.run0('checkout', path, wcpath) self.wc = wcpath self.opener = scmutil.opener(self.wc) self.wopener = scmutil.opener(self.wc) self.childmap = mapfile(ui, self.join('hg-childmap')) self.is_exec = util.checkexec(self.wc) and util.isexec or None if created: hook = os.path.join(created, 'hooks', 'pre-revprop-change') fp = open(hook, 'w') fp.write(pre_revprop_change) fp.close() util.setflags(hook, False, True) output = self.run0('info') self.uuid = self.uuid_re.search(output).group(1).strip()
def putfile(self, filename, flags, data): if 'l' in flags: self.wopener.symlink(data, filename) else: try: if os.path.islink(self.wjoin(filename)): os.unlink(filename) except OSError: pass self.wopener.write(filename, data) if self.is_exec: if self.is_exec(self.wjoin(filename)): if 'x' not in flags: self.delexec.append(filename) else: if 'x' in flags: self.setexec.append(filename) util.setflags(self.wjoin(filename), False, 'x' in flags)
def snapshot(ui, repo, files, node, tmproot): '''snapshot files as of some revision if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files.''' dirname = os.path.basename(repo.root) if dirname == "": dirname = "root" if node is not None: dirname = '%s.%s' % (dirname, short(node)) base = os.path.join(tmproot, dirname) os.mkdir(base) if node is not None: ui.note( _('making snapshot of %d files from rev %s\n') % (len(files), short(node))) else: ui.note( _('making snapshot of %d files from working directory\n') % (len(files))) wopener = scmutil.opener(base) fns_and_mtime = [] ctx = repo[node] for fn in sorted(files): wfn = util.pconvert(fn) if wfn not in ctx: # File doesn't exist; could be a bogus modify continue ui.note(' %s\n' % wfn) dest = os.path.join(base, wfn) fctx = ctx[wfn] data = repo.wwritedata(wfn, fctx.data()) if 'l' in fctx.flags(): wopener.symlink(data, wfn) else: wopener.write(wfn, data) if 'x' in fctx.flags(): util.setflags(dest, False, True) if node is None: fns_and_mtime.append( (dest, repo.wjoin(fn), os.lstat(dest).st_mtime)) return dirname, fns_and_mtime
def snapshot(repo, files, ctx): '''snapshot files as of some revision''' dirname = os.path.basename(repo.root) or 'root' dirname += '.%d' % _diffCount if ctx.rev() is not None: dirname += '.%d' % ctx.rev() base = os.path.join(qtlib.gettempdir(), dirname) fns_and_mtime = [] if not os.path.exists(base): os.makedirs(base) for fn in files: wfn = util.pconvert(fn) if not wfn in ctx: # File doesn't exist; could be a bogus modify continue dest = os.path.join(base, wfn) if os.path.exists(dest): # File has already been snapshot continue destdir = os.path.dirname(dest) try: if not os.path.isdir(destdir): os.makedirs(destdir) fctx = ctx[wfn] data = repo.wwritedata(wfn, fctx.data()) f = open(dest, 'wb') f.write(data) f.close() if 'x' in fctx.flags(): util.setflags(dest, False, True) if ctx.rev() is None: fns_and_mtime.append((dest, repo.wjoin(fn), os.lstat(dest).st_mtime)) else: # Make file read/only, to indicate it's static (archival) nature os.chmod(dest, stat.S_IREAD) except EnvironmentError: pass return base, fns_and_mtime
def snapshot(ui, repo, files, node, tmproot): '''snapshot files as of some revision if not using snapshot, -I/-X does not work and recursive diff in tools like kdiff3 and meld displays too many files.''' dirname = os.path.basename(repo.root) if dirname == "": dirname = "root" if node is not None: dirname = '%s.%s' % (dirname, short(node)) base = os.path.join(tmproot, dirname) os.mkdir(base) if node is not None: ui.note(_('making snapshot of %d files from rev %s\n') % (len(files), short(node))) else: ui.note(_('making snapshot of %d files from working directory\n') % (len(files))) wopener = scmutil.opener(base) fns_and_mtime = [] ctx = repo[node] for fn in sorted(files): wfn = util.pconvert(fn) if wfn not in ctx: # File doesn't exist; could be a bogus modify continue ui.note(' %s\n' % wfn) dest = os.path.join(base, wfn) fctx = ctx[wfn] data = repo.wwritedata(wfn, fctx.data()) if 'l' in fctx.flags(): wopener.symlink(data, wfn) else: wopener.write(wfn, data) if 'x' in fctx.flags(): util.setflags(dest, False, True) if node is None: fns_and_mtime.append((dest, repo.wjoin(fn), os.lstat(dest).st_mtime)) return dirname, fns_and_mtime