83 fp = self._run(cmd, **kwargs) |
83 fp = self._run(cmd, **kwargs) |
84 etree.parse(fp) |
84 etree.parse(fp) |
85 self.checkexit(fp.close()) |
85 self.checkexit(fp.close()) |
86 return etree.getroot() |
86 return etree.getroot() |
87 |
87 |
|
88 def manifest(self): |
|
89 man = [] |
|
90 output, status = self.run('show', 'files', no_directories=True, |
|
91 repodir=self.tmppath) |
|
92 self.checkexit(status) |
|
93 for line in output.split('\n'): |
|
94 path = line[2:] |
|
95 if path: |
|
96 man.append(path) |
|
97 return man |
|
98 |
88 def getheads(self): |
99 def getheads(self): |
89 return self.parents[None] |
100 return self.parents[None] |
90 |
101 |
91 def getcommit(self, rev): |
102 def getcommit(self, rev): |
92 elt = self.changes[rev] |
103 elt = self.changes[rev] |
105 if output.find('We have conflicts in') == -1: |
116 if output.find('We have conflicts in') == -1: |
106 self.checkexit(status, output) |
117 self.checkexit(status, output) |
107 output, status = self.run('revert', all=True, repodir=self.tmppath) |
118 output, status = self.run('revert', all=True, repodir=self.tmppath) |
108 self.checkexit(status, output) |
119 self.checkexit(status, output) |
109 |
120 |
110 def getchanges(self, rev): |
121 def getchanges(self, rev): |
111 self.pull(rev) |
|
112 copies = {} |
122 copies = {} |
113 changes = [] |
123 changes = [] |
|
124 man = None |
114 for elt in self.changes[rev].find('summary').getchildren(): |
125 for elt in self.changes[rev].find('summary').getchildren(): |
115 if elt.tag in ('add_directory', 'remove_directory'): |
126 if elt.tag in ('add_directory', 'remove_directory'): |
116 continue |
127 continue |
117 if elt.tag == 'move': |
128 if elt.tag == 'move': |
118 changes.append((elt.get('from'), rev)) |
129 if man is None: |
119 changes.append((elt.get('to'), rev)) |
130 man = self.manifest() |
120 copies[elt.get('to')] = elt.get('from') |
131 source, dest = elt.get('from'), elt.get('to') |
|
132 if source in man: |
|
133 # File move |
|
134 changes.append((source, rev)) |
|
135 changes.append((dest, rev)) |
|
136 copies[dest] = source |
|
137 else: |
|
138 # Directory move, deduce file moves from manifest |
|
139 source = source + '/' |
|
140 for f in man: |
|
141 if not f.startswith(source): |
|
142 continue |
|
143 fdest = dest + '/' + f[len(source):] |
|
144 changes.append((f, rev)) |
|
145 changes.append((fdest, rev)) |
|
146 copies[fdest] = f |
121 else: |
147 else: |
122 changes.append((elt.text.strip(), rev)) |
148 changes.append((elt.text.strip(), rev)) |
|
149 self.pull(rev) |
123 self.lastrev = rev |
150 self.lastrev = rev |
124 return sorted(changes), copies |
151 return sorted(changes), copies |
125 |
152 |
126 def getfile(self, name, rev): |
153 def getfile(self, name, rev): |
127 if rev != self.lastrev: |
154 if rev != self.lastrev: |