comparison mercurial/cmdutil.py @ 12266:00658492e2aa

patch: break import cycle with cmdutil The patch module imported cmdutil but used it only in updatedir.
author Martin Geisler <mg@lazybytes.net>
date Mon, 13 Sep 2010 13:08:09 +0200
parents affec9fb56ef
children 877236cdd437
comparison
equal deleted inserted replaced
12265:1ed2dc9d4368 12266:00658492e2aa
327 for new, old in copies.iteritems(): 327 for new, old in copies.iteritems():
328 wctx.copy(old, new) 328 wctx.copy(old, new)
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 #
335 # hgsep => pathname that uses "/" to separate directories 378 # hgsep => pathname that uses "/" to separate directories
336 # ossep => pathname that uses os.sep to separate directories 379 # ossep => pathname that uses os.sep to separate directories