]>
Tony Duckles's Git Repositories (git.nynim.org) - svn2svn.git/blob - svn2svn/run/svnancest.py
2 Display ancestry for a given path in an SVN repository.
5 from svn2svn
import base_version
, full_version
7 from svn2svn
import svnclient
8 from parse
import HelpFormatter
9 from svn2svn
.run
.common
import find_svn_ancestors
19 ui
.status("url: %s", url
, level
=ui
.DEBUG
, color
='GREEN')
20 info
= svnclient
.info(url
)
21 repos_root
= info
['repos_url']
22 repos_path
= url
[len(repos_root
):]
23 ancestors
= find_svn_ancestors(repos_root
, repos_path
, options
.revision
)
26 for idx
in range(len(ancestors
)):
28 max_len
= max(max_len
, len(d
['path']+"@"+str(d
['revision'])))
29 for idx
in range(len(ancestors
)):
31 ui
.status("[%s] %s --> %s", len(ancestors
)-idx
-1,
32 str(d
['path']+"@"+str(d
['revision'])).ljust(max_len
),
33 str(d
['copyfrom_path']+"@"+str(d
['copyfrom_rev'])))
35 ui
.status("No ancestor-chain found: %s", repos_root
+repos_path
+"@"+str(options
.revision
))
40 # Defined as entry point. Must be callable without arguments.
41 usage
= "svn2svn, version %s\n" % str(full_version
) + \
42 "<http://nynim.org/code/svn2svn> <https://github.com/tonyduckles/svn2svn>\n\n" + \
43 "Usage: %prog [OPTIONS] url\n"
45 Display ancestry for a given path in an SVN repository."""
46 parser
= optparse
.OptionParser(usage
, description
=description
,
47 formatter
=HelpFormatter(), version
="%prog "+str(full_version
))
48 parser
.add_option("-v", "--verbose", dest
="verbosity", action
="count", default
=1,
49 help="enable additional output (use -vv or -vvv for more)")
50 parser
.add_option("-r", "--revision", type="string", dest
="revision", metavar
="ARG",
51 help="revision range to replay from source_url\n"
52 "Any revision # formats which SVN understands are "
53 "supported, e.g. 'HEAD', '{2010-01-31}', etc.")
54 parser
.add_option("--debug", dest
="verbosity", const
=ui
.DEBUG
, action
="store_const",
55 help="enable debugging output (same as -vvv)")
57 options
, args
= parser
.parse_args()
59 parser
.error("incorrect number of arguments")
60 if options
.verbosity
< 10:
61 # Expand multiple "-v" arguments to a real ui._level value
62 options
.verbosity
*= 10
64 # Reg-ex for matching a revision arg (http://svnbook.red-bean.com/en/1.5/svn.tour.revs.specifiers.html#svn.tour.revs.dates)
65 rev_patt
= '[0-9A-Z]+|\{[0-9A-Za-z/\\ :-]+\}'
67 match
= re
.match('^('+rev_patt
+')$', options
.revision
)
69 parser
.error("unexpected --revision argument format; see 'svn help log' for valid revision formats")
71 options
.revision
= rev
[0] if len(rev
)>0 else None
73 options
.revision
= 'HEAD'
74 ui
.update_config(options
)
75 return real_main(args
)
78 if __name__
== "__main__":