Mercurial > hg > mercurial-crew-with-dirclash
annotate hgext/convert/subversion.py @ 5251:37c610c41ed6
Test svn repository conversion
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 27 Aug 2007 22:17:51 +0200 |
parents | 585471802a01 |
children | 694eb9ccb54d |
rev | line source |
---|---|
4758
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 |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
4 # |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
5 # Configuration options: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
6 # |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
7 # convert.svn.trunk |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
8 # Relative path to the trunk (default: "trunk") |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
9 # convert.svn.branches |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
10 # Relative path to tree of branches (default: "branches") |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
11 # |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
12 # Set these in a hgrc, or on the command line as follows: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
13 # |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
14 # hg convert --config convert.svn.trunk=wackoname [...] |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
15 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
16 import locale |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
17 import os |
5112
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
18 import sys |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
19 import cPickle as pickle |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
20 from mercurial import util |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
21 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
22 # Subversion stuff. Works best with very recent Python SVN bindings |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
23 # 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
|
24 # these bindings. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
25 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
26 from cStringIO import StringIO |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
27 |
5112
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
28 from common import NoRepo, commit, converter_source, encodeargs, decodeargs |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
29 |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
30 try: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
31 from svn.core import SubversionException, Pool |
5010
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
32 import svn |
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
33 import svn.client |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
34 import svn.core |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
35 import svn.ra |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
36 import svn.delta |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
37 import transport |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
38 except ImportError: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
39 pass |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
40 |
4998
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
41 def geturl(path): |
5010
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
42 try: |
5020
780051cca03c
convert svn: canonicalize path before calling url_from_path.
Brendan Cully <brendan@kublai.com>
parents:
5010
diff
changeset
|
43 return svn.client.url_from_path(svn.core.svn_path_canonicalize(path)) |
5010
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
44 except SubversionException: |
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
45 pass |
4998
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
46 if os.path.isdir(path): |
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
47 return 'file://%s' % os.path.normpath(os.path.abspath(path)) |
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
48 return path |
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
49 |
5072
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
50 def optrev(number): |
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
51 optrev = svn.core.svn_opt_revision_t() |
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
52 optrev.kind = svn.core.svn_opt_revision_number |
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
53 optrev.value.number = number |
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
54 return optrev |
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
55 |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
56 class changedpath(object): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
57 def __init__(self, p): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
58 self.copyfrom_path = p.copyfrom_path |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
59 self.copyfrom_rev = p.copyfrom_rev |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
60 self.action = p.action |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
61 |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
62 def get_log_child(fp, url, paths, start, end, limit=0, discover_changed_paths=True, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
63 strict_node_history=False): |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
64 protocol = -1 |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
65 def receiver(orig_paths, revnum, author, date, message, pool): |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
66 if orig_paths is not None: |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
67 for k, v in orig_paths.iteritems(): |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
68 orig_paths[k] = changedpath(v) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
69 pickle.dump((orig_paths, revnum, author, date, message), |
5117
d4fa6bafc43a
Remove trailing spaces, fix indentation
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5114
diff
changeset
|
70 fp, protocol) |
d4fa6bafc43a
Remove trailing spaces, fix indentation
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5114
diff
changeset
|
71 |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
72 try: |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
73 # Use an ra of our own so that our parent can consume |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
74 # our results without confusing the server. |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
75 t = transport.SvnRaTransport(url=url) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
76 svn.ra.get_log(t.ra, paths, start, end, limit, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
77 discover_changed_paths, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
78 strict_node_history, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
79 receiver) |
5113
792c1d979097
Replace _ with inst for catching exceptions to not shadow gettext.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5112
diff
changeset
|
80 except SubversionException, (inst, num): |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
81 pickle.dump(num, fp, protocol) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
82 else: |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
83 pickle.dump(None, fp, protocol) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
84 fp.close() |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
85 |
5112
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
86 def debugsvnlog(ui, **opts): |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
87 """Fetch SVN log in a subprocess and channel them back to parent to |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
88 avoid memory collection issues. |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
89 """ |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
90 util.set_binary(sys.stdin) |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
91 util.set_binary(sys.stdout) |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
92 args = decodeargs(sys.stdin.read()) |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
93 get_log_child(sys.stdout, *args) |
18abf13064cb
Move debugsvnlog to subversion module.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5111
diff
changeset
|
94 |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
95 # SVN conversion code stolen from bzr-svn and tailor |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
96 class convert_svn(converter_source): |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
97 def __init__(self, ui, url, rev=None): |
4806
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
98 super(convert_svn, self).__init__(ui, url, rev=rev) |
15a3cbfc6568
convert: call superclass init from engine init functions
Brendan Cully <brendan@kublai.com>
parents:
4797
diff
changeset
|
99 |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
100 try: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
101 SubversionException |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
102 except NameError: |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
103 msg = 'subversion python bindings could not be loaded\n' |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
104 ui.warn(msg) |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
105 raise NoRepo(msg) |
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
106 |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
107 self.encoding = locale.getpreferredencoding() |
4812
1fcdf2fe3d7c
convert: svn: use revmap to parse only new revisions in incremental conversions
Brendan Cully <brendan@kublai.com>
parents:
4810
diff
changeset
|
108 self.lastrevs = {} |
1fcdf2fe3d7c
convert: svn: use revmap to parse only new revisions in incremental conversions
Brendan Cully <brendan@kublai.com>
parents:
4810
diff
changeset
|
109 |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
110 latest = None |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
111 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
112 # Support file://path@rev syntax. Useful e.g. to convert |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
113 # deleted branches. |
4908
5e89b0dafce5
convert/subversion.py: str.rsplit is not available in Python 2.3
Bryan O'Sullivan <bos@serpentine.com>
parents:
4906
diff
changeset
|
114 at = url.rfind('@') |
5e89b0dafce5
convert/subversion.py: str.rsplit is not available in Python 2.3
Bryan O'Sullivan <bos@serpentine.com>
parents:
4906
diff
changeset
|
115 if at >= 0: |
5e89b0dafce5
convert/subversion.py: str.rsplit is not available in Python 2.3
Bryan O'Sullivan <bos@serpentine.com>
parents:
4906
diff
changeset
|
116 latest = int(url[at+1:]) |
5e89b0dafce5
convert/subversion.py: str.rsplit is not available in Python 2.3
Bryan O'Sullivan <bos@serpentine.com>
parents:
4906
diff
changeset
|
117 url = url[:at] |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
118 except ValueError, e: |
4759
95cbb6b74790
convert: activate subversion engine
Brendan Cully <brendan@kublai.com>
parents:
4758
diff
changeset
|
119 pass |
4998
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
120 self.url = geturl(url) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
121 self.encoding = 'UTF-8' # Subversion is always nominal UTF-8 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
122 try: |
4998
b6c3abdbe0eb
convert: urlify svn repos if necessary.
Brendan Cully <brendan@kublai.com>
parents:
4942
diff
changeset
|
123 self.transport = transport.SvnRaTransport(url=self.url) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
124 self.ra = self.transport.ra |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
125 self.ctx = self.transport.client |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
126 self.base = svn.ra.get_repos_root(self.ra) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
127 self.module = self.url[len(self.base):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
128 self.modulemap = {} # revision, module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
129 self.commits = {} |
5076
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
130 self.paths = {} |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
131 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
|
132 except SubversionException, e: |
5010
6b2d8caf87b2
convert svn: try to extract URL from source if it is a working directory
Brendan Cully <brendan@kublai.com>
parents:
4998
diff
changeset
|
133 raise NoRepo("couldn't open SVN repo %s" % self.url) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
134 |
5119
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
135 if rev: |
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
136 try: |
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
137 latest = int(rev) |
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
138 except ValueError: |
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
139 raise util.Abort('svn: revision %s is not an integer' % rev) |
0751c25ea0c0
raise util.Abort again if specified revision is not an integer.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5118
diff
changeset
|
140 |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
141 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
142 self.get_blacklist() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
143 except IOError, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
144 pass |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
145 |
4787
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
146 self.last_changed = self.latest(self.module, latest) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
147 |
4809
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4806
diff
changeset
|
148 self.head = self.revid(self.last_changed) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
149 |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
150 def setrevmap(self, revmap): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
151 lastrevs = {} |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
152 for revid in revmap.keys(): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
153 uuid, module, revnum = self.revsplit(revid) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
154 lastrevnum = lastrevs.setdefault(module, revnum) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
155 if revnum > lastrevnum: |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
156 lastrevs[module] = revnum |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
157 self.lastrevs = lastrevs |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
158 |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
159 def exists(self, path, optrev): |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
160 try: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
161 return svn.client.ls(self.url.rstrip('/') + '/' + path, |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
162 optrev, False, self.ctx) |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
163 except SubversionException, err: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
164 return [] |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
165 |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
166 def getheads(self): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
167 # detect standard /branches, /tags, /trunk layout |
5072
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
168 rev = optrev(self.last_changed) |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
169 rpath = self.url.strip('/') |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
170 cfgtrunk = self.ui.config('convert', 'svn.trunk') |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
171 cfgbranches = self.ui.config('convert', 'svn.branches') |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
172 trunk = (cfgtrunk or 'trunk').strip('/') |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
173 branches = (cfgbranches or 'branches').strip('/') |
5072
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
174 if self.exists(trunk, rev) and self.exists(branches, rev): |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
175 self.ui.note('found trunk at %r and branches at %r\n' % |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
176 (trunk, branches)) |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
177 oldmodule = self.module |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
178 self.module += '/' + trunk |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
179 lt = self.latest(self.module, self.last_changed) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
180 self.head = self.revid(lt) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
181 self.heads = [self.head] |
5072
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
182 branchnames = svn.client.ls(rpath + '/' + branches, rev, False, |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
183 self.ctx) |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
184 for branch in branchnames.keys(): |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
185 if oldmodule: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
186 module = '/' + oldmodule + '/' + branches + '/' + branch |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
187 else: |
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
188 module = '/' + branches + '/' + branch |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
189 brevnum = self.latest(module, self.last_changed) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
190 brev = self.revid(brevnum, module) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
191 self.ui.note('found branch %s at %d\n' % (branch, brevnum)) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
192 self.heads.append(brev) |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
193 elif cfgtrunk or cfgbranches: |
5113
792c1d979097
Replace _ with inst for catching exceptions to not shadow gettext.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5112
diff
changeset
|
194 raise util.Abort('trunk/branch layout expected, but not found') |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
195 else: |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
196 self.ui.note('working with one branch\n') |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
197 self.heads = [self.head] |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
198 return self.heads |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
199 |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
200 def getfile(self, file, rev): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
201 data, mode = self._getfile(file, rev) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
202 self.modecache[(file, rev)] = mode |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
203 return data |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
204 |
4939
cdd33a048289
removed trailing whitespace
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4931
diff
changeset
|
205 def getmode(self, file, rev): |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
206 return self.modecache[(file, rev)] |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
207 |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
208 def getchanges(self, rev): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
209 self.modecache = {} |
5076
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
210 (paths, parents) = self.paths[rev] |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
211 files, copies = self.expandpaths(rev, paths, parents) |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
212 files.sort() |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
213 files = zip(files, [rev] * len(files)) |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
214 |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
215 # caller caches the result, so free it here to release memory |
5076
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
216 del self.paths[rev] |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
217 return (files, copies) |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
218 |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
219 def getcommit(self, rev): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
220 if rev not in self.commits: |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
221 uuid, module, revnum = self.revsplit(rev) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
222 self.module = module |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
223 self.reparent(module) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
224 stop = self.lastrevs.get(module, 0) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
225 self._fetch_revisions(from_revnum=revnum, to_revnum=stop) |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
226 commit = self.commits[rev] |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
227 # caller caches the result, so free it here to release memory |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
228 del self.commits[rev] |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
229 return commit |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
230 |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
231 def get_log(self, paths, start, end, limit=0, discover_changed_paths=True, |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
232 strict_node_history=False): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
233 |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
234 def parent(fp): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
235 while True: |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
236 entry = pickle.load(fp) |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
237 try: |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
238 orig_paths, revnum, author, date, message = entry |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
239 except: |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
240 if entry is None: |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
241 break |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
242 raise SubversionException("child raised exception", entry) |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
243 yield entry |
5117
d4fa6bafc43a
Remove trailing spaces, fix indentation
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5114
diff
changeset
|
244 |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
245 args = [self.url, paths, start, end, limit, discover_changed_paths, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
246 strict_node_history] |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
247 arg = encodeargs(args) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
248 hgexe = util.hgexecutable() |
5118
07735e2d24cb
debugsvnlog call had too many quotes (found by Edouard Gomez)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5117
diff
changeset
|
249 cmd = '%s debugsvnlog' % util.shellquote(hgexe) |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
250 stdin, stdout = os.popen2(cmd, 'b') |
5117
d4fa6bafc43a
Remove trailing spaces, fix indentation
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5114
diff
changeset
|
251 |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
252 stdin.write(arg) |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
253 stdin.close() |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
254 |
5100
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
255 for p in parent(stdout): |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5077
diff
changeset
|
256 yield p |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
257 |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
258 def gettags(self): |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
259 tags = {} |
4931
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
260 start = self.revnum(self.head) |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
261 try: |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
262 for entry in self.get_log(['/tags'], 0, start): |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
263 orig_paths, revnum, author, date, message = entry |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
264 for path in orig_paths: |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
265 if not path.startswith('/tags/'): |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
266 continue |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
267 ent = orig_paths[path] |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
268 source = ent.copyfrom_path |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
269 rev = ent.copyfrom_rev |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
270 tag = path.split('/', 2)[2] |
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
271 tags[tag] = self.revid(rev, module=source) |
5113
792c1d979097
Replace _ with inst for catching exceptions to not shadow gettext.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5112
diff
changeset
|
272 except SubversionException, (inst, num): |
4931
2f0f9528e77b
convert/subversion: rehandle the no-tags case
Bryan O'Sullivan <bos@serpentine.com>
parents:
4928
diff
changeset
|
273 self.ui.note('no tags found at revision %d\n' % start) |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
274 return tags |
4825
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
275 |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
276 # -- helper functions -- |
a265fe42abe7
convert: svn code movement (no actual changes)
Brendan Cully <brendan@kublai.com>
parents:
4824
diff
changeset
|
277 |
4809
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4806
diff
changeset
|
278 def revid(self, revnum, module=None): |
4793
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
279 if not module: |
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
280 module = self.module |
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
281 return (u"svn:%s%s@%s" % (self.uuid, module, revnum)).decode(self.encoding) |
4767
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4766
diff
changeset
|
282 |
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4766
diff
changeset
|
283 def revnum(self, rev): |
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4766
diff
changeset
|
284 return int(rev.split('@')[-1]) |
4787
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
285 |
4792
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
286 def revsplit(self, rev): |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
287 url, revnum = rev.encode(self.encoding).split('@', 1) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
288 revnum = int(revnum) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
289 parts = url.split('/', 1) |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
290 uuid = parts.pop(0)[4:] |
4795
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
291 mod = '' |
4792
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
292 if parts: |
4795
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
293 mod = '/' + parts[0] |
4792
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
294 return uuid, mod, revnum |
1f10a6cccdb5
convert: add optional module argument to svn._fetch_revisions
Brendan Cully <brendan@kublai.com>
parents:
4791
diff
changeset
|
295 |
4788
c2ef09a35c53
convert: typo in svn.latest
Brendan Cully <brendan@kublai.com>
parents:
4787
diff
changeset
|
296 def latest(self, path, stop=0): |
4787
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
297 '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:
4786
diff
changeset
|
298 if not stop: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
299 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:
4786
diff
changeset
|
300 try: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
301 self.reparent('') |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
302 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:
4786
diff
changeset
|
303 self.reparent(self.module) |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
304 except SubversionException: |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
305 dirent = None |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
306 if not dirent: |
4906
2642726b61b6
convert/subversion.py: fix bad assumptions about SVN path naming
Bryan O'Sullivan <bos@serpentine.com>
parents:
4873
diff
changeset
|
307 raise util.Abort('%s not found up to revision %d' % (path, stop)) |
4787
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
308 |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
309 return dirent.created_rev |
c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Brendan Cully <brendan@kublai.com>
parents:
4786
diff
changeset
|
310 |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
311 def get_blacklist(self): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
312 """Avoid certain revision numbers. |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
313 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
|
314 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
|
315 of making a branch'. The converted repository is significantly |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
316 smaller if we ignore such revisions.""" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
317 self.blacklist = set() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
318 blacklist = self.blacklist |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
319 for line in file("blacklist.txt", "r"): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
320 if not line.startswith("#"): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
321 try: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
322 svn_rev = int(line.strip()) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
323 blacklist.add(svn_rev) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
324 except ValueError, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
325 pass # not an integer or a comment |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
326 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
327 def is_blacklisted(self, svn_rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
328 return svn_rev in self.blacklist |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
329 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
330 def reparent(self, module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
331 svn_url = self.base + module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
332 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
|
333 svn.ra.reparent(self.ra, svn_url.encode(self.encoding)) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
334 |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
335 def expandpaths(self, rev, paths, parents): |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
336 def get_entry_from_path(path, module=self.module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
337 # Given the repository url of this wc, say |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
338 # "http://server/plone/CMFPlone/branches/Plone-2_0-branch" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
339 # extract the "entry" portion (a relative path) from what |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
340 # svn log --xml says, ie |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
341 # "/CMFPlone/branches/Plone-2_0-branch/tests/PloneTestCase.py" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
342 # that is to say "tests/PloneTestCase.py" |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
343 if path.startswith(module): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
344 relative = path[len(module):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
345 if relative.startswith('/'): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
346 return relative[1:] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
347 else: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
348 return relative |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
349 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
350 # The path is outside our tracked tree... |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
351 self.ui.debug('%r is not under %r, ignoring\n' % (path, module)) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
352 return None |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
353 |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
354 entries = [] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
355 copyfrom = {} # Map of entrypath, revision for finding source of deleted revisions. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
356 copies = {} |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
357 revnum = self.revnum(rev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
358 |
5076
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
359 if revnum in self.modulemap: |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
360 new_module = self.modulemap[revnum] |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
361 if new_module != self.module: |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
362 self.module = new_module |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
363 self.reparent(self.module) |
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
364 |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
365 for path, ent in paths: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
366 entrypath = get_entry_from_path(path, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
367 entry = entrypath.decode(self.encoding) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
368 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
369 kind = svn.ra.check_path(self.ra, entrypath, revnum) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
370 if kind == svn.core.svn_node_file: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
371 if ent.copyfrom_path: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
372 copyfrom_path = get_entry_from_path(ent.copyfrom_path) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
373 if copyfrom_path: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
374 self.ui.debug("Copied to %s from %s@%s\n" % (entry, copyfrom_path, ent.copyfrom_rev)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
375 # It's probably important for hg that the source |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
376 # exists in the revision's parent, not just the |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
377 # ent.copyfrom_rev |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
378 fromkind = svn.ra.check_path(self.ra, copyfrom_path, ent.copyfrom_rev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
379 if fromkind != 0: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
380 copies[self.recode(entry)] = self.recode(copyfrom_path) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
381 entries.append(self.recode(entry)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
382 elif kind == 0: # gone, but had better be a deleted *file* |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
383 self.ui.debug("gone from %s\n" % ent.copyfrom_rev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
384 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
385 # if a branch is created but entries are removed in the same |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
386 # changeset, get the right fromrev |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
387 if parents: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
388 uuid, old_module, fromrev = self.revsplit(parents[0]) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
389 else: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
390 fromrev = revnum - 1 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
391 # might always need to be revnum - 1 in these 3 lines? |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
392 old_module = self.modulemap.get(fromrev, self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
393 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
394 basepath = old_module + "/" + get_entry_from_path(path, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
395 entrypath = old_module + "/" + get_entry_from_path(path, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
396 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
397 def lookup_parts(p): |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
398 rc = None |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
399 parts = p.split("/") |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
400 for i in range(len(parts)): |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
401 part = "/".join(parts[:i]) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
402 info = part, copyfrom.get(part, None) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
403 if info[1] is not None: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
404 self.ui.debug("Found parent directory %s\n" % info[1]) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
405 rc = info |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
406 return rc |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
407 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
408 self.ui.debug("base, entry %s %s\n" % (basepath, entrypath)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
409 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
410 frompath, froment = lookup_parts(entrypath) or (None, revnum - 1) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
411 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
412 # need to remove fragment from lookup_parts and replace with copyfrom_path |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
413 if frompath is not None: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
414 self.ui.debug("munge-o-matic\n") |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
415 self.ui.debug(entrypath + '\n') |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
416 self.ui.debug(entrypath[len(frompath):] + '\n') |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
417 entrypath = froment.copyfrom_path + entrypath[len(frompath):] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
418 fromrev = froment.copyfrom_rev |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
419 self.ui.debug("Info: %s %s %s %s\n" % (frompath, froment, ent, entrypath)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
420 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
421 fromkind = svn.ra.check_path(self.ra, entrypath, fromrev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
422 if fromkind == svn.core.svn_node_file: # a deleted file |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
423 entries.append(self.recode(entry)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
424 elif fromkind == svn.core.svn_node_dir: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
425 # print "Deleted/moved non-file:", revnum, path, ent |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
426 # children = self._find_children(path, revnum - 1) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
427 # print "find children %s@%d from %d action %s" % (path, revnum, ent.copyfrom_rev, ent.action) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
428 # Sometimes this is tricky. For example: in |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
429 # The Subversion Repository revision 6940 a dir |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
430 # was copied and one of its files was deleted |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
431 # from the new location in the same commit. This |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
432 # code can't deal with that yet. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
433 if ent.action == 'C': |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
434 children = self._find_children(path, fromrev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
435 else: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
436 oroot = entrypath.strip('/') |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
437 nroot = path.strip('/') |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
438 children = self._find_children(oroot, fromrev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
439 children = [s.replace(oroot,nroot) for s in children] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
440 # Mark all [files, not directories] as deleted. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
441 for child in children: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
442 # Can we move a child directory and its |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
443 # parent in the same commit? (probably can). Could |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
444 # cause problems if instead of revnum -1, |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
445 # we have to look in (copyfrom_path, revnum - 1) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
446 entrypath = get_entry_from_path("/" + child, module=old_module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
447 if entrypath: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
448 entry = self.recode(entrypath.decode(self.encoding)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
449 if entry in copies: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
450 # deleted file within a copy |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
451 del copies[entry] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
452 else: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
453 entries.append(entry) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
454 else: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
455 self.ui.debug('unknown path in revision %d: %s\n' % \ |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
456 (revnum, path)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
457 elif kind == svn.core.svn_node_dir: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
458 # Should probably synthesize normal file entries |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
459 # and handle as above to clean up copy/rename handling. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
460 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
461 # If the directory just had a prop change, |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
462 # then we shouldn't need to look for its children. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
463 # Also this could create duplicate entries. Not sure |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
464 # whether this will matter. Maybe should make entries a set. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
465 # print "Changed directory", revnum, path, ent.action, ent.copyfrom_path, ent.copyfrom_rev |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
466 # This will fail if a directory was copied |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
467 # from another branch and then some of its files |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
468 # were deleted in the same transaction. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
469 children = self._find_children(path, revnum) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
470 children.sort() |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
471 for child in children: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
472 # Can we move a child directory and its |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
473 # parent in the same commit? (probably can). Could |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
474 # cause problems if instead of revnum -1, |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
475 # we have to look in (copyfrom_path, revnum - 1) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
476 entrypath = get_entry_from_path("/" + child, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
477 # print child, self.module, entrypath |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
478 if entrypath: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
479 # Need to filter out directories here... |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
480 kind = svn.ra.check_path(self.ra, entrypath, revnum) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
481 if kind != svn.core.svn_node_dir: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
482 entries.append(self.recode(entrypath)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
483 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
484 # Copies here (must copy all from source) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
485 # Probably not a real problem for us if |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
486 # source does not exist |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
487 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
488 # Can do this with the copy command "hg copy" |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
489 # if ent.copyfrom_path: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
490 # copyfrom_entry = get_entry_from_path(ent.copyfrom_path.decode(self.encoding), |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
491 # module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
492 # copyto_entry = entrypath |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
493 # |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
494 # print "copy directory", copyfrom_entry, 'to', copyto_entry |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
495 # |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
496 # copies.append((copyfrom_entry, copyto_entry)) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
497 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
498 if ent.copyfrom_path: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
499 copyfrom_path = ent.copyfrom_path.decode(self.encoding) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
500 copyfrom_entry = get_entry_from_path(copyfrom_path, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
501 if copyfrom_entry: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
502 copyfrom[path] = ent |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
503 self.ui.debug("mark %s came from %s\n" % (path, copyfrom[path])) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
504 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
505 # Good, /probably/ a regular copy. Really should check |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
506 # to see whether the parent revision actually contains |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
507 # the directory in question. |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
508 children = self._find_children(self.recode(copyfrom_path), ent.copyfrom_rev) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
509 children.sort() |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
510 for child in children: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
511 entrypath = get_entry_from_path("/" + child, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
512 if entrypath: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
513 entry = entrypath.decode(self.encoding) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
514 # print "COPY COPY From", copyfrom_entry, entry |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
515 copyto_path = path + entry[len(copyfrom_entry):] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
516 copyto_entry = get_entry_from_path(copyto_path, module=self.module) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
517 # print "COPY", entry, "COPY To", copyto_entry |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
518 copies[self.recode(copyto_entry)] = self.recode(entry) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
519 # copy from quux splort/quuxfile |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
520 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
521 return (entries, copies) |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
522 |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
523 def _fetch_revisions(self, from_revnum = 0, to_revnum = 347): |
4922
961379b2c586
convert/subversion: reduce memory usage by filtering early
Bryan O'Sullivan <bos@serpentine.com>
parents:
4908
diff
changeset
|
524 self.child_cset = None |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
525 def parselogentry(orig_paths, revnum, author, date, message): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
526 self.ui.debug("parsing revision %d (%d changes)\n" % |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
527 (revnum, len(orig_paths))) |
4922
961379b2c586
convert/subversion: reduce memory usage by filtering early
Bryan O'Sullivan <bos@serpentine.com>
parents:
4908
diff
changeset
|
528 |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
529 if revnum in self.modulemap: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
530 new_module = self.modulemap[revnum] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
531 if new_module != self.module: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
532 self.module = new_module |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
533 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
534 |
4809
c2d529f288a1
convert: move some code into common init function
Brendan Cully <brendan@kublai.com>
parents:
4806
diff
changeset
|
535 rev = self.revid(revnum) |
4814
4cdbaa885d8a
convert: svn: some improvements in memory usage
Brendan Cully <brendan@kublai.com>
parents:
4813
diff
changeset
|
536 # branch log might return entries for a parent we already have |
4824
e20e40f67f0e
convert: svn: avoid parsing already-seen logentries due to branch following
Brendan Cully <brendan@kublai.com>
parents:
4814
diff
changeset
|
537 if (rev in self.commits or |
e20e40f67f0e
convert: svn: avoid parsing already-seen logentries due to branch following
Brendan Cully <brendan@kublai.com>
parents:
4814
diff
changeset
|
538 (revnum < self.lastrevs.get(self.module, 0))): |
4814
4cdbaa885d8a
convert: svn: some improvements in memory usage
Brendan Cully <brendan@kublai.com>
parents:
4813
diff
changeset
|
539 return |
4cdbaa885d8a
convert: svn: some improvements in memory usage
Brendan Cully <brendan@kublai.com>
parents:
4813
diff
changeset
|
540 |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
541 parents = [] |
5074
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
542 # check whether this revision is the start of a branch |
5246
585471802a01
convert: svn: check for branch movement in any log entry, not just the first.
Brendan Cully <brendan@kublai.com>
parents:
5119
diff
changeset
|
543 if self.module in orig_paths: |
585471802a01
convert: svn: check for branch movement in any log entry, not just the first.
Brendan Cully <brendan@kublai.com>
parents:
5119
diff
changeset
|
544 ent = orig_paths[self.module] |
5074
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
545 if ent.copyfrom_path: |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
546 # ent.copyfrom_rev may not be the actual last revision |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
547 prev = self.latest(ent.copyfrom_path, ent.copyfrom_rev) |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
548 self.modulemap[prev] = ent.copyfrom_path |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
549 parents = [self.revid(prev, ent.copyfrom_path)] |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
550 self.ui.note('found parent of branch %s at %d: %s\n' % \ |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
551 (self.module, prev, ent.copyfrom_path)) |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
552 else: |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
553 self.ui.debug("No copyfrom path, don't know what to do.\n") |
4cef0b93969d
convert: svn: hoist up branch creation check
Brendan Cully <brendan@kublai.com>
parents:
5073
diff
changeset
|
554 |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
555 self.modulemap[revnum] = self.module # track backwards in time |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
556 |
5246
585471802a01
convert: svn: check for branch movement in any log entry, not just the first.
Brendan Cully <brendan@kublai.com>
parents:
5119
diff
changeset
|
557 orig_paths = orig_paths.items() |
585471802a01
convert: svn: check for branch movement in any log entry, not just the first.
Brendan Cully <brendan@kublai.com>
parents:
5119
diff
changeset
|
558 orig_paths.sort() |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
559 paths = [] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
560 # filter out unrelated paths |
4922
961379b2c586
convert/subversion: reduce memory usage by filtering early
Bryan O'Sullivan <bos@serpentine.com>
parents:
4908
diff
changeset
|
561 for path, ent in orig_paths: |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
562 if not path.startswith(self.module): |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
563 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:
4785
diff
changeset
|
564 continue |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
565 paths.append((path, ent)) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
566 |
5076
ef338e34a906
convert: look up copies in getchanges instead of getcommit
Brendan Cully <brendan@kublai.com>
parents:
5075
diff
changeset
|
567 self.paths[rev] = (paths, parents) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
568 |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
569 # 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:
4785
diff
changeset
|
570 # 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:
4785
diff
changeset
|
571 # '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:
4785
diff
changeset
|
572 date = util.parsedate(date[:18] + " UTC", ["%Y-%m-%dT%H:%M:%S"]) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
573 |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
574 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:
4785
diff
changeset
|
575 author = author and self.recode(author) or '' |
5075
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
576 try: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
577 branch = self.module.split("/")[-1] |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
578 if branch == 'trunk': |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
579 branch = '' |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
580 except IndexError: |
514c06098e9c
convert: svn: pull up path to file expansion code into separate function.
Brendan Cully <brendan@kublai.com>
parents:
5074
diff
changeset
|
581 branch = None |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
582 |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
583 cset = commit(author=author, |
4939
cdd33a048289
removed trailing whitespace
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4931
diff
changeset
|
584 date=util.datestr(date), |
cdd33a048289
removed trailing whitespace
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4931
diff
changeset
|
585 desc=log, |
4793
ea618c5934f3
convert: svn: get parent for branch creation events
Brendan Cully <brendan@kublai.com>
parents:
4792
diff
changeset
|
586 parents=parents, |
4873
28b23b9073a8
convert: record the source revision in the changelog
Brendan Cully <brendan@kublai.com>
parents:
4835
diff
changeset
|
587 branch=branch, |
28b23b9073a8
convert: record the source revision in the changelog
Brendan Cully <brendan@kublai.com>
parents:
4835
diff
changeset
|
588 rev=rev.encode('utf-8')) |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
589 |
4794
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
590 self.commits[rev] = cset |
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
591 if self.child_cset and not self.child_cset.parents: |
4786
62e1b6412b62
convert: svn: add an early return to move most changeset parsing out an indent level
Brendan Cully <brendan@kublai.com>
parents:
4785
diff
changeset
|
592 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:
4785
diff
changeset
|
593 self.child_cset = cset |
4794
26857a6f9dd0
convert: svn: pull out broken batching code, add alpha tags support
Brendan Cully <brendan@kublai.com>
parents:
4793
diff
changeset
|
594 |
4922
961379b2c586
convert/subversion: reduce memory usage by filtering early
Bryan O'Sullivan <bos@serpentine.com>
parents:
4908
diff
changeset
|
595 self.ui.note('fetching revision log for "%s" from %d to %d\n' % |
4795
09dae950919f
convert: svn: autodetect /branches, /tags, /trunk.
Brendan Cully <brendan@kublai.com>
parents:
4794
diff
changeset
|
596 (self.module, from_revnum, to_revnum)) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
597 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
598 try: |
4928
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
599 for entry in self.get_log([self.module], from_revnum, to_revnum): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
600 orig_paths, revnum, author, date, message = entry |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
601 if self.is_blacklisted(revnum): |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
602 self.ui.note('skipping blacklisted revision %d\n' % revnum) |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
603 continue |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
604 if orig_paths is None: |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
605 self.ui.debug('revision %d has no entries\n' % revnum) |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
606 continue |
e8f4e40f285a
convert/subversion: work around memory leak in svn's python bindings
Bryan O'Sullivan <bos@serpentine.com>
parents:
4926
diff
changeset
|
607 parselogentry(orig_paths, revnum, author, date, message) |
5113
792c1d979097
Replace _ with inst for catching exceptions to not shadow gettext.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5112
diff
changeset
|
608 except SubversionException, (inst, num): |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
609 if num == svn.core.SVN_ERR_FS_NO_SUCH_REVISION: |
4939
cdd33a048289
removed trailing whitespace
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4931
diff
changeset
|
610 raise NoSuchRevision(branch=self, |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
611 revision="Revision number %d" % to_revnum) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
612 raise |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
613 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
614 def _getfile(self, file, rev): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
615 io = StringIO() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
616 # 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
|
617 mode = '' |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
618 try: |
4767
d305852a5ec8
convert: svn: add revnum() to convert rev to revnum
Brendan Cully <brendan@kublai.com>
parents:
4766
diff
changeset
|
619 revnum = self.revnum(rev) |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
620 if self.module != self.modulemap[revnum]: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
621 self.module = self.modulemap[revnum] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
622 self.reparent(self.module) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
623 info = svn.ra.get_file(self.ra, file, revnum, io) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
624 if isinstance(info, list): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
625 info = info[-1] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
626 mode = ("svn:executable" in info) and 'x' or '' |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
627 mode = ("svn:special" in info) and 'l' or mode |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
628 except SubversionException, e: |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
629 notfound = (svn.core.SVN_ERR_FS_NOT_FOUND, |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
630 svn.core.SVN_ERR_RA_DAV_PATH_NOT_FOUND) |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
631 if e.apr_err in notfound: # File not found |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
632 raise IOError() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
633 raise |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
634 data = io.getvalue() |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
635 if mode == 'l': |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
636 link_prefix = "link " |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
637 if data.startswith(link_prefix): |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
638 data = data[len(link_prefix):] |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
639 return data, mode |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
640 |
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
641 def _find_children(self, path, revnum): |
5069
35f67dd712d0
convert: svn: ensure leading / is removed from paths in _find_children (broken in 2bd996d0aaf8)
Brendan Cully <brendan@kublai.com>
parents:
5050
diff
changeset
|
642 path = path.strip('/') |
4758
b6a1f2c46c6c
convert extension: Add SVN converter
Daniel Holth <dholth@fastmail.fm>
parents:
diff
changeset
|
643 pool = Pool() |
5069
35f67dd712d0
convert: svn: ensure leading / is removed from paths in _find_children (broken in 2bd996d0aaf8)
Brendan Cully <brendan@kublai.com>
parents:
5050
diff
changeset
|
644 rpath = '/'.join([self.base, path]).strip('/') |
5072
c89ed1f27e78
convert: svn: add helper function for optrevs
Brendan Cully <brendan@kublai.com>
parents:
5069
diff
changeset
|
645 return ['%s/%s' % (path, x) for x in svn.client.ls(rpath, optrev(revnum), True, self.ctx, pool).keys()] |