[PATCH] Add built-in cvsps equivalent
Dean Roehrich
Dean.Roehrich at sun.com
Thu Mar 27 10:39:53 CDT 2008
On Wed, Mar 26, 2008 at 09:26:18PM +0000, Frank Kingswood wrote:
> # HG changeset patch
> # User Frank Kingswood <frank at kingswood-consulting.co.uk>
> # Date 1206566746 0
> # Node ID 9c0aac69922ad807a503ff80b489a27d7fb8e2b0
> # Parent e1fd124dd3473e4fde6ef62b3a7cb04090feddc2
> Add built-in cvsps equivalent.
>
> Built-in cvsps uses cvs rlog to determine the complete project history,
> merges similar commits into changesets and builds an ancestry graph.
>
> Also adds cvsps.py commandline tool, in case that is needed for debug.
> The cvsps.py output is mostly compatible with that of cvsps but
> in my experience sometimes generates correct output in situatons where
> the 'real' cvsps fails.
I've played with the stand-alone cvsps.py tool and it looks like it's
producing results similar to those of cvsps-2.1. I rarely use cvsps without
the -b and -r options, so here's my...first attempt at python code to add
those options. This is lightly tested, but so far looks like it's giving me
the results I expect from cvsps-2.1.
Now that I have -b and -r, I miss the cache. As I work through my weekly
incremental branch updates I can usually take advantage of the cache and get
1-minute response times from cvsps-2.1 queries. I run cvsps-2.1 once per week
to update the cache--this is one 11-minute hit (16 mins, with cvsps.py) to
parse nearly 12,000 patchsets in more branches than I care about.
Anyway, here's my first attempt at producing some perfectly lovely python
code. This applies on top of your patch and adds the -b and -r options (-r is
--tag1 and --tag2 here).
Dean
Index: mercurial.hg/hgext/convert/cvsps.py
===================================================================
--- mercurial.hg.orig/hgext/convert/cvsps.py 2008-03-26 17:03:16.000000000 -0500
+++ mercurial.hg/hgext/convert/cvsps.py 2008-03-27 09:27:53.447002000 -0500
@@ -438,6 +438,8 @@ def main():
op.add_option('-q',dest='Ignore',action='store_true',help=SUPPRESS_HELP)
# Main options
+ op.add_option('-b',dest='Branch',action='store',default='',
+ help='Restrict output to patchsets affecting branch')
op.add_option('-p',dest='Prefix',action='store',default='',
help='Prefix to remove from file names')
op.add_option('-v',dest='Verbose',action='count',default=0,
@@ -446,6 +448,10 @@ def main():
help='Set commit time fuzz',metavar='seconds')
op.add_option('--root',dest='Root',action='store',
help='Specify cvsroot',metavar='cvsroot')
+ op.add_option('--tag1',dest='Tag1',action='store',default='',
+ help='Show revisions since tag')
+ op.add_option('--tag2',dest='Tag2',action='store',default='',
+ help='Show revisions between --tag1 and --tag2')
# Debugging options
op.add_option('-c',dest='ReadChangeset',action='store',default='',
@@ -496,17 +502,47 @@ def main():
print
print '---------------'
+ in_tag_range = 1
+ found_tag2_stop = 0
+ found_tag1_start = 0
+ if options.Tag1:
+ in_tag_range = 0
+
# Print changesets
for i,cs in enumerate(changeset):
cs.Id=i+1
+
+ # If -b is specified, limit printing to the given branch.
+ if not cs.Branch:
+ cs.Branch = 'HEAD'
+ if options.Branch and cs.Branch != options.Branch:
+ continue
+
+ # Make a note when we find --tag1 or --tag2.
+ if options.Tag1:
+ for tag in cs.Tags:
+ if not in_tag_range and tag == options.Tag1:
+ found_tag1_start = 1
+ break
+ if in_tag_range and options.Tag2 and tag == options.Tag2:
+ found_tag2_stop = 1
+ break
+
+ if not in_tag_range:
+ # We begin printing with the changeset that _follows_ --tag1.
+ if found_tag1_start:
+ in_tag_range = 1
+ continue
+
+
# Note: trailing spaces on several lines here are needed to have
# bug-for-bug compatibility with cvsps.
print '---------------------'
print 'PatchSet %d '%cs.Id
print 'Date: %s'%util.datestr(cs.Date,'%Y/%m/%d %H:%M:%S')
print 'Author: %s'%cs.Author
- print 'Branch: %s'%(cs.Branch or 'HEAD')
+ print 'Branch: %s'%cs.Branch
print 'Tag%s: %s '%(['','s'][len(cs.Tags)>1],
','.join(cs.Tags) or '(none)')
if cs.Parent:
@@ -528,6 +564,12 @@ def main():
'.'.join([str(x) for x in f.Revision]),['','(DEAD)'][f.Dead])
print
+ # If that was --tag2, then stop.
+ if found_tag2_stop:
+ break
+
+
+
if __name__=='__main__':
main()
More information about the Mercurial-devel
mailing list