comparison hgext/convert/cvsps.py @ 8661:883f14fcd1df

convert/cvsps: wrap long lines
author Martin Geisler <mg@lazybytes.net>
date Sun, 31 May 2009 01:28:18 +0200
parents 221786b9ce34
children 6019e6517f95
comparison
equal deleted inserted replaced
8660:b9ec04eb2aa3 8661:883f14fcd1df
32 .parent - Previous revision of this entry 32 .parent - Previous revision of this entry
33 .rcs - name of file as returned from CVS 33 .rcs - name of file as returned from CVS
34 .revision - revision number as tuple 34 .revision - revision number as tuple
35 .tags - list of tags on the file 35 .tags - list of tags on the file
36 .synthetic - is this a synthetic "file ... added on ..." revision? 36 .synthetic - is this a synthetic "file ... added on ..." revision?
37 .mergepoint- the branch that has been merged from (if present in rlog output) 37 .mergepoint- the branch that has been merged from
38 (if present in rlog output)
38 ''' 39 '''
39 def __init__(self, **entries): 40 def __init__(self, **entries):
40 self.__dict__.update(entries) 41 self.__dict__.update(entries)
41 42
42 def __repr__(self): 43 def __repr__(self):
103 104
104 # patterns to match in CVS (r)log output, by state of use 105 # patterns to match in CVS (r)log output, by state of use
105 re_00 = re.compile('RCS file: (.+)$') 106 re_00 = re.compile('RCS file: (.+)$')
106 re_01 = re.compile('cvs \\[r?log aborted\\]: (.+)$') 107 re_01 = re.compile('cvs \\[r?log aborted\\]: (.+)$')
107 re_02 = re.compile('cvs (r?log|server): (.+)\n$') 108 re_02 = re.compile('cvs (r?log|server): (.+)\n$')
108 re_03 = re.compile("(Cannot access.+CVSROOT)|(can't create temporary directory.+)$") 109 re_03 = re.compile("(Cannot access.+CVSROOT)|"
110 "(can't create temporary directory.+)$")
109 re_10 = re.compile('Working file: (.+)$') 111 re_10 = re.compile('Working file: (.+)$')
110 re_20 = re.compile('symbolic names:') 112 re_20 = re.compile('symbolic names:')
111 re_30 = re.compile('\t(.+): ([\\d.]+)$') 113 re_30 = re.compile('\t(.+): ([\\d.]+)$')
112 re_31 = re.compile('----------------------------$') 114 re_31 = re.compile('----------------------------$')
113 re_32 = re.compile('=============================================================================$') 115 re_32 = re.compile('======================================='
116 '======================================$')
114 re_50 = re.compile('revision ([\\d.]+)(\s+locked by:\s+.+;)?$') 117 re_50 = re.compile('revision ([\\d.]+)(\s+locked by:\s+.+;)?$')
115 re_60 = re.compile(r'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?(.*mergepoint:\s+([^;]+);)?') 118 re_60 = re.compile(r'date:\s+(.+);\s+author:\s+(.+);\s+state:\s+(.+?);'
119 r'(\s+lines:\s+(\+\d+)?\s+(-\d+)?;)?'
120 r'(.*mergepoint:\s+([^;]+);)?')
116 re_70 = re.compile('branches: (.+);$') 121 re_70 = re.compile('branches: (.+);$')
117 122
118 file_added_re = re.compile(r'file [^/]+ was (initially )?added on branch') 123 file_added_re = re.compile(r'file [^/]+ was (initially )?added on branch')
119 124
120 prefix = '' # leading path to strip of what we get from CVS 125 prefix = '' # leading path to strip of what we get from CVS
280 elif state == 4: 285 elif state == 4:
281 # expecting '------' separator before first revision 286 # expecting '------' separator before first revision
282 if re_31.match(line): 287 if re_31.match(line):
283 state = 5 288 state = 5
284 else: 289 else:
285 assert not re_32.match(line), _('must have at least some revisions') 290 assert not re_32.match(line), _('must have at least '
291 'some revisions')
286 292
287 elif state == 5: 293 elif state == 5:
288 # expecting revision number and possibly (ignored) lock indication 294 # expecting revision number and possibly (ignored) lock indication
289 # we create the logentry here from values stored in states 0 to 4, 295 # we create the logentry here from values stored in states 0 to 4,
290 # as this state is re-entered for subsequent revisions of a file. 296 # as this state is re-entered for subsequent revisions of a file.
306 d = '19' + d 312 d = '19' + d
307 313
308 if len(d.split()) != 3: 314 if len(d.split()) != 3:
309 # cvs log dates always in GMT 315 # cvs log dates always in GMT
310 d = d + ' UTC' 316 d = d + ' UTC'
311 e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%Y-%m-%d %H:%M:%S']) 317 e.date = util.parsedate(d, ['%y/%m/%d %H:%M:%S',
318 '%Y/%m/%d %H:%M:%S',
319 '%Y-%m-%d %H:%M:%S'])
312 e.author = scache(match.group(2)) 320 e.author = scache(match.group(2))
313 e.dead = match.group(3).lower() == 'dead' 321 e.dead = match.group(3).lower() == 'dead'
314 322
315 if match.group(5): 323 if match.group(5):
316 if match.group(6): 324 if match.group(6):
441 .date - the commit date as a (time,tz) tuple 449 .date - the commit date as a (time,tz) tuple
442 .entries - list of logentry objects in this changeset 450 .entries - list of logentry objects in this changeset
443 .parents - list of one or two parent changesets 451 .parents - list of one or two parent changesets
444 .tags - list of tags on this changeset 452 .tags - list of tags on this changeset
445 .synthetic - from synthetic revision "file ... added on branch ..." 453 .synthetic - from synthetic revision "file ... added on branch ..."
446 .mergepoint- the branch that has been merged from (if present in rlog output) 454 .mergepoint- the branch that has been merged from
455 (if present in rlog output)
447 ''' 456 '''
448 def __init__(self, **entries): 457 def __init__(self, **entries):
449 self.__dict__.update(entries) 458 self.__dict__.update(entries)
450 459
451 def __repr__(self): 460 def __repr__(self):
687 696
688 return changesets 697 return changesets
689 698
690 699
691 def debugcvsps(ui, *args, **opts): 700 def debugcvsps(ui, *args, **opts):
692 '''Read CVS rlog for current directory or named path in repository, and 701 '''Read CVS rlog for current directory or named path in
693 convert the log to changesets based on matching commit log entries and dates.''' 702 repository, and convert the log to changesets based on matching
694 703 commit log entries and dates.
704 '''
695 if opts["new_cache"]: 705 if opts["new_cache"]:
696 cache = "write" 706 cache = "write"
697 elif opts["update_cache"]: 707 elif opts["update_cache"]:
698 cache = "update" 708 cache = "update"
699 else: 709 else:
722 ancestors = {} # parent branch 732 ancestors = {} # parent branch
723 for cs in changesets: 733 for cs in changesets:
724 734
725 if opts["ancestors"]: 735 if opts["ancestors"]:
726 if cs.branch not in branches and cs.parents and cs.parents[0].id: 736 if cs.branch not in branches and cs.parents and cs.parents[0].id:
727 ancestors[cs.branch] = changesets[cs.parents[0].id-1].branch, cs.parents[0].id 737 ancestors[cs.branch] = (changesets[cs.parents[0].id-1].branch,
738 cs.parents[0].id)
728 branches[cs.branch] = cs.id 739 branches[cs.branch] = cs.id
729 740
730 # limit by branches 741 # limit by branches
731 if opts["branches"] and (cs.branch or 'HEAD') not in opts["branches"]: 742 if opts["branches"] and (cs.branch or 'HEAD') not in opts["branches"]:
732 continue 743 continue
734 if not off: 745 if not off:
735 # Note: trailing spaces on several lines here are needed to have 746 # Note: trailing spaces on several lines here are needed to have
736 # bug-for-bug compatibility with cvsps. 747 # bug-for-bug compatibility with cvsps.
737 ui.write('---------------------\n') 748 ui.write('---------------------\n')
738 ui.write('PatchSet %d \n' % cs.id) 749 ui.write('PatchSet %d \n' % cs.id)
739 ui.write('Date: %s\n' % util.datestr(cs.date, '%Y/%m/%d %H:%M:%S %1%2')) 750 ui.write('Date: %s\n' % util.datestr(cs.date,
751 '%Y/%m/%d %H:%M:%S %1%2'))
740 ui.write('Author: %s\n' % cs.author) 752 ui.write('Author: %s\n' % cs.author)
741 ui.write('Branch: %s\n' % (cs.branch or 'HEAD')) 753 ui.write('Branch: %s\n' % (cs.branch or 'HEAD'))
742 ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1], 754 ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1],
743 ','.join(cs.tags) or '(none)')) 755 ','.join(cs.tags) or '(none)'))
744 if opts["parents"] and cs.parents: 756 if opts["parents"] and cs.parents: