##// END OF EJS Templates
patch: break import cycle with cmdutil...
Martin Geisler -
r12266:00658492 default
parent child Browse files
Show More
@@ -685,7 +685,7 b' class queue(object):'
685 p1, p2 = repo.dirstate.parents()
685 p1, p2 = repo.dirstate.parents()
686 repo.dirstate.setparents(p1, merge)
686 repo.dirstate.setparents(p1, merge)
687
687
688 files = patch.updatedir(self.ui, repo, files)
688 files = cmdutil.updatedir(self.ui, repo, files)
689 match = cmdutil.matchfiles(repo, files or [])
689 match = cmdutil.matchfiles(repo, files or [])
690 n = repo.commit(message, ph.user, ph.date, match=match, force=True)
690 n = repo.commit(message, ph.user, ph.date, match=match, force=True)
691
691
@@ -2134,7 +2134,7 b' def fold(ui, repo, *files, **opts):'
2134 (patchsuccess, files, fuzz) = q.patch(repo, pf)
2134 (patchsuccess, files, fuzz) = q.patch(repo, pf)
2135 if not patchsuccess:
2135 if not patchsuccess:
2136 raise util.Abort(_('error folding patch %s') % p)
2136 raise util.Abort(_('error folding patch %s') % p)
2137 patch.updatedir(ui, repo, files)
2137 cmdutil.updatedir(ui, repo, files)
2138
2138
2139 if not message:
2139 if not message:
2140 ph = patchheader(q.join(parent), q.plainmode)
2140 ph = patchheader(q.join(parent), q.plainmode)
@@ -497,7 +497,7 b' def dorecord(ui, repo, commitfunc, *pats'
497 pfiles = {}
497 pfiles = {}
498 patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
498 patch.internalpatch(fp, ui, 1, repo.root, files=pfiles,
499 eolmode=None)
499 eolmode=None)
500 patch.updatedir(ui, repo, pfiles)
500 cmdutil.updatedir(ui, repo, pfiles)
501 except patch.PatchError, err:
501 except patch.PatchError, err:
502 s = str(err)
502 s = str(err)
503 if s:
503 if s:
@@ -225,7 +225,7 b' class transplanter(object):'
225 % revlog.hex(node))
225 % revlog.hex(node))
226 return None
226 return None
227 finally:
227 finally:
228 files = patch.updatedir(self.ui, repo, files)
228 files = cmdutil.updatedir(self.ui, repo, files)
229 except Exception, inst:
229 except Exception, inst:
230 seriespath = os.path.join(self.path, 'series')
230 seriespath = os.path.join(self.path, 'series')
231 if os.path.exists(seriespath):
231 if os.path.exists(seriespath):
@@ -329,6 +329,49 b' def addremove(repo, pats=[], opts={}, dr'
329 finally:
329 finally:
330 wlock.release()
330 wlock.release()
331
331
332 def updatedir(ui, repo, patches, similarity=0):
333 '''Update dirstate after patch application according to metadata'''
334 if not patches:
335 return
336 copies = []
337 removes = set()
338 cfiles = patches.keys()
339 cwd = repo.getcwd()
340 if cwd:
341 cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
342 for f in patches:
343 gp = patches[f]
344 if not gp:
345 continue
346 if gp.op == 'RENAME':
347 copies.append((gp.oldpath, gp.path))
348 removes.add(gp.oldpath)
349 elif gp.op == 'COPY':
350 copies.append((gp.oldpath, gp.path))
351 elif gp.op == 'DELETE':
352 removes.add(gp.path)
353
354 wctx = repo[None]
355 for src, dst in copies:
356 wctx.copy(src, dst)
357 if (not similarity) and removes:
358 wctx.remove(sorted(removes), True)
359
360 for f in patches:
361 gp = patches[f]
362 if gp and gp.mode:
363 islink, isexec = gp.mode
364 dst = repo.wjoin(gp.path)
365 # patch won't create empty files
366 if gp.op == 'ADD' and not os.path.exists(dst):
367 flags = (isexec and 'x' or '') + (islink and 'l' or '')
368 repo.wwrite(gp.path, '', flags)
369 util.set_flags(dst, islink, isexec)
370 addremove(repo, cfiles, similarity=similarity)
371 files = patches.keys()
372 files.extend([r for r in removes if r not in files])
373 return sorted(files)
374
332 def copy(ui, repo, pats, opts, rename=False):
375 def copy(ui, repo, pats, opts, rename=False):
333 # called with the repo lock held
376 # called with the repo lock held
334 #
377 #
@@ -2301,8 +2301,8 b' def import_(ui, repo, patch1, *patches, '
2301 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2301 patch.patch(tmpname, ui, strip=strip, cwd=repo.root,
2302 files=files, eolmode=None)
2302 files=files, eolmode=None)
2303 finally:
2303 finally:
2304 files = patch.updatedir(ui, repo, files,
2304 files = cmdutil.updatedir(ui, repo, files,
2305 similarity=sim / 100.0)
2305 similarity=sim / 100.0)
2306 if not opts.get('no_commit'):
2306 if not opts.get('no_commit'):
2307 if opts.get('exact'):
2307 if opts.get('exact'):
2308 m = None
2308 m = None
@@ -11,7 +11,7 b' import tempfile, zlib'
11
11
12 from i18n import _
12 from i18n import _
13 from node import hex, nullid, short
13 from node import hex, nullid, short
14 import base85, cmdutil, mdiff, util, diffhelpers, copies, encoding
14 import base85, mdiff, util, diffhelpers, copies, encoding
15
15
16 gitre = re.compile('diff --git a/(.*) b/(.*)')
16 gitre = re.compile('diff --git a/(.*) b/(.*)')
17
17
@@ -444,8 +444,8 b' class patchfile(object):'
444
444
445 def writelines(self, fname, lines):
445 def writelines(self, fname, lines):
446 # Ensure supplied data ends in fname, being a regular file or
446 # Ensure supplied data ends in fname, being a regular file or
447 # a symlink. updatedir() will -too magically- take care of
447 # a symlink. cmdutil.updatedir will -too magically- take care
448 # setting it to the proper type afterwards.
448 # of setting it to the proper type afterwards.
449 islink = os.path.islink(fname)
449 islink = os.path.islink(fname)
450 if islink:
450 if islink:
451 fp = cStringIO.StringIO()
451 fp = cStringIO.StringIO()
@@ -1129,8 +1129,8 b' def applydiff(ui, fp, changed, strip=1, '
1129 read in binary mode. Otherwise, line endings are ignored when
1129 read in binary mode. Otherwise, line endings are ignored when
1130 patching then normalized according to 'eolmode'.
1130 patching then normalized according to 'eolmode'.
1131
1131
1132 Callers probably want to call 'updatedir' after this to apply
1132 Callers probably want to call 'cmdutil.updatedir' after this to
1133 certain categories of changes not done by this function.
1133 apply certain categories of changes not done by this function.
1134 """
1134 """
1135 return _applydiff(
1135 return _applydiff(
1136 ui, fp, patchfile, copyfile,
1136 ui, fp, patchfile, copyfile,
@@ -1196,49 +1196,6 b' def _applydiff(ui, fp, patcher, copyfn, '
1196 return -1
1196 return -1
1197 return err
1197 return err
1198
1198
1199 def updatedir(ui, repo, patches, similarity=0):
1200 '''Update dirstate after patch application according to metadata'''
1201 if not patches:
1202 return
1203 copies = []
1204 removes = set()
1205 cfiles = patches.keys()
1206 cwd = repo.getcwd()
1207 if cwd:
1208 cfiles = [util.pathto(repo.root, cwd, f) for f in patches.keys()]
1209 for f in patches:
1210 gp = patches[f]
1211 if not gp:
1212 continue
1213 if gp.op == 'RENAME':
1214 copies.append((gp.oldpath, gp.path))
1215 removes.add(gp.oldpath)
1216 elif gp.op == 'COPY':
1217 copies.append((gp.oldpath, gp.path))
1218 elif gp.op == 'DELETE':
1219 removes.add(gp.path)
1220
1221 wctx = repo[None]
1222 for src, dst in copies:
1223 wctx.copy(src, dst)
1224 if (not similarity) and removes:
1225 wctx.remove(sorted(removes), True)
1226
1227 for f in patches:
1228 gp = patches[f]
1229 if gp and gp.mode:
1230 islink, isexec = gp.mode
1231 dst = repo.wjoin(gp.path)
1232 # patch won't create empty files
1233 if gp.op == 'ADD' and not os.path.exists(dst):
1234 flags = (isexec and 'x' or '') + (islink and 'l' or '')
1235 repo.wwrite(gp.path, '', flags)
1236 util.set_flags(dst, islink, isexec)
1237 cmdutil.addremove(repo, cfiles, similarity=similarity)
1238 files = patches.keys()
1239 files.extend([r for r in removes if r not in files])
1240 return sorted(files)
1241
1242 def externalpatch(patcher, args, patchname, ui, strip, cwd, files):
1199 def externalpatch(patcher, args, patchname, ui, strip, cwd, files):
1243 """use <patcher> to apply <patchname> to the working directory.
1200 """use <patcher> to apply <patchname> to the working directory.
1244 returns whether patch was applied with fuzz factor."""
1201 returns whether patch was applied with fuzz factor."""
General Comments 0
You need to be logged in to leave comments. Login now