Mercurial > hg-stable
annotate hgext/convert/subversion.py @ 4810:c2d529f288a1
convert: move some code into common init function
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 05 Jul 2007 12:08:48 -0700 |
parents | 15a3cbfc6568 |
children | f7c8222920ee |
rev | line source |
---|---|
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
1 # Subversion 1.4/1.5 Python API backend |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
2 # |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
3 # Copyright(C) 2007 Daniel Holth et al |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
4 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
5 import pprint |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
6 import locale |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
7 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
8 from mercurial import util |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
9 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
10 # Subversion stuff. Works best with very recent Python SVN bindings |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
11 # e.g. SVN 1.5 or backports. Thanks to the bzr folks for enhancing |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
12 # these bindings. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
13 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
14 from cStringIO import StringIO |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
15 |
4766
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
16 from common import NoRepo, commit, converter_source |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
17 |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
18 try: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
19 from svn.core import SubversionException, Pool |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
20 import svn.core |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
21 import svn.ra |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
22 import svn.delta |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
23 import svn |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
24 import transport |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
25 except ImportError: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
26 pass |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
27 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
28 class CompatibilityException(Exception): pass |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
29 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
30 class svn_entry(object): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
31 """Emulate a Subversion path change.""" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
32 __slots__ = ['path', 'copyfrom_path', 'copyfrom_rev', 'action'] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
33 def __init__(self, entry): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
34 self.copyfrom_path = entry.copyfrom_path |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
35 self.copyfrom_rev = entry.copyfrom_rev |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
36 self.action = entry.action |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
37 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
38 def __str__(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
39 return "%s %s %s" % (self.action, self.copyfrom_path, self.copyfrom_rev) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
40 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
41 def __repr__(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
42 return self.__str__() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
43 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
44 class svn_paths(object): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
45 """Emulate a Subversion ordered dictionary of changed paths.""" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
46 __slots__ = ['values', 'order'] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
47 def __init__(self, orig_paths): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
48 self.order = [] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
49 self.values = {} |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
50 if hasattr(orig_paths, 'keys'): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
51 self.order = sorted(orig_paths.keys()) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
52 self.values.update(orig_paths) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
53 return |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
54 if not orig_paths: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
55 return |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
56 for path in orig_paths: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
57 self.order.append(path) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
58 self.values[path] = svn_entry(orig_paths[path]) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
59 self.order.sort() # maybe the order it came in isn't so great... |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
60 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
61 def __iter__(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
62 return iter(self.order) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
63 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
64 def __getitem__(self, key): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
65 return self.values[key] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
66 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
67 def __str__(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
68 s = "{\n" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
69 for path in self.order: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
70 s += "'%s': %s,\n" % (path, self.values[path]) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
71 s += "}" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
72 return s |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
73 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
74 def __repr__(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
75 return self.__str__() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
76 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
77 # SVN conversion code stolen from bzr-svn and tailor |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
78 class convert_svn(converter_source): |
4766
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
79 def __init__(self, ui, url, rev=None): |
4807
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4799
diff
changeset
|
80 super(convert_svn, self).__init__(ui, url, rev=rev) |
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4799
diff
changeset
|
81 |
4766
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
82 try: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
83 SubversionException |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
84 except NameError: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
85 msg = 'subversion python bindings could not be loaded\n' |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
86 ui.warn(msg) |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
87 raise NoRepo(msg) |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
88 |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
89 self.encoding = locale.getpreferredencoding() |
4766
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
90 latest = None |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
91 if rev: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
92 try: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
93 latest = int(rev) |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
94 except ValueError: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
95 raise util.Abort('svn: revision %s is not an integer' % rev) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
96 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
97 # Support file://path@rev syntax. Useful e.g. to convert |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
98 # deleted branches. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
99 url, latest = url.rsplit("@", 1) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
100 latest = int(latest) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
101 except ValueError, e: |
4766
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4765
diff
changeset
|
102 pass |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
103 self.url = url |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
104 self.encoding = 'UTF-8' # Subversion is always nominal UTF-8 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
105 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
106 self.transport = transport.SvnRaTransport(url = url) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
107 self.ra = self.transport.ra |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
108 self.ctx = svn.client.create_context() |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
109 self.base = svn.ra.get_repos_root(self.ra) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
110 self.module = self.url[len(self.base):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
111 self.modulemap = {} # revision, module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
112 self.commits = {} |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
113 self.files = {} |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
114 self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
115 except SubversionException, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
116 raise NoRepo("couldn't open SVN repo %s" % url) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
117 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
118 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
119 self.get_blacklist() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
120 except IOError, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
121 pass |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
122 |
4789
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
123 self.last_changed = self.latest(self.module, latest) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
124 |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
125 self.head = self.revid(self.last_changed) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
126 |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
127 def revid(self, revnum, module=None): |
4795
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
128 if not module: |
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
129 module = self.module |
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
130 return (u"svn:%s%s@%s" % (self.uuid, module, revnum)).decode(self.encoding) |
4774
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4773
diff
changeset
|
131 |
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4773
diff
changeset
|
132 def revnum(self, rev): |
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4773
diff
changeset
|
133 return int(rev.split('@')[-1]) |
4789
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
134 |
4794
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
135 def revsplit(self, rev): |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
136 url, revnum = rev.encode(self.encoding).split('@', 1) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
137 revnum = int(revnum) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
138 parts = url.split('/', 1) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
139 uuid = parts.pop(0)[4:] |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
140 mod = '' |
4794
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
141 if parts: |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
142 mod = '/' + parts[0] |
4794
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
143 return uuid, mod, revnum |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
144 |
4790
c2ef09a35c53
convert: typo in svn.latest
Brendan Cully <brendan@kublai.com>
parents:
4789
diff
changeset
|
145 def latest(self, path, stop=0): |
4789
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
146 'find the latest revision affecting path, up to stop' |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
147 if not stop: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
148 stop = svn.ra.get_latest_revnum(self.ra) |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
149 try: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
150 self.reparent('') |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
151 dirent = svn.ra.stat(self.ra, path.strip('/'), stop) |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
152 self.reparent(self.module) |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
153 except SubversionException: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
154 dirent = None |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
155 if not dirent: |
4791
772687e437e5
convert: another typo in svn.latest
Brendan Cully <brendan@kublai.com>
parents:
4790
diff
changeset
|
156 raise util.Abort('%s not found up to revision %d' \ |
772687e437e5
convert: another typo in svn.latest
Brendan Cully <brendan@kublai.com>
parents:
4790
diff
changeset
|
157 % (path, stop)) |
4789
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
158 |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
159 return dirent.created_rev |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4788
diff
changeset
|
160 |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
161 def get_blacklist(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
162 """Avoid certain revision numbers. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
163 It is not uncommon for two nearby revisions to cancel each other |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
164 out, e.g. 'I copied trunk into a subdirectory of itself instead |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
165 of making a branch'. The converted repository is significantly |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
166 smaller if we ignore such revisions.""" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
167 self.blacklist = set() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
168 blacklist = self.blacklist |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
169 for line in file("blacklist.txt", "r"): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
170 if not line.startswith("#"): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
171 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
172 svn_rev = int(line.strip()) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
173 blacklist.add(svn_rev) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
174 except ValueError, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
175 pass # not an integer or a comment |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
176 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
177 def is_blacklisted(self, svn_rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
178 return svn_rev in self.blacklist |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
179 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
180 def reparent(self, module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
181 svn_url = self.base + module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
182 self.ui.debug("reparent to %s\n" % svn_url.encode(self.encoding)) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
183 svn.ra.reparent(self.ra, svn_url.encode(self.encoding)) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
184 |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
185 def _fetch_revisions(self, from_revnum = 0, to_revnum = 347): |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
186 def get_entry_from_path(path, module=self.module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
187 # Given the repository url of this wc, say |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
188 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
189 # extract the "entry" portion (a relative path) from what |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
190 # svn log --xml says, ie |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
191 # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
192 # that is to say "tests/PloneTestCase.py" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
193 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
194 if path.startswith(module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
195 relative = path[len(module):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
196 if relative.startswith('/'): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
197 return relative[1:] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
198 else: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
199 return relative |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
200 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
201 # The path is outside our tracked tree... |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
202 self.ui.debug('Ignoring %r since it is not under %r\n' % (path, module)) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
203 return None |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
204 |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
205 self.child_cset = None |
4793
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
206 def parselogentry(*arg, **args): |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
207 orig_paths, revnum, author, date, message, pool = arg |
4793
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
208 orig_paths = svn_paths(orig_paths) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
209 |
4793
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
210 if self.is_blacklisted(revnum): |
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
211 self.ui.note('skipping blacklisted revision %d\n' % revnum) |
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
212 return |
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
213 |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
214 self.ui.debug("parsing revision %d\n" % revnum) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
215 |
4792
2b5723a5b186
convert: svn: move some debug output to verbose
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
216 if orig_paths is None: |
4793
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
217 self.ui.debug('revision %d has no entries\n' % revnum) |
4792
2b5723a5b186
convert: svn: move some debug output to verbose
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
218 return |
2b5723a5b186
convert: svn: move some debug output to verbose
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
219 |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
220 if revnum in self.modulemap: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
221 new_module = self.modulemap[revnum] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
222 if new_module != self.module: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
223 self.module = new_module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
224 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
225 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
226 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
227 copies = {} |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
228 entries = [] |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
229 rev = self.revid(revnum) |
4795
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
230 parents = [] |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
231 try: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
232 branch = self.module.split("/")[-1] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
233 if branch == 'trunk': |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
234 branch = '' |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
235 except IndexError: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
236 branch = None |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
237 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
238 for path in orig_paths: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
239 # self.ui.write("path %s\n" % path) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
240 if path == self.module: # Follow branching back in history |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
241 ent = orig_paths[path] |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
242 if ent: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
243 if ent.copyfrom_path: |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
244 # ent.copyfrom_rev may not be the actual last revision |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
245 prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
246 self.modulemap[prev] = ent.copyfrom_path |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
247 parents = [self.revid(prev, ent.copyfrom_path)] |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
248 self.ui.note('found parent of branch %s at %d: %s\n' % \ |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
249 (self.module, prev, ent.copyfrom_path)) |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
250 else: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
251 self.ui.debug("No copyfrom path, don't know what to do.\n") |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
252 # Maybe it was added and there is no more history. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
253 entrypath = get_entry_from_path(path, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
254 # self.ui.write("entrypath %s\n" % entrypath) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
255 if entrypath is None: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
256 # Outside our area of interest |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
257 self.ui.debug("boring@%s: %s\n" % (revnum, path)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
258 continue |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
259 entry = entrypath.decode(self.encoding) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
260 ent = orig_paths[path] |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
261 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
262 kind = svn.ra.check_path(self.ra, entrypath, revnum) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
263 if kind == svn.core.svn_node_file: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
264 if ent.copyfrom_path: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
265 copyfrom_path = get_entry_from_path(ent.copyfrom_path) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
266 if copyfrom_path: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
267 self.ui.debug("Copied to %s from %s@%s\n" % (entry, copyfrom_path, ent.copyfrom_rev)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
268 # It's probably important for hg that the source |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
269 # exists in the revision's parent, not just the |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
270 # ent.copyfrom_rev |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
271 fromkind = svn.ra.check_path(self.ra, copyfrom_path, ent.copyfrom_rev) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
272 if fromkind != 0: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
273 copies[self.recode(entry)] = self.recode(copyfrom_path) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
274 entries.append(self.recode(entry)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
275 elif kind == 0: # gone, but had better be a deleted *file* |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
276 self.ui.debug("gone from %s\n" % ent.copyfrom_rev) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
277 |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
278 # if a branch is created but entries are removed in the same |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
279 # changeset, get the right fromrev |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
280 if parents: |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
281 uuid, old_module, fromrev = self.revsplit(parents[0]) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
282 else: |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
283 fromrev = revnum - 1 |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
284 # might always need to be revnum - 1 in these 3 lines? |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
285 old_module = self.modulemap.get(fromrev, self.module) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
286 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
287 basepath = old_module + "/" + get_entry_from_path(path, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
288 entrypath = old_module + "/" + get_entry_from_path(path, module=self.module) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
289 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
290 def lookup_parts(p): |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
291 rc = None |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
292 parts = p.split("/") |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
293 for i in range(len(parts)): |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
294 part = "/".join(parts[:i]) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
295 info = part, copyfrom.get(part, None) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
296 if info[1] is not None: |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
297 self.ui.debug("Found parent directory %s\n" % info[1]) |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
298 rc = info |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
299 return rc |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
300 |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
301 self.ui.debug("base, entry %s %s\n" % (basepath, entrypath)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
302 |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
303 frompath, froment = lookup_parts(entrypath) or (None, revnum - 1) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
304 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
305 # need to remove fragment from lookup_parts and replace with copyfrom_path |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
306 if frompath is not None: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
307 self.ui.debug("munge-o-matic\n") |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
308 self.ui.debug(entrypath + '\n') |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
309 self.ui.debug(entrypath[len(frompath):] + '\n') |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
310 entrypath = froment.copyfrom_path + entrypath[len(frompath):] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
311 fromrev = froment.copyfrom_rev |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
312 self.ui.debug("Info: %s %s %s %s\n" % (frompath, froment, ent, entrypath)) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
313 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
314 fromkind = svn.ra.check_path(self.ra, entrypath, fromrev) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
315 if fromkind == svn.core.svn_node_file: # a deleted file |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
316 entries.append(self.recode(entry)) |
4798
83c1bbb934ec
convert: svn merges produce hard-to-trace file entries. Ignore them for now.
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
317 elif fromkind == svn.core.svn_node_dir: |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
318 # print "Deleted/moved non-file:", revnum, path, ent |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
319 # children = self._find_children(path, revnum - 1) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
320 # print "find children %s@%d from %d action %s" % (path, revnum, ent.copyfrom_rev, ent.action) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
321 # Sometimes this is tricky. For example: in |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
322 # The Subversion Repository revision 6940 a dir |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
323 # was copied and one of its files was deleted |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
324 # from the new location in the same commit. This |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
325 # code can't deal with that yet. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
326 if ent.action == 'C': |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
327 children = self._find_children(path, fromrev) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
328 else: |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
329 oroot = entrypath.strip('/') |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
330 nroot = path.strip('/') |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
331 children = self._find_children(oroot, fromrev) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
332 children = [s.replace(oroot,nroot) for s in children] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
333 # Mark all [files, not directories] as deleted. |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
334 for child in children: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
335 # Can we move a child directory and its |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
336 # parent in the same commit? (probably can). Could |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
337 # cause problems if instead of revnum -1, |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
338 # we have to look in (copyfrom_path, revnum - 1) |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
339 entrypath = get_entry_from_path("/" + child, module=old_module) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
340 if entrypath: |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
341 entry = self.recode(entrypath.decode(self.encoding)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
342 if entry in copies: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
343 # deleted file within a copy |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
344 del copies[entry] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
345 else: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
346 entries.append(entry) |
4798
83c1bbb934ec
convert: svn merges produce hard-to-trace file entries. Ignore them for now.
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
347 else: |
83c1bbb934ec
convert: svn merges produce hard-to-trace file entries. Ignore them for now.
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
348 self.ui.debug('unknown path in revision %d: %s\n' % \ |
83c1bbb934ec
convert: svn merges produce hard-to-trace file entries. Ignore them for now.
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
349 (revnum, path)) |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
350 elif kind == svn.core.svn_node_dir: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
351 # Should probably synthesize normal file entries |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
352 # and handle as above to clean up copy/rename handling. |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
353 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
354 # If the directory just had a prop change, |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
355 # then we shouldn't need to look for its children. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
356 # Also this could create duplicate entries. Not sure |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
357 # whether this will matter. Maybe should make entries a set. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
358 # print "Changed directory", revnum, path, ent.action, ent.copyfrom_path, ent.copyfrom_rev |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
359 # This will fail if a directory was copied |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
360 # from another branch and then some of its files |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
361 # were deleted in the same transaction. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
362 children = self._find_children(path, revnum) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
363 children.sort() |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
364 for child in children: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
365 # Can we move a child directory and its |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
366 # parent in the same commit? (probably can). Could |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
367 # cause problems if instead of revnum -1, |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
368 # we have to look in (copyfrom_path, revnum - 1) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
369 entrypath = get_entry_from_path("/" + child, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
370 # print child, self.module, entrypath |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
371 if entrypath: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
372 # Need to filter out directories here... |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
373 kind = svn.ra.check_path(self.ra, entrypath, revnum) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
374 if kind != svn.core.svn_node_dir: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
375 entries.append(self.recode(entrypath)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
376 |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
377 # Copies here (must copy all from source) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
378 # Probably not a real problem for us if |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
379 # source does not exist |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
380 |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
381 # Can do this with the copy command "hg copy" |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
382 # if ent.copyfrom_path: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
383 # copyfrom_entry = get_entry_from_path(ent.copyfrom_path.decode(self.encoding), |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
384 # module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
385 # copyto_entry = entrypath |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
386 # |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
387 # print "copy directory", copyfrom_entry, 'to', copyto_entry |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
388 # |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
389 # copies.append((copyfrom_entry, copyto_entry)) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
390 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
391 if ent.copyfrom_path: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
392 copyfrom_path = ent.copyfrom_path.decode(self.encoding) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
393 copyfrom_entry = get_entry_from_path(copyfrom_path, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
394 if copyfrom_entry: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
395 copyfrom[path] = ent |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
396 self.ui.debug("mark %s came from %s\n" % (path, copyfrom[path])) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
397 |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
398 # Good, /probably/ a regular copy. Really should check |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
399 # to see whether the parent revision actually contains |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
400 # the directory in question. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
401 children = self._find_children(self.recode(copyfrom_path), ent.copyfrom_rev) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
402 children.sort() |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
403 for child in children: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
404 entrypath = get_entry_from_path("/" + child, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
405 if entrypath: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
406 entry = entrypath.decode(self.encoding) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
407 # print "COPY COPY From", copyfrom_entry, entry |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
408 copyto_path = path + entry[len(copyfrom_entry):] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
409 copyto_entry = get_entry_from_path(copyto_path, module=self.module) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
410 # print "COPY", entry, "COPY To", copyto_entry |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
411 copies[self.recode(copyto_entry)] = self.recode(entry) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
412 # copy from quux splort/quuxfile |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
413 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
414 self.modulemap[revnum] = self.module # track backwards in time |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
415 # a list of (filename, id) where id lets us retrieve the file. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
416 # eg in git, id is the object hash. for svn it'll be the |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
417 self.files[rev] = zip(entries, [rev] * len(entries)) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
418 if not entries: |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
419 return |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
420 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
421 # Example SVN datetime. Includes microseconds. |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
422 # ISO-8601 conformant |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
423 # '2007-01-04T17:35:00.902377Z' |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
424 date = util.parsedate(date[:18] + " UTC", ["%Y-%m-%dT%H:%M:%S"]) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
425 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
426 log = message and self.recode(message) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
427 author = author and self.recode(author) or '' |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
428 |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
429 cset = commit(author=author, |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
430 date=util.datestr(date), |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
431 desc=log, |
4795
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
432 parents=parents, |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
433 copies=copies, |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
434 branch=branch) |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
435 |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
436 self.commits[rev] = cset |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
437 if self.child_cset and not self.child_cset.parents: |
4788
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
438 self.child_cset.parents = [rev] |
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
439 self.child_cset = cset |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
440 |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
441 self.ui.note('fetching revision log for "%s" from %d to %d\n' % \ |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
442 (self.module, from_revnum, to_revnum)) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
443 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
444 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
445 discover_changed_paths = True |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
446 strict_node_history = False |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
447 svn.ra.get_log(self.ra, [self.module], from_revnum, to_revnum, 0, |
4793
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
448 discover_changed_paths, strict_node_history, |
9f20f4b205ba
convert: svn: parse log entries as they arrive instead of deferring it
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
449 parselogentry) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
450 self.last_revnum = to_revnum |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
451 except SubversionException, (_, num): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
452 if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
453 raise NoSuchRevision(branch=self, |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
454 revision="Revision number %d" % to_revnum) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
455 raise |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
456 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
457 def getheads(self): |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
458 # detect standard /branches, /tags, /trunk layout |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
459 optrev = svn.core.svn_opt_revision_t() |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
460 optrev.kind = svn.core.svn_opt_revision_number |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
461 optrev.value.number = self.last_changed |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
462 rpath = self.url.strip('/') |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
463 paths = svn.client.ls(rpath, optrev, False, self.ctx) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
464 if 'branches' in paths and 'trunk' in paths: |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
465 self.module += '/trunk' |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
466 lt = self.latest(self.module, self.last_changed) |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
467 self.head = self.revid(lt) |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
468 self.heads = [self.head] |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
469 branches = svn.client.ls(rpath + '/branches', optrev, False, self.ctx) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
470 for branch in branches.keys(): |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
471 module = '/branches/' + branch |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
472 brevnum = self.latest(module, self.last_changed) |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
473 brev = self.revid(brevnum, module) |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
474 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
475 self.heads.append(brev) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
476 else: |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
477 self.heads = [self.head] |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
478 return self.heads |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
479 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
480 def _getfile(self, file, rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
481 io = StringIO() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
482 # TODO: ra.get_file transmits the whole file instead of diffs. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
483 mode = '' |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
484 try: |
4774
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4773
diff
changeset
|
485 revnum = self.revnum(rev) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
486 if self.module != self.modulemap[revnum]: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
487 self.module = self.modulemap[revnum] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
488 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
489 info = svn.ra.get_file(self.ra, file, revnum, io) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
490 if isinstance(info, list): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
491 info = info[-1] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
492 mode = ("svn:executable" in info) and 'x' or '' |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
493 mode = ("svn:special" in info) and 'l' or mode |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
494 except SubversionException, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
495 notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
496 svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
497 if e.apr_err in notfound: # File not found |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
498 raise IOError() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
499 raise |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
500 data = io.getvalue() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
501 if mode == 'l': |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
502 link_prefix = "link " |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
503 if data.startswith(link_prefix): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
504 data = data[len(link_prefix):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
505 return data, mode |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
506 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
507 def getfile(self, file, rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
508 data, mode = self._getfile(file, rev) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
509 self.modecache[(file, rev)] = mode |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
510 return data |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
511 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
512 def getmode(self, file, rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
513 return self.modecache[(file, rev)] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
514 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
515 def getchanges(self, rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
516 self.modecache = {} |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
517 files = self.files[rev] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
518 cl = files |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
519 cl.sort() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
520 return cl |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
521 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
522 def getcommit(self, rev): |
4772
69548a9d9796
convert: fetch svn changes on demand (in batches)
Brendan Cully <brendan@kublai.com>
parents:
4771
diff
changeset
|
523 if rev not in self.commits: |
4794
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
524 uuid, module, revnum = self.revsplit(rev) |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
525 self.module = module |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
526 self.reparent(module) |
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
527 self._fetch_revisions(from_revnum=revnum, to_revnum=0) |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
528 return self.commits[rev] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
529 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
530 def gettags(self): |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
531 tags = {} |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
532 def parselogentry(*arg, **args): |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
533 orig_paths, revnum, author, date, message, pool = arg |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
534 orig_paths = svn_paths(orig_paths) |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
535 for path in orig_paths: |
4799
d00ca99bc54e
convert svn: minor improvement to tag detection.
Brendan Cully <brendan@kublai.com>
parents:
4798
diff
changeset
|
536 if not path.startswith('/tags/'): |
d00ca99bc54e
convert svn: minor improvement to tag detection.
Brendan Cully <brendan@kublai.com>
parents:
4798
diff
changeset
|
537 continue |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
538 ent = orig_paths[path] |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
539 source = ent.copyfrom_path |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
540 rev = ent.copyfrom_rev |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
541 tag = path.split('/', 2)[2] |
4810
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4807
diff
changeset
|
542 tags[tag] = self.revid(rev, module=source) |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
543 |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
544 start = self.revnum(self.head) |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
545 try: |
4799
d00ca99bc54e
convert svn: minor improvement to tag detection.
Brendan Cully <brendan@kublai.com>
parents:
4798
diff
changeset
|
546 svn.ra.get_log(self.ra, ['/tags'], 0, start, 0, True, False, |
4796
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
547 parselogentry) |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
548 return tags |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
549 except SubversionException: |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
550 self.ui.note('no tags found at revision %d\n' % start) |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4795
diff
changeset
|
551 return {} |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
552 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
553 def _find_children(self, path, revnum): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
554 path = path.strip("/") |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
555 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
556 def _find_children_fallback(path, revnum): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
557 # SWIG python bindings for getdir are broken up to at least 1.4.3 |
4787
a67f185d0474
convert: svn: use a separate mempool for each ls in the 1.4 fallback path
Brendan Cully <brendan@kublai.com>
parents:
4776
diff
changeset
|
558 pool = Pool() |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
559 optrev = svn.core.svn_opt_revision_t() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
560 optrev.kind = svn.core.svn_opt_revision_number |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
561 optrev.value.number = revnum |
4770
4526ef8c47b2
convert: svn: fix fallback directory listing code when importing a submodule
Brendan Cully <brendan@kublai.com>
parents:
4769
diff
changeset
|
562 rpath = '/'.join([self.base, path]).strip('/') |
4797
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4796
diff
changeset
|
563 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev, True, self.ctx, pool).keys()] |
4765
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
564 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
565 if hasattr(self, '_find_children_fallback'): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
566 return _find_children_fallback(path, revnum) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
567 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
568 self.reparent("/" + path) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
569 pool = Pool() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
570 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
571 children = [] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
572 def find_children_inner(children, path, revnum = revnum): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
573 if hasattr(svn.ra, 'get_dir2'): # Since SVN 1.4 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
574 fields = 0xffffffff # Binding does not provide SVN_DIRENT_ALL |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
575 getdir = svn.ra.get_dir2(self.ra, path, revnum, fields, pool) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
576 else: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
577 getdir = svn.ra.get_dir(self.ra, path, revnum, pool) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
578 if type(getdir) == dict: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
579 # python binding for getdir is broken up to at least 1.4.3 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
580 raise CompatibilityException() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
581 dirents = getdir[0] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
582 if type(dirents) == int: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
583 # got here once due to infinite recursion bug |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
584 # pprint.pprint(getdir) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
585 return |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
586 c = dirents.keys() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
587 c.sort() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
588 for child in c: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
589 dirent = dirents[child] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
590 if dirent.kind == svn.core.svn_node_dir: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
591 find_children_inner(children, (path + "/" + child).strip("/")) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
592 else: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
593 children.append((path + "/" + child).strip("/")) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
594 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
595 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
596 find_children_inner(children, "") |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
597 except CompatibilityException: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
598 self._find_children_fallback = True |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
599 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
600 return _find_children_fallback(path, revnum) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
601 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
602 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
603 return [path + "/" + c for c in children] |