equal
deleted
inserted
replaced
4 from mercurial import util |
4 from mercurial import util |
5 |
5 |
6 from common import NoRepo, commit, converter_source |
6 from common import NoRepo, commit, converter_source |
7 |
7 |
8 class convert_cvs(converter_source): |
8 class convert_cvs(converter_source): |
9 def __init__(self, ui, path): |
9 def __init__(self, ui, path, rev=None): |
10 self.path = path |
10 self.path = path |
11 self.ui = ui |
11 self.ui = ui |
|
12 self.rev = rev |
12 cvs = os.path.join(path, "CVS") |
13 cvs = os.path.join(path, "CVS") |
13 if not os.path.exists(cvs): |
14 if not os.path.exists(cvs): |
14 raise NoRepo("couldn't open CVS repo %s" % path) |
15 raise NoRepo("couldn't open CVS repo %s" % path) |
15 |
16 |
16 self.changeset = {} |
17 self.changeset = {} |
27 |
28 |
28 def _parse(self): |
29 def _parse(self): |
29 if self.changeset: |
30 if self.changeset: |
30 return |
31 return |
31 |
32 |
|
33 maxrev = 0 |
|
34 cmd = 'cvsps -A -u --cvs-direct -q' |
|
35 if self.rev: |
|
36 # TODO: handle tags |
|
37 try: |
|
38 # patchset number? |
|
39 maxrev = int(self.rev) |
|
40 except ValueError: |
|
41 try: |
|
42 # date |
|
43 util.parsedate(self.rev, ['%Y/%m/%d %H:%M:%S']) |
|
44 cmd = "%s -d '1970/01/01 00:00:01' -d '%s'" % (cmd, self.rev) |
|
45 except util.Abort: |
|
46 raise util.Abort('revision %s is not a patchset number or date' % self.rev) |
|
47 |
32 d = os.getcwd() |
48 d = os.getcwd() |
33 try: |
49 try: |
34 os.chdir(self.path) |
50 os.chdir(self.path) |
35 id = None |
51 id = None |
36 state = 0 |
52 state = 0 |
37 for l in os.popen("cvsps -A -u --cvs-direct -q"): |
53 for l in os.popen(cmd): |
38 if state == 0: # header |
54 if state == 0: # header |
39 if l.startswith("PatchSet"): |
55 if l.startswith("PatchSet"): |
40 id = l[9:-2] |
56 id = l[9:-2] |
|
57 if maxrev and int(id) > maxrev: |
|
58 state = 3 |
41 elif l.startswith("Date"): |
59 elif l.startswith("Date"): |
42 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) |
60 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) |
43 date = util.datestr(date) |
61 date = util.datestr(date) |
44 elif l.startswith("Branch"): |
62 elif l.startswith("Branch"): |
45 branch = l[8:-1] |
63 branch = l[8:-1] |
83 colon = l.rfind(':') |
101 colon = l.rfind(':') |
84 file = l[1:colon] |
102 file = l[1:colon] |
85 rev = l[colon+1:-2] |
103 rev = l[colon+1:-2] |
86 rev = rev.split("->")[1] |
104 rev = rev.split("->")[1] |
87 files[file] = rev |
105 files[file] = rev |
|
106 elif state == 3: |
|
107 continue |
88 |
108 |
89 self.heads = self.lastbranch.values() |
109 self.heads = self.lastbranch.values() |
90 finally: |
110 finally: |
91 os.chdir(d) |
111 os.chdir(d) |
92 |
112 |