comparison hgext/convert/monotone.py @ 8050:087cc65bebff

convert/mtn: record changes from directory renames (issue1587) Bug report and initial path by Pavel Volkovitskiy <int@mtx.ru>
author Patrick Mezard <pmezard@gmail.com>
date Sat, 11 Apr 2009 23:12:42 +0200
parents aa3f61884a48
children 718c8f01feb2 3cdf4872941a
comparison
equal deleted inserted replaced
8049:99e5f97c9a97 8050:087cc65bebff
109 return certs 109 return certs
110 110
111 def mtnrenamefiles(self, files, fromdir, todir): 111 def mtnrenamefiles(self, files, fromdir, todir):
112 renamed = {} 112 renamed = {}
113 for tofile in files: 113 for tofile in files:
114 suffix = tofile.lstrip(todir) 114 if tofile.startswith(todir + '/'):
115 if todir + suffix == tofile: 115 renamed[tofile] = fromdir + tofile[len(todir):]
116 renamed[tofile] = (fromdir + suffix).lstrip("/")
117 return renamed 116 return renamed
118
119 117
120 # implement the converter_source interface: 118 # implement the converter_source interface:
121 119
122 def getheads(self): 120 def getheads(self):
123 if not self.rev: 121 if not self.rev:
155 if self.mtnisdir(toname, rev): 153 if self.mtnisdir(toname, rev):
156 renamed = self.mtnrenamefiles(self.files, fromname, toname) 154 renamed = self.mtnrenamefiles(self.files, fromname, toname)
157 for tofile, fromfile in renamed.items(): 155 for tofile, fromfile in renamed.items():
158 self.ui.debug (_("copying file in renamed dir from '%s' to '%s'") % (fromfile, tofile), '\n') 156 self.ui.debug (_("copying file in renamed dir from '%s' to '%s'") % (fromfile, tofile), '\n')
159 files[tofile] = rev 157 files[tofile] = rev
158 copies[tofile] = fromfile
160 for fromfile in renamed.values(): 159 for fromfile in renamed.values():
161 files[fromfile] = rev 160 files[fromfile] = rev
162 return (files.items(), copies) 161 return (files.items(), copies)
163 162
164 def getmode(self, name, rev): 163 def getmode(self, name, rev):