class SvnWCCommandPath(FSPathBase):
path implementation offering access/modification to svn working copies.
It has methods similar to the functions in os.path and similar to the
commands of the svn client.
class attributes and properties:
basename: <property object (dynamically calculated value)>
ext: <property object (dynamically calculated value)>
purebasename: <property object (dynamically calculated value)>
sep: /
strpath: <property object (dynamically calculated value)>
url: <property object (dynamically calculated value)>
methods:
def add(self):
add ourself to svn
arguments:
return value:
<None>
def blame(self):
return a list of tuples of three elements:
(revision, commiter, line)
arguments:
return value:
<List>
source: path/svn/wccommand.py
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 | |
def blame(self): |
""" return a list of tuples of three elements: |
(revision, commiter, line)""" |
out = self._svn('blame') |
result = [] |
blamelines = out.splitlines() |
reallines = py.path.svnurl(self.url).readlines() |
for i, (blameline, line) in py.builtin.enumerate( |
zip(blamelines, reallines)): |
m = rex_blame.match(blameline) |
if not m: |
raise ValueError("output line %r of svn blame does not match " |
"expected format" % (line, )) |
rev, name, _ = m.groups() |
result.append((int(rev), name, line)) |
return result | |
def check(self, **kw):
check a path for existence, or query its properties
without arguments, this returns True if the path exists (on the
filesystem), False if not
with (keyword only) arguments, the object compares the value
of the argument with the value of a property with the same name
(if it has one, else it raises a TypeError)
when for example the keyword argument 'ext' is '.py', this will
return True if self.ext == '.py', False otherwise
arguments:
return value:
<Boolean>
source: path/common.py
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | |
def check(self, **kw): |
""" check a path for existence, or query its properties |
|
without arguments, this returns True if the path exists (on the |
filesystem), False if not |
|
with (keyword only) arguments, the object compares the value |
of the argument with the value of a property with the same name |
(if it has one, else it raises a TypeError) |
|
when for example the keyword argument 'ext' is '.py', this will |
return True if self.ext == '.py', False otherwise |
""" |
if kw: |
kw = kw.copy() |
if not checktype(self, kw): |
return False |
else: |
kw = {'exists' : 1} |
return self.Checkers(self)._evaluate(kw) | |
def checkout(self, url=None, rev=None):
checkout from url to local wcpath.
arguments:
return value:
<None>
source: path/svn/wccommand.py
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | |
def checkout(self, url=None, rev=None): |
""" checkout from url to local wcpath. """ |
args = [] |
if url is None: |
url = self.url |
if rev is None or rev == -1: |
if (py.std.sys.platform != 'win32' and |
svncommon._getsvnversion() == '1.3'): |
url += "@HEAD" |
else: |
if svncommon._getsvnversion() == '1.3': |
url += "@%d" % rev |
else: |
args.append('-r' + str(rev)) |
args.append(url) |
self._authsvn('co', args) | |
def cleanup(self):
remove any locks from the resource
arguments:
return value:
<UNKNOWN>
source: path/svn/wccommand.py
231 |
232 |
233 |
234 |
235 |
236 |
237 | |
def cleanup(self): |
""" remove any locks from the resource """ |
|
try: |
self.unlock() |
except: |
pass | |
def commit(self, msg='', rec=1):
commit with support for non-recursive commits
arguments:
return value:
AnyOf(<None>, <Int>)
source: path/svn/wccommand.py
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 | |
def commit(self, msg='', rec=1): |
""" commit with support for non-recursive commits """ |
from py.__.path.svn import cache |
|
cmd = 'commit -m "%s" --force-log' % (msg.replace('"', '\\"'),) |
if not rec: |
cmd += ' -N' |
out = self._authsvn(cmd) |
try: |
del cache.info[self] |
except KeyError: |
pass |
if out: |
m = self._rex_commit.match(out) |
return int(m.group(1)) | |
def common(self, other):
return the common part shared with the other path
or None if there is no common part.
source: path/common.py
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 | |
def common(self, other): |
""" return the common part shared with the other path |
or None if there is no common part. |
""" |
last = None |
for x, y in zip(self.parts(), other.parts()): |
if x != y: |
return last |
last = x |
return last | |
def copy(self, target):
copy path to target.
arguments:
return value:
<None>
def diff(self, rev=None):
return a diff of the current path against revision rev (defaulting
to the last one).
arguments:
return value:
<String>
source: path/svn/wccommand.py
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 | |
def diff(self, rev=None): |
""" return a diff of the current path against revision rev (defaulting |
to the last one). |
""" |
args = [] |
if rev is not None: |
args.append("-r %d" % rev) |
out = self._authsvn('diff', args) |
return out | |
def dirpath(self, *args):
return the directory Path of the current Path.
source: path/svn/wccommand.py
|
def dirpath(self, *args): |
""" return the directory Path of the current Path. """ |
return self.__class__(self.localpath.dirpath(*args), auth=self.auth) | |
def dump(self, obj):
pickle object into path location
arguments:
- self: <UNKNOWN>
- obj: <UNKNOWN>
return value:
<UNKNOWN>
def ensure(self, *args, **kwargs):
ensure that an args-joined path exists (by default as
a file). if you specify a keyword argument 'directory=True'
then the path is forced to be a directory path.
source: path/svn/wccommand.py
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 | |
def ensure(self, *args, **kwargs): |
""" ensure that an args-joined path exists (by default as |
a file). if you specify a keyword argument 'directory=True' |
then the path is forced to be a directory path. |
""" |
try: |
p = self.join(*args) |
if p.check(): |
if p.check(versioned=False): |
p.add() |
return p |
if kwargs.get('dir', 0): |
return p._ensuredirs() |
parent = p.dirpath() |
parent._ensuredirs() |
p.write("") |
p.add() |
return p |
except: |
error_enhance(sys.exc_info()) | |
def info(self, usecache=1):
return an Info structure with svn-provided information.
arguments:
return value:
AnyOf(<Instance of Class InfoSvnWCCommand>, <None>)
source: path/svn/wccommand.py
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 | |
def info(self, usecache=1): |
""" return an Info structure with svn-provided information. """ |
info = usecache and cache.info.get(self) |
if not info: |
try: |
output = self._svn('info') |
except py.process.cmdexec.Error, e: |
if e.err.find('Path is not a working copy directory') != -1: |
raise py.error.ENOENT(self, e.err) |
raise |
|
|
|
if (output.strip() == '' or |
output.lower().find('not a versioned resource') != -1): |
raise py.error.ENOENT(self, output) |
info = InfoSvnWCCommand(output) |
|
|
if py.std.sys.platform != 'win32': |
if info.path != self.localpath: |
raise py.error.ENOENT(self, "not a versioned resource:" + |
" %s != %s" % (info.path, self.localpath)) |
cache.info[self] = info |
self.rev = info.rev |
return info | |
def join(self, *args, **kwargs):
return a new Path (with the same revision) which is composed
of the self Path followed by 'args' path components.
source: path/svn/wccommand.py
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 | |
def join(self, *args, **kwargs): |
""" return a new Path (with the same revision) which is composed |
of the self Path followed by 'args' path components. |
""" |
if not args: |
return self |
localpath = self.localpath.join(*args, **kwargs) |
return self.__class__(localpath, auth=self.auth) | |
def listdir(self, fil=None, sort=None):
return a sequence of Paths.
listdir will return either a tuple or a list of paths
depending on implementation choices.
arguments:
- self: <Instance of Class SvnWCCommandPath>
- fil: AnyOf(<String>, <None>, <Instance of Class checker>)
- sort: AnyOf(<Boolean>, <None>)
return value:
AnyOf(<None>, <List>)
source: path/svn/wccommand.py
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 | |
def listdir(self, fil=None, sort=None): |
""" return a sequence of Paths. |
|
listdir will return either a tuple or a list of paths |
depending on implementation choices. |
""" |
if isinstance(fil, str): |
fil = common.fnmatch(fil) |
|
def notsvn(path): |
return path.basename != '.svn' |
|
paths = [] |
for localpath in self.localpath.listdir(notsvn): |
p = self.__class__(localpath, auth=self.auth) |
paths.append(p) |
|
if fil or sort: |
paths = filter(fil, paths) |
paths = isinstance(paths, list) and paths or list(paths) |
if callable(sort): |
paths.sort(sort) |
elif sort: |
paths.sort() |
return paths | |
def load(self):
return object unpickled from self.read()
arguments:
return value:
<Dict>
source: path/common.py
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 | |
def load(self): |
""" return object unpickled from self.read() """ |
f = self.open('rb') |
try: |
from cPickle import load |
return self._callex(load, f) |
finally: |
f.close() | |
def lock(self):
set a lock (exclusive) on the resource
arguments:
return value:
<None>
source: path/svn/wccommand.py
|
def lock(self): |
""" set a lock (exclusive) on the resource """ |
out = self._authsvn('lock').strip() |
if not out: |
|
raise Exception(out[4:]) | |
def log(self, rev_start=None, rev_end=1, verbose=False):
return a list of LogEntry instances for this path.
rev_start is the starting revision (defaulting to the first one).
rev_end is the last revision (defaulting to HEAD).
if verbose is True, then the LogEntry instances also know which files changed.
arguments:
- self: <UNKNOWN>
- rev_start: <UNKNOWN>
- rev_end: <UNKNOWN>
- verbose: <UNKNOWN>
return value:
<UNKNOWN>
source: path/svn/wccommand.py
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 | |
def log(self, rev_start=None, rev_end=1, verbose=False): |
""" return a list of LogEntry instances for this path. |
rev_start is the starting revision (defaulting to the first one). |
rev_end is the last revision (defaulting to HEAD). |
if verbose is True, then the LogEntry instances also know which files changed. |
""" |
from py.__.path.svn.urlcommand import _Head, LogEntry |
assert self.check() |
rev_start = rev_start is None and _Head or rev_start |
rev_end = rev_end is None and _Head or rev_end |
|
if rev_start is _Head and rev_end == 1: |
rev_opt = "" |
else: |
rev_opt = "-r %s:%s" % (rev_start, rev_end) |
verbose_opt = verbose and "-v" or "" |
locale_env = svncommon.fixlocale() |
|
auth_opt = self._makeauthoptions() |
stdin, stdout, stderr = os.popen3(locale_env + |
'svn log --xml %s %s %s "%s"' % ( |
rev_opt, verbose_opt, auth_opt, |
self.strpath)) |
from xml.dom import minidom |
from xml.parsers.expat import ExpatError |
try: |
tree = minidom.parse(stdout) |
except ExpatError: |
|
|
raise ValueError('no such revision') |
result = [] |
for logentry in filter(None, tree.firstChild.childNodes): |
if logentry.nodeType == logentry.ELEMENT_NODE: |
result.append(LogEntry(logentry)) |
return result | |
def mkdir(self, *args):
create & return the directory joined with args.
source: path/svn/wccommand.py
177 |
178 |
179 |
180 |
181 |
182 |
183 | |
def mkdir(self, *args): |
""" create & return the directory joined with args. """ |
if args: |
return self.join(*args).mkdir() |
else: |
self._svn('mkdir') |
return self | |
def move(self, target):
move this path to target.
arguments:
return value:
<None>
source: path/common.py
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 | |
def move(self, target): |
""" move this path to target. """ |
if target.relto(self): |
raise py.error.EINVAL(target, "cannot move path into a subdirectory of itself") |
try: |
self.rename(target) |
except py.error.EXDEV: |
self.copy(target) |
self.remove() | |
def mtime(self):
Return the last modification time of the file.
arguments:
return value:
<Int>
def new(self, **kw):
create a modified version of this path. A 'rev' argument
indicates a new revision.
the following keyword arguments modify various path parts:
http://host.com/repo/path/file.ext
|-----------------------| dirname
|------| basename
|--| purebasename
|--| ext
source: path/svn/wccommand.py
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 | |
def new(self, **kw): |
""" create a modified version of this path. A 'rev' argument |
indicates a new revision. |
the following keyword arguments modify various path parts: |
|
http://host.com/repo/path/file.ext |
|-----------------------| dirname |
|------| basename |
|--| purebasename |
|--| ext |
""" |
if kw: |
localpath = self.localpath.new(**kw) |
else: |
localpath = self.localpath |
return self.__class__(localpath, auth=self.auth) | |
def open(self, mode='r'):
return an opened file with the given mode.
arguments:
return value:
<Instance of Class file>
def parts(self, reverse=False):
return a root-first list of all ancestor directories
plus the path itself.
arguments:
return value:
<List>
source: path/common.py
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 | |
def parts(self, reverse=False): |
""" return a root-first list of all ancestor directories |
plus the path itself. |
""" |
current = self |
l = [self] |
while 1: |
last = current |
current = current.dirpath() |
if last == current: |
break |
l.insert(0, current) |
if reverse: |
l.reverse() |
return l | |
def propdel(self, name):
delete property name on this path.
arguments:
return value:
<String>
source: path/svn/wccommand.py
|
def propdel(self, name): |
""" delete property name on this path. """ |
res = self._svn('propdel', name) |
return res[:-1] | |
def propget(self, name):
get property name on this path.
arguments:
return value:
<String>
def proplist(self, rec=0):
return a mapping of property names to property values.
If rec is True, then return a dictionary mapping sub-paths to such mappings.
arguments:
return value:
AnyOf(<Dict>, <Instance of Class PropListDict>)
source: path/svn/wccommand.py
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 | |
def proplist(self, rec=0): |
""" return a mapping of property names to property values. |
If rec is True, then return a dictionary mapping sub-paths to such mappings. |
""" |
if rec: |
res = self._svn('proplist -R') |
return make_recursive_propdict(self, res) |
else: |
res = self._svn('proplist') |
lines = res.split('\n') |
lines = map(str.strip, lines[1:]) |
return svncommon.PropListDict(self, lines) | |
def propset(self, name, value, *args):
set property name to value on this path.
arguments:
return value:
<None>
source: path/svn/wccommand.py
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 | |
def propset(self, name, value, *args): |
""" set property name to value on this path. """ |
d = py.path.local.mkdtemp() |
try: |
p = d.join('value') |
p.write(value) |
self._svn('propset', name, '--file', str(p), *args) |
finally: |
d.remove() | |
def read(self, mode='rb'):
read and return a bytestring from reading the path.
arguments:
return value:
<String>
source: path/common.py
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 | |
def read(self, mode='rb'): |
""" read and return a bytestring from reading the path. """ |
if py.std.sys.version_info < (2,3): |
for x in 'u', 'U': |
if x in mode: |
mode = mode.replace(x, '') |
f = self.open(mode) |
try: |
return f.read() |
finally: |
f.close() | |
def readlines(self, cr=1):
read and return a list of lines from the path. if cr is False, the
newline will be removed from the end of each line.
arguments:
return value:
<List>
source: path/common.py
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 | |
def readlines(self, cr=1): |
""" read and return a list of lines from the path. if cr is False, the |
newline will be removed from the end of each line. """ |
if not cr: |
content = self.read('rU') |
return content.split('\n') |
else: |
f = self.open('rU') |
try: |
return f.readlines() |
finally: |
f.close() | |
def relto(self, relpath):
return a string which is the relative part of the path
to the given 'relpath'.
arguments:
return value:
AnyOf(<None>, <String>)
source: path/common.py
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | |
def relto(self, relpath): |
""" return a string which is the relative part of the path |
to the given 'relpath'. |
""" |
if not isinstance(relpath, (str, PathBase)): |
raise TypeError("%r: not a string or path object" %(relpath,)) |
strrelpath = str(relpath) |
if strrelpath and strrelpath[-1] != self.sep: |
strrelpath += self.sep |
|
|
strself = str(self) |
if strself.startswith(strrelpath): |
return strself[len(strrelpath):] |
return "" | |
def remove(self, rec=1, force=1):
remove a file or a directory tree. 'rec'ursive is
ignored and considered always true (because of
underlying svn semantics.
arguments:
return value:
<None>
source: path/svn/wccommand.py
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 | |
def remove(self, rec=1, force=1): |
""" remove a file or a directory tree. 'rec'ursive is |
ignored and considered always true (because of |
underlying svn semantics. |
""" |
assert rec, "svn cannot remove non-recursively" |
if not self.check(versioned=True): |
|
py.path.local(self).remove() |
return |
flags = [] |
if force: |
flags.append('--force') |
self._svn('remove', *flags) | |
def rename(self, target):
rename this path to target.
arguments:
return value:
<None>
source: path/svn/wccommand.py
|
def rename(self, target): |
""" rename this path to target. """ |
py.process.cmdexec("svn move --force %s %s" %(str(self), str(target))) | |
def revert(self, rec=0):
revert the local changes of this path. if rec is True, do so
recursively.
arguments:
return value:
<String>
source: path/svn/wccommand.py
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 | |
def revert(self, rec=0): |
""" revert the local changes of this path. if rec is True, do so |
recursively. """ |
if rec: |
result = self._svn('revert -R') |
else: |
result = self._svn('revert') |
return result | |
def size(self):
Return the size of the file content of the Path.
arguments:
return value:
<Instance of Class long>
def status(self, updates=0, rec=0, externals=0):
return (collective) Status object for this file.
arguments:
return value:
<Instance of Class WCStatus>
source: path/svn/wccommand.py
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 | |
def status(self, updates=0, rec=0, externals=0): |
""" return (collective) Status object for this file. """ |
|
|
|
if externals: |
raise ValueError("XXX cannot perform status() " |
"on external items yet") |
else: |
|
externals = '' |
if rec: |
rec= '' |
else: |
rec = '--non-recursive' |
|
|
|
|
|
if updates: |
updates = '-u' |
else: |
updates = '' |
|
update_rev = None |
|
cmd = 'status -v %s %s %s' % (updates, rec, externals) |
out = self._authsvn(cmd) |
rootstatus = WCStatus(self) |
for line in out.split('\n'): |
if not line.strip(): |
continue |
|
flags, rest = line[:8], line[8:] |
|
c0,c1,c2,c3,c4,c5,x6,c7 = flags |
|
|
|
if c0 in '?XI': |
fn = line.split(None, 1)[1] |
if c0 == '?': |
wcpath = self.join(fn, abs=1) |
rootstatus.unknown.append(wcpath) |
elif c0 == 'X': |
wcpath = self.__class__(self.localpath.join(fn, abs=1), |
auth=self.auth) |
rootstatus.external.append(wcpath) |
elif c0 == 'I': |
wcpath = self.join(fn, abs=1) |
rootstatus.ignored.append(wcpath) |
|
continue |
|
|
|
|
m = self._rex_status.match(rest) |
if not m: |
if c7 == '*': |
fn = rest.strip() |
wcpath = self.join(fn, abs=1) |
rootstatus.update_available.append(wcpath) |
continue |
if line.lower().find('against revision:')!=-1: |
update_rev = int(rest.split(':')[1].strip()) |
continue |
|
raise ValueError, "could not parse line %r" % line |
else: |
rev, modrev, author, fn = m.groups() |
wcpath = self.join(fn, abs=1) |
|
if c0 == 'M': |
assert wcpath.check(file=1), "didn't expect a directory with changed content here" |
rootstatus.modified.append(wcpath) |
elif c0 == 'A' or c3 == '+' : |
rootstatus.added.append(wcpath) |
elif c0 == 'D': |
rootstatus.deleted.append(wcpath) |
elif c0 == 'C': |
rootstatus.conflict.append(wcpath) |
elif c0 == '~': |
rootstatus.kindmismatch.append(wcpath) |
elif c0 == '!': |
rootstatus.incomplete.append(wcpath) |
elif not c0.strip(): |
rootstatus.unchanged.append(wcpath) |
else: |
raise NotImplementedError("received flag %r" % c0) |
|
if c1 == 'M': |
rootstatus.prop_modified.append(wcpath) |
|
if c2 == 'L' or c5 == 'K': |
rootstatus.locked.append(wcpath) |
if c7 == '*': |
rootstatus.update_available.append(wcpath) |
|
if wcpath == self: |
rootstatus.rev = rev |
rootstatus.modrev = modrev |
rootstatus.author = author |
if update_rev: |
rootstatus.update_rev = update_rev |
continue |
return rootstatus | |
def svnurl(self):
return current SvnPath for this WC-item.
arguments:
return value:
<UNKNOWN>
source: path/svn/wccommand.py
|
def svnurl(self): |
""" return current SvnPath for this WC-item. """ |
info = self.info() |
return py.path.svnurl(info.url) | |
def switch(self, url):
switch to given URL.
arguments:
- self: <UNKNOWN>
- url: <UNKNOWN>
return value:
<UNKNOWN>
def unlock(self):
unset a previously set lock
arguments:
return value:
<None>
source: path/svn/wccommand.py
|
def unlock(self): |
""" unset a previously set lock """ |
out = self._authsvn('unlock').strip() |
if out.startswith('svn:'): |
|
raise Exception(out[4:]) | |
def update(self, rev='HEAD'):
update working copy item to given revision. (None -> HEAD).
arguments:
return value:
<None>
source: path/svn/wccommand.py
|
def update(self, rev = 'HEAD'): |
""" update working copy item to given revision. (None -> HEAD). """ |
self._authsvn('up', ['-r', rev]) | |
def visit(self, fil=None, rec=None, ignore=<class py.__.path.common._dummyclass at 0x70396180>):
yields all paths below the current one
fil is a filter (glob pattern or callable), if not matching the
path will not be yielded, defaulting to None (everything is
returned)
rec is a filter (glob pattern or callable) that controls whether
a node is descended, defaulting to None
ignore is an Exception class that is ignoredwhen calling dirlist()
on any of the paths (by default, all exceptions are reported)
arguments:
- self: <Instance of Class SvnWCCommandPath>
- fil: AnyOf(<String>, <None>, <Instance of Class checker>, <Instance of Class fnmatch>, <Function>)
- rec: AnyOf(<Function>, <None>)
- ignore: AnyOf(Class ENOENT, Class _dummyclass)
return value:
AnyOf(<None>, <Instance of
Class SvnWCCommandPath>)
source: path/common.py
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 | |
def visit(self, fil=None, rec=None, ignore=_dummyclass): |
""" yields all paths below the current one |
|
fil is a filter (glob pattern or callable), if not matching the |
path will not be yielded, defaulting to None (everything is |
returned) |
|
rec is a filter (glob pattern or callable) that controls whether |
a node is descended, defaulting to None |
|
ignore is an Exception class that is ignoredwhen calling dirlist() |
on any of the paths (by default, all exceptions are reported) |
""" |
if isinstance(fil, str): |
fil = fnmatch(fil) |
if rec: |
if isinstance(rec, str): |
rec = fnmatch(fil) |
elif not callable(rec): |
rec = lambda x: True |
reclist = [self] |
while reclist: |
current = reclist.pop(0) |
try: |
dirlist = current.listdir() |
except ignore: |
return |
for p in dirlist: |
if fil is None or fil(p): |
yield p |
if p.check(dir=1) and (rec is None or rec(p)): |
reclist.append(p) | |
def write(self, content, mode='wb'):
write content into local filesystem wc.
arguments:
return value:
<None>
source: path/svn/wccommand.py
|
def write(self, content, mode='wb'): |
""" write content into local filesystem wc. """ |
self.localpath.write(content, mode) | |
def __add__(self, other):
return new path object with 'other' added to the basename
source: path/common.py
|
def __add__(self, other): |
""" return new path object with 'other' added to the basename""" |
return self.new(basename=self.basename+str(other)) | |
def __cmp__(self, other):
return sort value (-1, 0, +1).
arguments:
return value:
<Int>
source: path/common.py
|
def __cmp__(self, other): |
""" return sort value (-1, 0, +1). """ |
try: |
return cmp(self.strpath, other.strpath) |
except AttributeError: |
return cmp(str(self), str(other)) | |
def __contains__(self, other):
*no docstring available*
arguments:
return value:
<Boolean>
source: path/common.py
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 | |
def __contains__(self, other): |
if isinstance(other, str): |
return self.join(other).check() |
else: |
if other.dirpath() != self: |
return False |
p = self.join(other.basename) |
return p.check() | |
def __div__(self, other):
def __eq__(self, other):
*no docstring available*
arguments:
return value:
<Boolean>
def __hash__(self):
*no docstring available*
arguments:
return value:
<Int>
def __iter__(self):
*no docstring available*
arguments:
return value:
<UNKNOWN>
def __repr__(self):
*no docstring available*
arguments:
return value:
<String>
def __str__(self):
*no docstring available*
arguments:
return value:
<String>