Mercurial > hg
annotate hgext/convert/filemap.py @ 23337:3a8a763f4197
revlog: add a method to get missing revs incrementally
This will turn out to be useful for discovery.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sun, 16 Nov 2014 00:39:48 -0800 |
parents | 35ab037de989 |
children | 216fa1ba9993 |
rev | line source |
---|---|
5376
d60a067227a5
convert: move filemapper class to a separate file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5375
diff
changeset
|
1 # Copyright 2007 Bryan O'Sullivan <bos@serpentine.com> |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
2 # Copyright 2007 Alexis S. L. Carvalho <alexis@cecm.usp.br> |
316 | 3 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8150
diff
changeset
|
4 # This software may be used and distributed according to the terms of the |
10263 | 5 # GNU General Public License version 2 or any later version. |
316 | 6 |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
7 import posixpath |
5376
d60a067227a5
convert: move filemapper class to a separate file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5375
diff
changeset
|
8 import shlex |
d60a067227a5
convert: move filemapper class to a separate file
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5375
diff
changeset
|
9 from mercurial.i18n import _ |
19863
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
10 from mercurial import util, error |
5556
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5510
diff
changeset
|
11 from common import SKIPREV, converter_source |
694 | 12 |
20048
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
13 def rpairs(path): |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
14 '''Yield tuples with path split at '/', starting with the full path. |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
15 No leading, trailing or double '/', please. |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
16 >>> for x in rpairs('foo/bar/baz'): print x |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
17 ('foo/bar/baz', '') |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
18 ('foo/bar', 'baz') |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
19 ('foo', 'bar/baz') |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
20 ('.', 'foo/bar/baz') |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
21 ''' |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
22 i = len(path) |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
23 while i != -1: |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
24 yield path[:i], path[i + 1:] |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
25 i = path.rfind('/', 0, i) |
da99ebd35f00
convert: readability and test of rpairs function
Mads Kiilerich <madski@unity3d.com>
parents:
19892
diff
changeset
|
26 yield '.', path |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
27 |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
28 def normalize(path): |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
29 ''' We use posixpath.normpath to support cross-platform path format. |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
30 However, it doesn't handle None input. So we wrap it up. ''' |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
31 if path is None: |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
32 return None |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
33 return posixpath.normpath(path) |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
34 |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
35 class filemapper(object): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
36 '''Map and filter filenames when importing. |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
37 A name can be mapped to itself, a new name, or None (omit from new |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
38 repository).''' |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
39 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
40 def __init__(self, ui, path=None): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
41 self.ui = ui |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
42 self.include = {} |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
43 self.exclude = {} |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
44 self.rename = {} |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
45 if path: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
46 if self.parse(path): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
47 raise util.Abort(_('errors in filemap')) |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
48 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
49 def parse(self, path): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
50 errs = 0 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
51 def check(name, mapping, listname): |
11680
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
52 if not name: |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
53 self.ui.warn(_('%s:%d: path to %s is missing\n') % |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
54 (lex.infile, lex.lineno, listname)) |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
55 return 1 |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
56 if name in mapping: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
57 self.ui.warn(_('%s:%d: %r already in %s list\n') % |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
58 (lex.infile, lex.lineno, name, listname)) |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
59 return 1 |
11680
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
60 if (name.startswith('/') or |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
61 name.endswith('/') or |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
62 '//' in name): |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
63 self.ui.warn(_('%s:%d: superfluous / in %s %r\n') % |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
64 (lex.infile, lex.lineno, listname, name)) |
7fefef3ce791
convert: warn on superfluous / in paths
Mads Kiilerich <mads@kiilerich.com>
parents:
11673
diff
changeset
|
65 return 1 |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
66 return 0 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
67 lex = shlex.shlex(open(path), path, True) |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
68 lex.wordchars += '!@#$%^&*()-=+[]{}|;:,./<>?' |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
69 cmd = lex.get_token() |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
70 while cmd: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
71 if cmd == 'include': |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
72 name = normalize(lex.get_token()) |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
73 errs += check(name, self.exclude, 'exclude') |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
74 self.include[name] = name |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
75 elif cmd == 'exclude': |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
76 name = normalize(lex.get_token()) |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
77 errs += check(name, self.include, 'include') |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
78 errs += check(name, self.rename, 'rename') |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
79 self.exclude[name] = name |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
80 elif cmd == 'rename': |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
81 src = normalize(lex.get_token()) |
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
82 dest = normalize(lex.get_token()) |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
83 errs += check(src, self.exclude, 'exclude') |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
84 self.rename[src] = dest |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
85 elif cmd == 'source': |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
86 errs += self.parse(normalize(lex.get_token())) |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
87 else: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
88 self.ui.warn(_('%s:%d: unknown directive %r\n') % |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
89 (lex.infile, lex.lineno, cmd)) |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
90 errs += 1 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
91 cmd = lex.get_token() |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
92 return errs |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
93 |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
94 def lookup(self, name, mapping): |
17797
e4da793998bf
convert: normalize paths in filemaps (issue3612)
Huayang <huayang@fb.com>
parents:
17184
diff
changeset
|
95 name = normalize(name) |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
96 for pre, suf in rpairs(name): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
97 try: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
98 return mapping[pre], pre, suf |
7875
553aa0cbeab6
cleanup: drop unused assignments
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
5803
diff
changeset
|
99 except KeyError: |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
100 pass |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
101 return '', name, '' |
5143
d4fa6bafc43a
Remove trailing spaces, fix indentation
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5139
diff
changeset
|
102 |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
103 def __call__(self, name): |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
104 if self.include: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
105 inc = self.lookup(name, self.include)[0] |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
106 else: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
107 inc = name |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
108 if self.exclude: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
109 exc = self.lookup(name, self.exclude)[0] |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
110 else: |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
111 exc = '' |
9884
2dd700a35fd1
convert: make filemap favor most specific filtering rule
Stefan Simek <simek@triaxis.sk>
parents:
8693
diff
changeset
|
112 if (not self.include and exc) or (len(inc) <= len(exc)): |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
113 return None |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
114 newpre, pre, suf = self.lookup(name, self.rename) |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
115 if newpre: |
5133
745cffe59ca8
convert: use '.' as destination name if renaming subdir into root
Bryan O'Sullivan <bos@serpentine.com>
parents:
5127
diff
changeset
|
116 if newpre == '.': |
745cffe59ca8
convert: use '.' as destination name if renaming subdir into root
Bryan O'Sullivan <bos@serpentine.com>
parents:
5127
diff
changeset
|
117 return suf |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
118 if suf: |
15565
3992c7df85f2
convert: handle trailing slashes in filemap better (issue3124)
Matt Mackall <mpm@selenic.com>
parents:
15107
diff
changeset
|
119 if newpre.endswith('/'): |
3992c7df85f2
convert: handle trailing slashes in filemap better (issue3124)
Matt Mackall <mpm@selenic.com>
parents:
15107
diff
changeset
|
120 return newpre + suf |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
121 return newpre + '/' + suf |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
122 return newpre |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
123 return name |
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
124 |
5195
33015dac5df5
convert: fix mercurial_sink.putcommit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5173
diff
changeset
|
125 def active(self): |
33015dac5df5
convert: fix mercurial_sink.putcommit
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5173
diff
changeset
|
126 return bool(self.include or self.exclude or self.rename) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
127 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
128 # This class does two additional things compared to a regular source: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
129 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
130 # - Filter and rename files. This is mostly wrapped by the filemapper |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
131 # class above. We hide the original filename in the revision that is |
11134
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
132 # returned by getchanges to be able to find things later in getfile. |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
133 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
134 # - Return only revisions that matter for the files we're interested in. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
135 # This involves rewriting the parents of the original revision to |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
136 # create a graph that is restricted to those revisions. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
137 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
138 # This set of revisions includes not only revisions that directly |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
139 # touch files we're interested in, but also merges that merge two |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
140 # or more interesting revisions. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
141 |
5556
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5510
diff
changeset
|
142 class filemap_source(converter_source): |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
143 def __init__(self, ui, baseconverter, filemap): |
5556
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5510
diff
changeset
|
144 super(filemap_source, self).__init__(ui) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
145 self.base = baseconverter |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
146 self.filemapper = filemapper(ui, filemap) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
147 self.commits = {} |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
148 # if a revision rev has parent p in the original revision graph, then |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
149 # rev will have parent self.parentmap[p] in the restricted graph. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
150 self.parentmap = {} |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
151 # self.wantedancestors[rev] is the set of all ancestors of rev that |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
152 # are in the restricted graph. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
153 self.wantedancestors = {} |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
154 self.convertedorder = None |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
155 self._rebuilt = False |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
156 self.origparents = {} |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
157 self.children = {} |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
158 self.seenchildren = {} |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
159 |
5799
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
160 def before(self): |
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
161 self.base.before() |
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
162 |
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
163 def after(self): |
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
164 self.base.after() |
4b82d1a84db8
convert: filemap must call base converter before()/after() actions
Patrick Mezard <pmezard@gmail.com>
parents:
5401
diff
changeset
|
165 |
5510
11d7908a3ea8
convert: abstract map files into a class
Bryan O'Sullivan <bos@serpentine.com>
parents:
5401
diff
changeset
|
166 def setrevmap(self, revmap): |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
167 # rebuild our state to make things restartable |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
168 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
169 # To avoid calling getcommit for every revision that has already |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
170 # been converted, we rebuild only the parentmap, delaying the |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
171 # rebuild of wantedancestors until we need it (i.e. until a |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
172 # merge). |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
173 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
174 # We assume the order argument lists the revisions in |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
175 # topological order, so that we can infer which revisions were |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
176 # wanted by previous runs. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
177 self._rebuilt = not revmap |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
178 seen = {SKIPREV: SKIPREV} |
8150
bbc24c0753a0
util: use built-in set and frozenset
Martin Geisler <mg@lazybytes.net>
parents:
7875
diff
changeset
|
179 dummyset = set() |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
180 converted = [] |
5510
11d7908a3ea8
convert: abstract map files into a class
Bryan O'Sullivan <bos@serpentine.com>
parents:
5401
diff
changeset
|
181 for rev in revmap.order: |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
182 mapped = revmap[rev] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
183 wanted = mapped not in seen |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
184 if wanted: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
185 seen[mapped] = rev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
186 self.parentmap[rev] = rev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
187 else: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
188 self.parentmap[rev] = seen[mapped] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
189 self.wantedancestors[rev] = dummyset |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
190 arg = seen[mapped] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
191 if arg == SKIPREV: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
192 arg = None |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
193 converted.append((rev, wanted, arg)) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
194 self.convertedorder = converted |
5510
11d7908a3ea8
convert: abstract map files into a class
Bryan O'Sullivan <bos@serpentine.com>
parents:
5401
diff
changeset
|
195 return self.base.setrevmap(revmap) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
196 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
197 def rebuild(self): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
198 if self._rebuilt: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
199 return True |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
200 self._rebuilt = True |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
201 self.parentmap.clear() |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
202 self.wantedancestors.clear() |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
203 self.seenchildren.clear() |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
204 for rev, wanted, arg in self.convertedorder: |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
205 if rev not in self.origparents: |
19863
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
206 try: |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
207 self.origparents[rev] = self.getcommit(rev).parents |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
208 except error.RepoLookupError: |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
209 self.ui.debug("unknown revmap source: %s\n" % rev) |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
210 continue |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
211 if arg is not None: |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
212 self.children[arg] = self.children.get(arg, 0) + 1 |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
213 |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
214 for rev, wanted, arg in self.convertedorder: |
19863
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
215 try: |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
216 parents = self.origparents[rev] |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
217 except KeyError: |
daeab82fa644
convert: fix crash when existing converted revision didn't come from source
Mads Kiilerich <madski@unity3d.com>
parents:
19862
diff
changeset
|
218 continue # unknown revmap source |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
219 if wanted: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
220 self.mark_wanted(rev, parents) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
221 else: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
222 self.mark_not_wanted(rev, arg) |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
223 self._discard(arg, *parents) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
224 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
225 return True |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
226 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
227 def getheads(self): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
228 return self.base.getheads() |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
229 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
230 def getcommit(self, rev): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
231 # We want to save a reference to the commit objects to be able |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
232 # to rewrite their parents later on. |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
233 c = self.commits[rev] = self.base.getcommit(rev) |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
234 for p in c.parents: |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
235 self.children[p] = self.children.get(p, 0) + 1 |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
236 return c |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
237 |
13968
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
238 def _cachedcommit(self, rev): |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
239 if rev in self.commits: |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
240 return self.commits[rev] |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
241 return self.base.getcommit(rev) |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
242 |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
243 def _discard(self, *revs): |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
244 for r in revs: |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
245 if r is None: |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
246 continue |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
247 self.seenchildren[r] = self.seenchildren.get(r, 0) + 1 |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
248 if self.seenchildren[r] == self.children[r]: |
19862
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
249 self.wantedancestors.pop(r, None) |
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
250 self.parentmap.pop(r, None) |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
251 del self.seenchildren[r] |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
252 if self._rebuilt: |
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
253 del self.children[r] |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
254 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
255 def wanted(self, rev, i): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
256 # Return True if we're directly interested in rev. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
257 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
258 # i is an index selecting one of the parents of rev (if rev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
259 # has no parents, i is None). getchangedfiles will give us |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
260 # the list of files that are different in rev and in the parent |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
261 # indicated by i. If we're interested in any of these files, |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
262 # we're interested in rev. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
263 try: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
264 files = self.base.getchangedfiles(rev, i) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
265 except NotImplementedError: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
266 raise util.Abort(_("source repository doesn't support --filemap")) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
267 for f in files: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
268 if self.filemapper(f): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
269 return True |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
270 return False |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
271 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
272 def mark_not_wanted(self, rev, p): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
273 # Mark rev as not interesting and update data structures. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
274 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
275 if p is None: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
276 # A root revision. Use SKIPREV to indicate that it doesn't |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
277 # map to any revision in the restricted graph. Put SKIPREV |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
278 # in the set of wanted ancestors to simplify code elsewhere |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
279 self.parentmap[rev] = SKIPREV |
8150
bbc24c0753a0
util: use built-in set and frozenset
Martin Geisler <mg@lazybytes.net>
parents:
7875
diff
changeset
|
280 self.wantedancestors[rev] = set((SKIPREV,)) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
281 return |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
282 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
283 # Reuse the data from our parent. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
284 self.parentmap[rev] = self.parentmap[p] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
285 self.wantedancestors[rev] = self.wantedancestors[p] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
286 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
287 def mark_wanted(self, rev, parents): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
288 # Mark rev ss wanted and update data structures. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
289 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
290 # rev will be in the restricted graph, so children of rev in |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
291 # the original graph should still have rev as a parent in the |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
292 # restricted graph. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
293 self.parentmap[rev] = rev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
294 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
295 # The set of wanted ancestors of rev is the union of the sets |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
296 # of wanted ancestors of its parents. Plus rev itself. |
8150
bbc24c0753a0
util: use built-in set and frozenset
Martin Geisler <mg@lazybytes.net>
parents:
7875
diff
changeset
|
297 wrev = set() |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
298 for p in parents: |
19862
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
299 if p in self.wantedancestors: |
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
300 wrev.update(self.wantedancestors[p]) |
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
301 else: |
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
302 self.ui.warn(_('warning: %s parent %s is missing\n') % |
42455ebbab9f
convert: fix crash when filemap filtering is changed
Mads Kiilerich <madski@unity3d.com>
parents:
17797
diff
changeset
|
303 (rev, p)) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
304 wrev.add(rev) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
305 self.wantedancestors[rev] = wrev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
306 |
22300
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
20048
diff
changeset
|
307 def getchanges(self, rev, full): |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
308 parents = self.commits[rev].parents |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
309 if len(parents) > 1: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
310 self.rebuild() |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
311 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
312 # To decide whether we're interested in rev we: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
313 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
314 # - calculate what parents rev will have if it turns out we're |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
315 # interested in it. If it's going to have more than 1 parent, |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
316 # we're interested in it. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
317 # |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
318 # - otherwise, we'll compare it with the single parent we found. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
319 # If any of the files we're interested in is different in the |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
320 # the two revisions, we're interested in rev. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
321 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
322 # A parent p is interesting if its mapped version (self.parentmap[p]): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
323 # - is not SKIPREV |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
324 # - is still not in the list of parents (we don't want duplicates) |
17103
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
325 # - is not an ancestor of the mapped versions of the other parents or |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
326 # there is no parent in the same branch than the current revision. |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
327 mparents = [] |
17103
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
328 knownparents = set() |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
329 branch = self.commits[rev].branch |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
330 hasbranchparent = False |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
331 for i, p1 in enumerate(parents): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
332 mp1 = self.parentmap[p1] |
17103
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
333 if mp1 == SKIPREV or mp1 in knownparents: |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
334 continue |
17103
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
335 isancestor = util.any(p2 for p2 in parents |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
336 if p1 != p2 and mp1 != self.parentmap[p2] |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
337 and mp1 in self.wantedancestors[p2]) |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
338 if not isancestor and not hasbranchparent and len(parents) > 1: |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
339 # This could be expensive, avoid unnecessary calls. |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
340 if self._cachedcommit(p1).branch == branch: |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
341 hasbranchparent = True |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
342 mparents.append((p1, mp1, i, isancestor)) |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
343 knownparents.add(mp1) |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
344 # Discard parents ancestors of other parents if there is a |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
345 # non-ancestor one on the same branch than current revision. |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
346 if hasbranchparent: |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
347 mparents = [p for p in mparents if not p[3]] |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
348 wp = None |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
349 if mparents: |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
350 wp = max(p[2] for p in mparents) |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
351 mparents = [p[1] for p in mparents] |
5146de7bce96
convert: keep branch switching merges with ancestors (issue3340)
Patrick Mezard <patrick@mezard.eu>
parents:
15565
diff
changeset
|
352 elif parents: |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
353 wp = 0 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
354 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
355 self.origparents[rev] = parents |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
356 |
13968
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
357 closed = False |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
358 if 'close' in self.commits[rev].extra: |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
359 # A branch closing revision is only useful if one of its |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
360 # parents belong to the branch being closed |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
361 pbranches = [self._cachedcommit(p).branch for p in mparents] |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
362 if branch in pbranches: |
82845434e974
convert: make filemap prune useless branch closing revs (issue2774)
Patrick Mezard <pmezard@gmail.com>
parents:
11680
diff
changeset
|
363 closed = True |
11673
a2f11188e2d2
convert: handle closed branch heads in hg-hg conversion (issue2185)
Matt Mackall <mpm@selenic.com>
parents:
11134
diff
changeset
|
364 |
a2f11188e2d2
convert: handle closed branch heads in hg-hg conversion (issue2185)
Matt Mackall <mpm@selenic.com>
parents:
11134
diff
changeset
|
365 if len(mparents) < 2 and not closed and not self.wanted(rev, wp): |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
366 # We don't want this revision. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
367 # Update our state and tell the convert process to map this |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
368 # revision to the same revision its parent as mapped to. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
369 p = None |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
370 if parents: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
371 p = parents[wp] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
372 self.mark_not_wanted(rev, p) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
373 self.convertedorder.append((rev, False, p)) |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
374 self._discard(*parents) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
375 return self.parentmap[rev] |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
376 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
377 # We want this revision. |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
378 # Rewrite the parents of the commit object |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
379 self.commits[rev].parents = mparents |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
380 self.mark_wanted(rev, parents) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
381 self.convertedorder.append((rev, True, None)) |
5401
4c555dd167dd
convert --filemap: reduce memory usage
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5377
diff
changeset
|
382 self._discard(*parents) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
383 |
11134
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
384 # Get the real changes and do the filtering/mapping. To be |
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
385 # able to get the files later on in getfile, we hide the |
33010ff1fd6f
convert: merge sources getmode() into getfile()
Patrick Mezard <pmezard@gmail.com>
parents:
10282
diff
changeset
|
386 # original filename in the rev part of the return value. |
22300
35ab037de989
convert: introduce --full for converting all files
Mads Kiilerich <madski@unity3d.com>
parents:
20048
diff
changeset
|
387 changes, copies = self.base.getchanges(rev, full) |
17174
32b2e6d641e4
convert: make filemap renames consistently override revision renames
Wagner Bruna <wbruna@yahoo.com>
parents:
15565
diff
changeset
|
388 files = {} |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
389 for f, r in changes: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
390 newf = self.filemapper(f) |
17174
32b2e6d641e4
convert: make filemap renames consistently override revision renames
Wagner Bruna <wbruna@yahoo.com>
parents:
15565
diff
changeset
|
391 if newf and (newf != f or newf not in files): |
32b2e6d641e4
convert: make filemap renames consistently override revision renames
Wagner Bruna <wbruna@yahoo.com>
parents:
15565
diff
changeset
|
392 files[newf] = (f, r) |
32b2e6d641e4
convert: make filemap renames consistently override revision renames
Wagner Bruna <wbruna@yahoo.com>
parents:
15565
diff
changeset
|
393 files = sorted(files.items()) |
5377
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
394 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
395 ncopies = {} |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
396 for c in copies: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
397 newc = self.filemapper(c) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
398 if newc: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
399 newsource = self.filemapper(copies[c]) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
400 if newsource: |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
401 ncopies[newc] = newsource |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
402 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
403 return files, ncopies |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
404 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
405 def getfile(self, name, rev): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
406 realname, realrev = rev |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
407 return self.base.getfile(realname, realrev) |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
408 |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
409 def gettags(self): |
756a43a30e34
convert: readd --filemap
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5376
diff
changeset
|
410 return self.base.gettags() |
8691
a0a541d6fed6
convert: fail fast if source does not support --sourcesort
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
411 |
a0a541d6fed6
convert: fail fast if source does not support --sourcesort
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
412 def hasnativeorder(self): |
a0a541d6fed6
convert: fail fast if source does not support --sourcesort
Patrick Mezard <pmezard@gmail.com>
parents:
8225
diff
changeset
|
413 return self.base.hasnativeorder() |
8693
68e0a55eee6e
convert: rewrite tags when converting from hg to hg
Patrick Mezard <pmezard@gmail.com>
parents:
8691
diff
changeset
|
414 |
68e0a55eee6e
convert: rewrite tags when converting from hg to hg
Patrick Mezard <pmezard@gmail.com>
parents:
8691
diff
changeset
|
415 def lookuprev(self, rev): |
68e0a55eee6e
convert: rewrite tags when converting from hg to hg
Patrick Mezard <pmezard@gmail.com>
parents:
8691
diff
changeset
|
416 return self.base.lookuprev(rev) |
15107
2433525a9e1e
convert: added bookmarks support in filemap
etienne <etienne.desautels@gmail.com>
parents:
13968
diff
changeset
|
417 |
2433525a9e1e
convert: added bookmarks support in filemap
etienne <etienne.desautels@gmail.com>
parents:
13968
diff
changeset
|
418 def getbookmarks(self): |
2433525a9e1e
convert: added bookmarks support in filemap
etienne <etienne.desautels@gmail.com>
parents:
13968
diff
changeset
|
419 return self.base.getbookmarks() |
19892
77872b002e73
convert: update source shamap when using filemap, just as when not using filemap
Mads Kiilerich <madski@unity3d.com>
parents:
19863
diff
changeset
|
420 |
77872b002e73
convert: update source shamap when using filemap, just as when not using filemap
Mads Kiilerich <madski@unity3d.com>
parents:
19863
diff
changeset
|
421 def converted(self, rev, sinkrev): |
77872b002e73
convert: update source shamap when using filemap, just as when not using filemap
Mads Kiilerich <madski@unity3d.com>
parents:
19863
diff
changeset
|
422 self.base.converted(rev, sinkrev) |