Mercurial > hg
annotate hgext/convert/cvs.py @ 5956:094638b3cbed
convert: checkout svn root revisions
Using changed files is enough if whole history is converted. Checkouts are
required to restrict the conversion to user-supplied subtree.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 14:45:04 +0100 |
parents | 549a7ebe1607 |
children | fb259a3572e9 |
rev | line source |
---|---|
4536
cc9b79216a76
Split convert extension into common and repository type modules
Brendan Cully <brendan@kublai.com>
parents:
4532
diff
changeset
|
1 # CVS conversion code inspired by hg-cvs-import and git-cvsimport |
4516
96d8a56d4ef9
Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4515
diff
changeset
|
2 |
4536
cc9b79216a76
Split convert extension into common and repository type modules
Brendan Cully <brendan@kublai.com>
parents:
4532
diff
changeset
|
3 import os, locale, re, socket |
5539
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
4 from cStringIO import StringIO |
4536
cc9b79216a76
Split convert extension into common and repository type modules
Brendan Cully <brendan@kublai.com>
parents:
4532
diff
changeset
|
5 from mercurial import util |
4447
1b75e0eff532
document conversion interface
Daniel Holth <dholth@fastmail.fm>
parents:
4114
diff
changeset
|
6 |
5497
f0a3918abd42
convert: fail if an external required tool is not found
Patrick Mezard <pmezard@gmail.com>
parents:
5381
diff
changeset
|
7 from common import NoRepo, commit, converter_source, checktool |
4447
1b75e0eff532
document conversion interface
Daniel Holth <dholth@fastmail.fm>
parents:
4114
diff
changeset
|
8 |
4448
af013ae3ca10
use documented convert-repo interface
Daniel Holth <dholth@fastmail.fm>
parents:
4447
diff
changeset
|
9 class convert_cvs(converter_source): |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
10 def __init__(self, ui, path, rev=None): |
4807
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4762
diff
changeset
|
11 super(convert_cvs, self).__init__(ui, path, rev=rev) |
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4762
diff
changeset
|
12 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
13 cvs = os.path.join(path, "CVS") |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
14 if not os.path.exists(cvs): |
5521
03496d4fa509
convert: display all errors if we couldn't open the source repo
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5481
diff
changeset
|
15 raise NoRepo("%s does not look like a CVS checkout" % path) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
16 |
5497
f0a3918abd42
convert: fail if an external required tool is not found
Patrick Mezard <pmezard@gmail.com>
parents:
5381
diff
changeset
|
17 for tool in ('cvsps', 'cvs'): |
f0a3918abd42
convert: fail if an external required tool is not found
Patrick Mezard <pmezard@gmail.com>
parents:
5381
diff
changeset
|
18 checktool(tool) |
f0a3918abd42
convert: fail if an external required tool is not found
Patrick Mezard <pmezard@gmail.com>
parents:
5381
diff
changeset
|
19 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
20 self.changeset = {} |
3954
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
21 self.files = {} |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
22 self.tags = {} |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
23 self.lastbranch = {} |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
24 self.parent = {} |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
25 self.socket = None |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
26 self.cvsroot = file(os.path.join(cvs, "Root")).read()[:-1] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
27 self.cvsrepo = file(os.path.join(cvs, "Repository")).read()[:-1] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
28 self.encoding = locale.getpreferredencoding() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
29 self._parse() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
30 self._connect() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
31 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
32 def _parse(self): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
33 if self.changeset: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
34 return |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
35 |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
36 maxrev = 0 |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
37 cmd = 'cvsps -A -u --cvs-direct -q' |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
38 if self.rev: |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
39 # TODO: handle tags |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
40 try: |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
41 # patchset number? |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
42 maxrev = int(self.rev) |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
43 except ValueError: |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
44 try: |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
45 # date |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
46 util.parsedate(self.rev, ['%Y/%m/%d %H:%M:%S']) |
5308 | 47 cmd = '%s -d "1970/01/01 00:00:01" -d "%s"' % (cmd, self.rev) |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
48 except util.Abort: |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
49 raise util.Abort('revision %s is not a patchset number or date' % self.rev) |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
50 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
51 d = os.getcwd() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
52 try: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
53 os.chdir(self.path) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
54 id = None |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
55 state = 0 |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
56 filerevids = {} |
5481
003d1f174fe1
Fix Windows os.popen bug with interleaved stdout/stderr output
Patrick Mezard <pmezard@gmail.com>
parents:
5381
diff
changeset
|
57 for l in util.popen(cmd): |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
58 if state == 0: # header |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
59 if l.startswith("PatchSet"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
60 id = l[9:-2] |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
61 if maxrev and int(id) > maxrev: |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
62 # ignore everything |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
63 state = 3 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
64 elif l.startswith("Date"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
65 date = util.parsedate(l[6:-1], ["%Y/%m/%d %H:%M:%S"]) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
66 date = util.datestr(date) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
67 elif l.startswith("Branch"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
68 branch = l[8:-1] |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
69 self.parent[id] = self.lastbranch.get(branch, 'bad') |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
70 self.lastbranch[branch] = id |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
71 elif l.startswith("Ancestor branch"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
72 ancestor = l[17:-1] |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
73 # figure out the parent later |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
74 self.parent[id] = None |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
75 elif l.startswith("Author"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
76 author = self.recode(l[8:-1]) |
4698
30e826bd8ed1
convert: handle new cvsps with Tags: and multiple tags.
Eric Hopper <hopper@omnifarious.org>
parents:
4536
diff
changeset
|
77 elif l.startswith("Tag:") or l.startswith("Tags:"): |
30e826bd8ed1
convert: handle new cvsps with Tags: and multiple tags.
Eric Hopper <hopper@omnifarious.org>
parents:
4536
diff
changeset
|
78 t = l[l.index(':')+1:] |
30e826bd8ed1
convert: handle new cvsps with Tags: and multiple tags.
Eric Hopper <hopper@omnifarious.org>
parents:
4536
diff
changeset
|
79 t = [ut.strip() for ut in t.split(',')] |
30e826bd8ed1
convert: handle new cvsps with Tags: and multiple tags.
Eric Hopper <hopper@omnifarious.org>
parents:
4536
diff
changeset
|
80 if (len(t) > 1) or (t[0] and (t[0] != "(none)")): |
30e826bd8ed1
convert: handle new cvsps with Tags: and multiple tags.
Eric Hopper <hopper@omnifarious.org>
parents:
4536
diff
changeset
|
81 self.tags.update(dict.fromkeys(t, id)) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
82 elif l.startswith("Log:"): |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
83 # switch to gathering log |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
84 state = 1 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
85 log = "" |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
86 elif state == 1: # log |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
87 if l == "Members: \n": |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
88 # switch to gathering members |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
89 files = {} |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
90 oldrevs = [] |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
91 log = self.recode(log[:-1]) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
92 state = 2 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
93 else: |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
94 # gather log |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
95 log += l |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
96 elif state == 2: # members |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
97 if l == "\n": # start of next entry |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
98 state = 0 |
3954
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
99 p = [self.parent[id]] |
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
100 if id == "1": |
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
101 p = [] |
4518
3e4aa4c9efe4
convert: map CVS HEAD to default branch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4516
diff
changeset
|
102 if branch == "HEAD": |
3e4aa4c9efe4
convert: map CVS HEAD to default branch
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4516
diff
changeset
|
103 branch = "" |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
104 if branch and p[0] == None: |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
105 latest = None |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
106 # the last changeset that contains a base |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
107 # file is our parent |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
108 for r in oldrevs: |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
109 latest = max(filerevids[r], latest) |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
110 p = [latest] |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
111 |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
112 # add current commit to set |
3954
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
113 c = commit(author=author, date=date, parents=p, |
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
114 desc=log, branch=branch) |
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
115 self.changeset[id] = c |
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
116 self.files[id] = files |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
117 else: |
4515
86a66cce9566
Fixed python2.3 incompatibility (rsplit) in cvs code of convert extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4513
diff
changeset
|
118 colon = l.rfind(':') |
86a66cce9566
Fixed python2.3 incompatibility (rsplit) in cvs code of convert extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4513
diff
changeset
|
119 file = l[1:colon] |
86a66cce9566
Fixed python2.3 incompatibility (rsplit) in cvs code of convert extension
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4513
diff
changeset
|
120 rev = l[colon+1:-2] |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
121 oldrev, rev = rev.split("->") |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
122 files[file] = rev |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
123 |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
124 # save some information for identifying branch points |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
125 oldrevs.append("%s:%s" % (oldrev, file)) |
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
126 filerevids["%s:%s" % (rev, file)] = id |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
127 elif state == 3: |
5920
5df7cb799baf
CVS convert: Find correct parent for new branch (issue704)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5521
diff
changeset
|
128 # swallow all input |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4759
diff
changeset
|
129 continue |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
130 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
131 self.heads = self.lastbranch.values() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
132 finally: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
133 os.chdir(d) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
134 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
135 def _connect(self): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
136 root = self.cvsroot |
4047 | 137 conntype = None |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
138 user, host = None, None |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
139 cmd = ['cvs', 'server'] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
140 |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
141 self.ui.status("connecting to %s\n" % root) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
142 |
4047 | 143 if root.startswith(":pserver:"): |
144 root = root[9:] | |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
145 m = re.match(r'(?:(.*?)(?::(.*?))?@)?([^:\/]*)(?::(\d*))?(.*)', |
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
146 root) |
4047 | 147 if m: |
148 conntype = "pserver" | |
149 user, passw, serv, port, root = m.groups() | |
150 if not user: | |
151 user = "anonymous" | |
5082
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
152 if not port: |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
153 port = 2401 |
4047 | 154 else: |
5082
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
155 port = int(port) |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
156 format0 = ":pserver:%s@%s:%s" % (user, serv, root) |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
157 format1 = ":pserver:%s@%s:%d%s" % (user, serv, port, root) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
158 |
4047 | 159 if not passw: |
160 passw = "A" | |
161 pf = open(os.path.join(os.environ["HOME"], ".cvspass")) | |
5082
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
162 for line in pf.read().splitlines(): |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
163 part1, part2 = line.split(' ', 1) |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
164 if part1 == '/1': |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
165 # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
166 part1, part2 = part2.split(' ', 1) |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
167 format = format1 |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
168 else: |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
169 # :pserver:user@example.com:/cvsroot/foo Ah<Z |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
170 format = format0 |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
171 if part1 == format: |
dc2e512cb89a
CVS import: Support new-style .cvspass-file format.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4698
diff
changeset
|
172 passw = part2 |
4047 | 173 break |
174 pf.close() | |
175 | |
176 sck = socket.socket() | |
177 sck.connect((serv, port)) | |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
178 sck.send("\n".join(["BEGIN AUTH REQUEST", root, user, passw, |
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
179 "END AUTH REQUEST", ""])) |
4047 | 180 if sck.recv(128) != "I LOVE YOU\n": |
5182
7e05bdeee7de
convert: raise Abort instead of NoRepo when CVS pserver auth fails.
Brendan Cully <brendan@kublai.com>
parents:
5146
diff
changeset
|
181 raise util.Abort("CVS pserver authentication failed") |
4047 | 182 |
183 self.writep = self.readp = sck.makefile('r+') | |
184 | |
185 if not conntype and root.startswith(":local:"): | |
186 conntype = "local" | |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
187 root = root[7:] |
4047 | 188 |
189 if not conntype: | |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
190 # :ext:user@host/home/user/path/to/cvsroot |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
191 if root.startswith(":ext:"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
192 root = root[5:] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
193 m = re.match(r'(?:([^@:/]+)@)?([^:/]+):?(.*)', root) |
5304
b85f7cc133cc
convert: avoid interpreting Windows path as CVS connection strings.
Patrick Mezard <pmezard@gmail.com>
parents:
5303
diff
changeset
|
194 # Do not take Windows path "c:\foo\bar" for a connection strings |
b85f7cc133cc
convert: avoid interpreting Windows path as CVS connection strings.
Patrick Mezard <pmezard@gmail.com>
parents:
5303
diff
changeset
|
195 if os.path.isdir(root) or not m: |
4047 | 196 conntype = "local" |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
197 else: |
4047 | 198 conntype = "rsh" |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
199 user, host, root = m.group(1), m.group(2), m.group(3) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
200 |
4047 | 201 if conntype != "pserver": |
4516
96d8a56d4ef9
Removed trailing whitespace and tabs from python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4515
diff
changeset
|
202 if conntype == "rsh": |
5860
493632bb171c
convert should use default value when CVS_RSH is not set, that value
Kostantinos Koukopoulos <kouk@noc.uoa.gr>
parents:
5539
diff
changeset
|
203 rsh = os.environ.get("CVS_RSH") or "ssh" |
4047 | 204 if user: |
205 cmd = [rsh, '-l', user, host] + cmd | |
206 else: | |
207 cmd = [rsh, host] + cmd | |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
208 |
5303
a76c61679b71
convert: call popen2 in binary mode, with a command string.
Patrick Mezard <pmezard@gmail.com>
parents:
5082
diff
changeset
|
209 # popen2 does not support argument lists under Windows |
a76c61679b71
convert: call popen2 in binary mode, with a command string.
Patrick Mezard <pmezard@gmail.com>
parents:
5082
diff
changeset
|
210 cmd = [util.shellquote(arg) for arg in cmd] |
a76c61679b71
convert: call popen2 in binary mode, with a command string.
Patrick Mezard <pmezard@gmail.com>
parents:
5082
diff
changeset
|
211 cmd = util.quotecommand(' '.join(cmd)) |
a76c61679b71
convert: call popen2 in binary mode, with a command string.
Patrick Mezard <pmezard@gmail.com>
parents:
5082
diff
changeset
|
212 self.writep, self.readp = os.popen2(cmd, 'b') |
4047 | 213 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
214 self.realroot = root |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
215 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
216 self.writep.write("Root %s\n" % root) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
217 self.writep.write("Valid-responses ok error Valid-requests Mode" |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
218 " M Mbinary E Checked-in Created Updated" |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
219 " Merged Removed\n") |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
220 self.writep.write("valid-requests\n") |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
221 self.writep.flush() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
222 r = self.readp.readline() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
223 if not r.startswith("Valid-requests"): |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
224 raise util.Abort("server sucks") |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
225 if "UseUnchanged" in r: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
226 self.writep.write("UseUnchanged\n") |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
227 self.writep.flush() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
228 r = self.readp.readline() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
229 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
230 def getheads(self): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
231 return self.heads |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
232 |
3956
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
233 def _getfile(self, name, rev): |
5539
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
234 |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
235 def chunkedread(fp, count): |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
236 # file-objects returned by socked.makefile() do not handle |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
237 # large read() requests very well. |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
238 chunksize = 65536 |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
239 output = StringIO() |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
240 while count > 0: |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
241 data = fp.read(min(count, chunksize)) |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
242 if not data: |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
243 raise util.Abort("%d bytes missing from remote file" % count) |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
244 count -= len(data) |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
245 output.write(data) |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
246 return output.getvalue() |
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
247 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
248 if rev.endswith("(DEAD)"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
249 raise IOError |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
250 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
251 args = ("-N -P -kk -r %s --" % rev).split() |
5305
87348cdce88c
convert: fix remote cvs file paths separator
Patrick Mezard <pmezard@gmail.com>
parents:
5304
diff
changeset
|
252 args.append(self.cvsrepo + '/' + name) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
253 for x in args: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
254 self.writep.write("Argument %s\n" % x) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
255 self.writep.write("Directory .\n%s\nco\n" % self.realroot) |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
256 self.writep.flush() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
257 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
258 data = "" |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
259 while 1: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
260 line = self.readp.readline() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
261 if line.startswith("Created ") or line.startswith("Updated "): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
262 self.readp.readline() # path |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
263 self.readp.readline() # entries |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
264 mode = self.readp.readline()[:-1] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
265 count = int(self.readp.readline()[:-1]) |
5539
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
266 data = chunkedread(self.readp, count) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
267 elif line.startswith(" "): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
268 data += line[1:] |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
269 elif line.startswith("M "): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
270 pass |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
271 elif line.startswith("Mbinary "): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
272 count = int(self.readp.readline()[:-1]) |
5539
954e68e54dea
convert: read CVS files in chunks (issue 800)
Patrick Mezard <pmezard@gmail.com>
parents:
5528
diff
changeset
|
273 data = chunkedread(self.readp, count) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
274 else: |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
275 if line == "ok\n": |
4082
6b2909e84203
convert-repo converts symlinks from git
Daniel Holth <dholth@fastmail.fm>
parents:
4062
diff
changeset
|
276 return (data, "x" in mode and "x" or "") |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
277 elif line.startswith("E "): |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
278 self.ui.warn("cvs server: %s\n" % line[2:]) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
279 elif line.startswith("Remove"): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
280 l = self.readp.readline() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
281 l = self.readp.readline() |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
282 if l != "ok\n": |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
283 raise util.Abort("unknown CVS response: %s" % l) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
284 else: |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
285 raise util.Abort("unknown CVS response: %s" % line) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
286 |
3956
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
287 def getfile(self, file, rev): |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
288 data, mode = self._getfile(file, rev) |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
289 self.modecache[(file, rev)] = mode |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
290 return data |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
291 |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
292 def getmode(self, file, rev): |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
293 return self.modecache[(file, rev)] |
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
294 |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
295 def getchanges(self, rev): |
3956
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
296 self.modecache = {} |
3954
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
297 files = self.files[rev] |
3956
558f52943cd2
convert-repo: add CVS exec bit support
Matt Mackall <mpm@selenic.com>
parents:
3954
diff
changeset
|
298 cl = files.items() |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
299 cl.sort() |
5121
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
4810
diff
changeset
|
300 return (cl, {}) |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
301 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
302 def getcommit(self, rev): |
3954
9af4b853ed4d
convert-repo: add CVS branch support
Matt Mackall <mpm@selenic.com>
parents:
3953
diff
changeset
|
303 return self.changeset[rev] |
3953
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
304 |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
305 def gettags(self): |
fad134931327
convert-repo: add basic CVS import support
Matt Mackall <mpm@selenic.com>
parents:
3939
diff
changeset
|
306 return self.tags |
5381
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
307 |
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
308 def getchangedfiles(self, rev, i): |
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
309 files = self.files[rev].keys() |
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
310 files.sort() |
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
311 return files |
6874368120dc
convert_cvs: add --filemap support
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5308
diff
changeset
|
312 |