--- a/mercurial/commands.py Fri Aug 11 14:50:41 2006 -0700
+++ b/mercurial/commands.py Fri Aug 11 15:50:07 2006 -0700
@@ -1825,6 +1825,7 @@
wlock = repo.wlock()
lock = repo.lock()
+ wlock = repo.wlock()
for patch in patches:
pf = os.path.join(d, patch)
@@ -1908,12 +1909,44 @@
raise util.Abort(_('no diffs found'))
files = util.patch(strip, tmpname, ui, cwd=repo.root)
+ removes = []
if len(files) > 0:
- cfiles = files
+ cfiles = files.keys()
+ copies = []
+ copts = {'after': False, 'force': False}
cwd = repo.getcwd()
if cwd:
- cfiles = [util.pathto(cwd, f) for f in files]
+ cfiles = [util.pathto(cwd, f) for f in files.keys()]
+ for f in files:
+ ctype, gp = files[f]
+ if ctype == 'RENAME':
+ copies.append((gp.oldpath, gp.path, gp.copymod))
+ removes.append(gp.oldpath)
+ elif ctype == 'COPY':
+ copies.append((gp.oldpath, gp.path, gp.copymod))
+ elif ctype == 'DELETE':
+ removes.append(gp.path)
+ for src, dst, after in copies:
+ absdst = os.path.join(repo.root, dst)
+ if not after and os.path.exists(absdst):
+ raise util.Abort(_('patch creates existing file %s') % dst)
+ if cwd:
+ src, dst = [util.pathto(cwd, f) for f in (src, dst)]
+ copts['after'] = after
+ errs, copied = docopy(ui, repo, (src, dst), copts, wlock=wlock)
+ if errs:
+ raise util.Abort(errs)
+ if removes:
+ repo.remove(removes, True, wlock=wlock)
+ for f in files:
+ ctype, gp = files[f]
+ if gp and gp.mode:
+ x = gp.mode & 0100 != 0
+ dst = os.path.join(repo.root, gp.path)
+ util.set_exec(dst, x)
addremove_lock(ui, repo, cfiles, {}, wlock=wlock)
+ files = files.keys()
+ files.extend([r for r in removes if r not in files])
repo.commit(files, message, user, date, wlock=wlock, lock=lock)
finally:
os.unlink(tmpname)