comparison hgext/convert/darcs.py @ 9541:53a95a744812

Merge with crew-stable
author Patrick Mezard <pmezard@gmail.com>
date Sun, 04 Oct 2009 23:16:54 +0200
parents 4c041f1ee1b4 b3c13e721593
children 18b134ef294c
comparison
equal deleted inserted replaced
9540:cad36e496640 9541:53a95a744812
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 copies[elt.get('from')] = elt.get('to') 130 man = self.manifest()
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
120 else: 147 else:
121 changes.append((elt.text.strip(), rev)) 148 changes.append((elt.text.strip(), rev))
149 self.pull(rev)
122 self.lastrev = rev 150 self.lastrev = rev
123 return sorted(changes), copies 151 return sorted(changes), copies
124 152
125 def getfile(self, name, rev): 153 def getfile(self, name, rev):
126 if rev != self.lastrev: 154 if rev != self.lastrev: