Show More
@@ -7,6 +7,7 b'' | |||||
7 | '''converting foreign VCS repositories to Mercurial''' |
|
7 | '''converting foreign VCS repositories to Mercurial''' | |
8 |
|
8 | |||
9 | import convcmd |
|
9 | import convcmd | |
|
10 | import cvsps | |||
10 | from mercurial import commands |
|
11 | from mercurial import commands | |
11 | from mercurial.i18n import _ |
|
12 | from mercurial.i18n import _ | |
12 |
|
13 | |||
@@ -183,7 +184,18 b' def convert(ui, src, dest=None, revmapfi' | |||||
183 | def debugsvnlog(ui, **opts): |
|
184 | def debugsvnlog(ui, **opts): | |
184 | return convcmd.debugsvnlog(ui, **opts) |
|
185 | return convcmd.debugsvnlog(ui, **opts) | |
185 |
|
186 | |||
186 | commands.norepo += " convert debugsvnlog" |
|
187 | def debugcvsps(ui, *args, **opts): | |
|
188 | '''Create changeset information from CVS | |||
|
189 | ||||
|
190 | This command is intended as a debugging tool for the CVS to Mercurial | |||
|
191 | converter, and can be used as a direct replacement for cvsps. | |||
|
192 | ||||
|
193 | Hg debugcvsps reads the CVS rlog for current directory (or any named | |||
|
194 | directory) in the CVS repository, and converts the log to a series of | |||
|
195 | changesets based on matching commit log entries and dates.''' | |||
|
196 | return cvsps.debugcvsps(ui, *args, **opts) | |||
|
197 | ||||
|
198 | commands.norepo += " convert debugsvnlog debugcvsps" | |||
187 |
|
199 | |||
188 | cmdtable = { |
|
200 | cmdtable = { | |
189 | "convert": |
|
201 | "convert": | |
@@ -200,4 +212,22 b' cmdtable = {' | |||||
200 | (debugsvnlog, |
|
212 | (debugsvnlog, | |
201 | [], |
|
213 | [], | |
202 | 'hg debugsvnlog'), |
|
214 | 'hg debugsvnlog'), | |
|
215 | "debugcvsps": | |||
|
216 | (debugcvsps, | |||
|
217 | [ | |||
|
218 | # Main options shared with cvsps-2.1 | |||
|
219 | ('b', 'branches', [], _('Only return changes on specified branches')), | |||
|
220 | ('p', 'prefix', '', _('Prefix to remove from file names')), | |||
|
221 | ('r', 'revisions', [], _('Only return changes after or between specified tags')), | |||
|
222 | ('u', 'update-cache', None, _("Update cvs log cache")), | |||
|
223 | ('x', 'new-cache', None, _("Create new cvs log cache")), | |||
|
224 | ('z', 'fuzz', 60, _('Set commit time fuzz in seconds')), | |||
|
225 | ('', 'root', '', _('Specify cvsroot')), | |||
|
226 | # Options specific to builtin cvsps | |||
|
227 | ('', 'parents', '', _('Show parent changesets')), | |||
|
228 | ('', 'ancestors', '', _('Show current changeset in ancestor branches')), | |||
|
229 | # Options that are ignored for compatibility with cvsps-2.1 | |||
|
230 | ('A', 'cvs-direct', None, 'Ignored for compatibility'), | |||
|
231 | ], | |||
|
232 | 'hg debugcvsps [OPTION]... [PATH]...'), | |||
203 | } |
|
233 | } |
@@ -584,3 +584,95 b' def createchangeset(ui, log, fuzz=60, me' | |||||
584 | ui.status(_('%d changeset entries\n') % len(changesets)) |
|
584 | ui.status(_('%d changeset entries\n') % len(changesets)) | |
585 |
|
585 | |||
586 | return changesets |
|
586 | return changesets | |
|
587 | ||||
|
588 | ||||
|
589 | def debugcvsps(ui, *args, **opts): | |||
|
590 | '''Read CVS rlog for current directory or named path in repository, and | |||
|
591 | convert the log to changesets based on matching commit log entries and dates.''' | |||
|
592 | ||||
|
593 | if opts["new_cache"]: | |||
|
594 | cache = "write" | |||
|
595 | elif opts["update_cache"]: | |||
|
596 | cache = "update" | |||
|
597 | else: | |||
|
598 | cache = None | |||
|
599 | ||||
|
600 | revisions = opts["revisions"] | |||
|
601 | ||||
|
602 | try: | |||
|
603 | if args: | |||
|
604 | log = [] | |||
|
605 | for d in args: | |||
|
606 | log += createlog(ui, d, root=opts["root"], cache=cache) | |||
|
607 | else: | |||
|
608 | log = createlog(ui, root=opts["root"], cache=cache) | |||
|
609 | except logerror, e: | |||
|
610 | ui.write("%r\n"%e) | |||
|
611 | return | |||
|
612 | ||||
|
613 | changesets = createchangeset(ui, log, opts["fuzz"]) | |||
|
614 | del log | |||
|
615 | ||||
|
616 | # Print changesets (optionally filtered) | |||
|
617 | ||||
|
618 | off = len(revisions) | |||
|
619 | branches = {} # latest version number in each branch | |||
|
620 | ancestors = {} # parent branch | |||
|
621 | for cs in changesets: | |||
|
622 | ||||
|
623 | if opts["ancestors"]: | |||
|
624 | if cs.branch not in branches and cs.parents and cs.parents[0].id: | |||
|
625 | ancestors[cs.branch] = changesets[cs.parents[0].id-1].branch, cs.parents[0].id | |||
|
626 | branches[cs.branch] = cs.id | |||
|
627 | ||||
|
628 | # limit by branches | |||
|
629 | if opts["branches"] and (cs.branch or 'HEAD') not in opts["branches"]: | |||
|
630 | continue | |||
|
631 | ||||
|
632 | if not off: | |||
|
633 | # Note: trailing spaces on several lines here are needed to have | |||
|
634 | # bug-for-bug compatibility with cvsps. | |||
|
635 | ui.write('---------------------\n') | |||
|
636 | ui.write('PatchSet %d \n' % cs.id) | |||
|
637 | ui.write('Date: %s\n' % util.datestr(cs.date, '%Y/%m/%d %H:%M:%S %1%2')) | |||
|
638 | ui.write('Author: %s\n' % cs.author) | |||
|
639 | ui.write('Branch: %s\n' % (cs.branch or 'HEAD')) | |||
|
640 | ui.write('Tag%s: %s \n' % (['', 's'][len(cs.tags)>1], | |||
|
641 | ','.join(cs.tags) or '(none)')) | |||
|
642 | if opts["parents"] and cs.parents: | |||
|
643 | if len(cs.parents)>1: | |||
|
644 | ui.write('Parents: %s\n' % (','.join([str(p.id) for p in cs.parents]))) | |||
|
645 | else: | |||
|
646 | ui.write('Parent: %d\n' % cs.parents[0].id) | |||
|
647 | ||||
|
648 | if opts["ancestors"]: | |||
|
649 | b = cs.branch | |||
|
650 | r = [] | |||
|
651 | while b: | |||
|
652 | b, c = ancestors[b] | |||
|
653 | r.append('%s:%d:%d' % (b or "HEAD", c, branches[b])) | |||
|
654 | if r: | |||
|
655 | ui.write('Ancestors: %s\n' % (','.join(r))) | |||
|
656 | ||||
|
657 | ui.write('Log:\n') | |||
|
658 | ui.write('%s\n\n' % cs.comment) | |||
|
659 | ui.write('Members: \n') | |||
|
660 | for f in cs.entries: | |||
|
661 | fn = f.file | |||
|
662 | if fn.startswith(opts["prefix"]): | |||
|
663 | fn = fn[len(opts["prefix"]):] | |||
|
664 | ui.write('\t%s:%s->%s%s \n' % (fn, '.'.join([str(x) for x in f.parent]) or 'INITIAL', | |||
|
665 | '.'.join([str(x) for x in f.revision]), ['', '(DEAD)'][f.dead])) | |||
|
666 | ui.write('\n') | |||
|
667 | ||||
|
668 | # have we seen the start tag? | |||
|
669 | if revisions and off: | |||
|
670 | if revisions[0] == str(cs.id) or \ | |||
|
671 | revisions[0] in cs.tags: | |||
|
672 | off = False | |||
|
673 | ||||
|
674 | # see if we reached the end tag | |||
|
675 | if len(revisions)>1 and not off: | |||
|
676 | if revisions[1] == str(cs.id) or \ | |||
|
677 | revisions[1] in cs.tags: | |||
|
678 | break |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now