comparison hgext/convert/monotone.py @ 8123:933b874e402f

convert/mtn: handle files moved in a moved directory (issue1619/2)
author Patrick Mezard <pmezard@gmail.com>
date Tue, 21 Apr 2009 22:31:16 +0200
parents d8229670710f
children d883bfbd2e60
comparison
equal deleted inserted replaced
8101:d8229670710f 8123:933b874e402f
120 120
121 def getchanges(self, rev): 121 def getchanges(self, rev):
122 #revision = self.mtncmd("get_revision %s" % rev).split("\n\n") 122 #revision = self.mtncmd("get_revision %s" % rev).split("\n\n")
123 revision = self.mtnrun("get_revision", rev).split("\n\n") 123 revision = self.mtnrun("get_revision", rev).split("\n\n")
124 files = {} 124 files = {}
125 addedfiles = {} 125 ignoremove = {}
126 renameddirs = [] 126 renameddirs = []
127 copies = {} 127 copies = {}
128 for e in revision: 128 for e in revision:
129 m = self.add_file_re.match(e) 129 m = self.add_file_re.match(e)
130 if m: 130 if m:
131 files[m.group(1)] = rev 131 files[m.group(1)] = rev
132 addedfiles[m.group(1)] = rev 132 ignoremove[m.group(1)] = rev
133 m = self.patch_re.match(e) 133 m = self.patch_re.match(e)
134 if m: 134 if m:
135 files[m.group(1)] = rev 135 files[m.group(1)] = rev
136 # Delete/rename is handled later when the convert engine 136 # Delete/rename is handled later when the convert engine
137 # discovers an IOError exception from getfile, 137 # discovers an IOError exception from getfile,
142 m = self.rename_re.match(e) 142 m = self.rename_re.match(e)
143 if m: 143 if m:
144 toname = m.group(2) 144 toname = m.group(2)
145 fromname = m.group(1) 145 fromname = m.group(1)
146 if self.mtnisfile(toname, rev): 146 if self.mtnisfile(toname, rev):
147 ignoremove[toname] = 1
147 copies[toname] = fromname 148 copies[toname] = fromname
148 files[toname] = rev 149 files[toname] = rev
149 files[fromname] = rev 150 files[fromname] = rev
150 elif self.mtnisdir(toname, rev): 151 elif self.mtnisdir(toname, rev):
151 renameddirs.append((fromname, toname)) 152 renameddirs.append((fromname, toname))
153 # Directory renames can be handled only once we have recorded 154 # Directory renames can be handled only once we have recorded
154 # all new files 155 # all new files
155 for fromdir, todir in renameddirs: 156 for fromdir, todir in renameddirs:
156 renamed = {} 157 renamed = {}
157 for tofile in self.files: 158 for tofile in self.files:
158 if tofile in addedfiles: 159 if tofile in ignoremove:
159 continue 160 continue
160 if tofile.startswith(todir + '/'): 161 if tofile.startswith(todir + '/'):
161 renamed[tofile] = fromdir + tofile[len(todir):] 162 renamed[tofile] = fromdir + tofile[len(todir):]
162 for tofile, fromfile in renamed.items(): 163 for tofile, fromfile in renamed.items():
163 self.ui.debug (_("copying file in renamed dir from '%s' to '%s'") 164 self.ui.debug (_("copying file in renamed dir from '%s' to '%s'")