📄 client.rb
字号:
require "English"require 'uri'require "svn/error"require "svn/util"require "svn/core"require "svn/wc"require "svn/ra"require "svn/ext/client"module Svn module Client Util.set_constants(Ext::Client, self) Util.set_methods(Ext::Client, self) class CommitItem class << self undef new end end class CommitItem2 class << self undef new end end class Info alias url URL alias repos_root_url repos_root_URL end PropListItem = ProplistItem # Following methods are also available: # # [name] # Returns an URI for the item concerned with the instance. # [props] # Returns a Hash of properties, such as # <tt>{propname1 => propval1, propname2 => propval2, ...}</tt>. class PropListItem alias name node_name alias props prop_hash def method_missing(meth, *args) _props = props if _props.respond_to?(meth) _props.__send__(meth, *args) else super end end end Context = Ctx class Context class << self undef new def new obj = Client.create_context obj.__send__("initialize") obj end end alias _auth_baton auth_baton attr_reader :auth_baton alias _initialize initialize def initialize @prompts = [] @batons = [] @providers = [] @auth_baton = Svn::Core::AuthBaton.new self.auth_baton = @auth_baton init_callbacks end undef _initialize def checkout(url, path, revision=nil, peg_rev=nil, recurse=true, ignore_externals=false) revision ||= "HEAD" Client.checkout2(url, path, peg_rev, revision, recurse, ignore_externals, self) end alias co checkout def mkdir(*paths) paths = paths.first if paths.size == 1 and paths.first.is_a?(Array) Client.mkdir2(normalize_path(paths), self) end def commit(targets, recurse=true, keep_locks=false) targets = [targets] unless targets.is_a?(Array) Client.commit3(targets, recurse, keep_locks, self) end alias ci commit def status(path, rev=nil, recurse=true, get_all=false, update=true, no_ignore=false, ignore_externals=false, &status_func) Client.status2(path, rev, status_func, recurse, get_all, update, no_ignore, ignore_externals, self) end alias st status def add(path, recurse=true, force=false, no_ignore=false) Client.add3(path, recurse, force, no_ignore, self) end def delete(paths, force=false) paths = [paths] unless paths.is_a?(Array) Client.delete2(paths, force, self) end alias del delete alias remove delete alias rm remove def rm_f(*paths) paths = paths.first if paths.size == 1 and paths.first.is_a?(Array) rm(paths, true) end def update(paths, rev="HEAD", recurse=true, ignore_externals=false) paths_is_array = paths.is_a?(Array) paths = [paths] unless paths_is_array result = Client.update2(paths, rev, recurse, ignore_externals, self) result = result.first unless paths_is_array result end alias up update def import(path, uri, recurse=true, no_ignore=false) Client.import2(path, uri, !recurse, no_ignore, self) end def cleanup(dir) Client.cleanup(dir, self) end def relocate(dir, from, to, recurse=true) Client.relocate(dir, from, to, recurse, self) end def revert(paths, recurse=true) paths = [paths] unless paths.is_a?(Array) Client.revert(paths, recurse, self) end def resolved(path, recurse=true) Client.resolved(path, recurse, self) end def propset(name, value, target, recurse=true, force=false) Client.propset2(name, value, target, recurse, force, self) end alias prop_set propset alias pset propset alias ps propset def propdel(name, target, recurse=true, force=false) Client.propset2(name, nil, target, recurse, force, self) end alias prop_del propdel alias pdel propdel alias pd propdel # Returns a value of a property, with +name+ attached to +target+, # as a Hash such as <tt>{uri1 => value1, uri2 => value2, ...}</tt>. def propget(name, target, rev=nil, peg_rev=nil, recurse=true) rev ||= "HEAD" peg_rev ||= rev Client.propget2(name, target, rev, peg_rev, recurse, self) end alias prop_get propget alias pget propget alias pg propget # Returns list of properties attached to +target+ as an Array of # Svn::Client::PropListItem. # Paths and URIs are available as +target+. def proplist(target, rev=nil, peg_rev=nil, recurse=true) rev ||= "HEAD" peg_rev ||= rev Client.proplist2(target, rev, peg_rev, recurse, self) end alias prop_list proplist alias plist proplist alias pl proplist def copy(src_path, dst_path, rev=nil) Client.copy3(src_path, rev || "HEAD", dst_path, self) end alias cp copy def move(src_path, dst_path, force=false) Client.move4(src_path, dst_path, force, self) end alias mv move def mv_f(src_path, dst_path) move(src_path, dst_path, true) end def diff(options, path1, rev1, path2, rev2, out_file, err_file, recurse=true, ignore_ancestry=false, no_diff_deleted=false, force=false, header_encoding=nil) header_encoding ||= Core::LOCALE_CHARSET Client.diff3(options, path1, rev1, path2, rev2, recurse, ignore_ancestry, no_diff_deleted, force, header_encoding, out_file, err_file, self) end def diff_peg(options, path, start_rev, end_rev, out_file, err_file, peg_rev=nil, recurse=true, ignore_ancestry=false, no_diff_deleted=false, force=false, header_encoding=nil) header_encoding ||= Core::LOCALE_CHARSET Client.diff_peg3(options, path, peg_rev, start_rev, end_rev, recurse, ignore_ancestry, no_diff_deleted, force, header_encoding, out_file, err_file, self) end # Invokes block once for each item changed between <tt>path1</tt> # at <tt>rev1</tt> and <tt>path2</tt> at <tt>rev2</tt>, # and returns +nil+. # +diff+ is an instance of Svn::Client::DiffSummarize. def diff_summarize(path1, rev1, path2, rev2, recurse=true, ignore_ancestry=true, &block) # :yields: diff Client.diff_summarize(path1, rev1, path2, rev2, recurse, ignore_ancestry, block, self) end def diff_summarize_peg(path1, rev1, rev2, peg_rev=nil, recurse=true, ignore_ancestry=true, &block) Client.diff_summarize_peg(path1, rev1, rev2, peg_rev, recurse, ignore_ancestry, block, self) end def merge(src1, rev1, src2, rev2, target_wcpath, recurse=true, ignore_ancestry=false, force=false, dry_run=false, options=nil) Client.merge2(src1, rev1, src2, rev2, target_wcpath, recurse, ignore_ancestry, force, dry_run, options, self) end def merge_peg(src, rev1, rev2, target_wcpath, peg_rev=nil, recurse=true, ignore_ancestry=false, force=false, dry_run=false, options=nil) Client.merge_peg2(src, rev1, rev2, peg_rev, target_wcpath, recurse, ignore_ancestry, force, dry_run, options, self) end # Returns a content of +path+ at +rev+ as a String. def cat(path, rev="HEAD", peg_rev=nil, output=nil) used_string_io = output.nil? output ||= StringIO.new Client.cat2(output, path, peg_rev, rev, self) if used_string_io output.rewind output.read else output end end def lock(targets, comment=nil, steal_lock=false) targets = [targets] unless targets.is_a?(Array) Client.lock(targets, comment, steal_lock, self) end def unlock(targets, break_lock=false) targets = [targets] unless targets.is_a?(Array) Client.unlock(targets, break_lock, self) end def info(path_or_uri, rev=nil, peg_rev=nil, recurse=false) rev ||= URI(path_or_uri).scheme ? "HEAD" : "BASE" peg_rev ||= rev receiver = Proc.new do |path, info| yield(path, info) end Client.info(path_or_uri, rev, peg_rev, receiver, recurse, self) end # Returns URL for +path+ as a String. def url_from_path(path) Client.url_from_path(path) end def uuid_from_path(path, adm) Client.uuid_from_path(path, adm, self) end # Returns UUID for +url+ as a String. def uuid_from_url(url) Client.uuid_from_url(url, self) end def open_ra_session(url) Client.open_ra_session(url, self) end # Scans revisions from +start_rev+ to +end_rev+ for each path in # +paths+, invokes block once for each revision, and then returns # +nil+. # # When +discover_changed_paths+ is +false+ or +nil+, +changed_paths+,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -