# HG changeset patch # User Patrick Mezard # Date 1229035003 -3600 # Node ID b3ae5d52c405453c14856fa39cea2a7b5357c249 # Parent d8cd79fbed3c7b358dd820ff5dee44a7cff362bc# Parent 8e76e9f67cb3414f9b7042435758d375dc505ea2 Merge with crew-stable diff -r d8cd79fbed3c -r b3ae5d52c405 mercurial/patch.py --- a/mercurial/patch.py Wed Dec 10 16:29:53 2008 +0000 +++ b/mercurial/patch.py Thu Dec 11 23:36:43 2008 +0100 @@ -22,17 +22,20 @@ # helper functions -def copyfile(src, dst, basedir=None): - if not basedir: - basedir = os.getcwd() - - abssrc, absdst = [os.path.join(basedir, n) for n in (src, dst)] +def copyfile(src, dst, basedir): + abssrc, absdst = [util.canonpath(basedir, basedir, x) for x in [src, dst]] if os.path.exists(absdst): raise util.Abort(_("cannot create %s: destination already exists") % dst) - if not os.path.isdir(basedir): - os.makedirs(basedir) + dstdir = os.path.dirname(absdst) + if dstdir and not os.path.isdir(dstdir): + try: + os.makedirs(dstdir) + except IOError: + raise util.Abort( + _("cannot create %s: unable to create destination directory") + % dst) util.copyfile(abssrc, absdst) @@ -977,9 +980,7 @@ cwd = os.getcwd() for gp in gitpatches: if gp.op in ('COPY', 'RENAME'): - src, dst = [util.canonpath(cwd, cwd, x) - for x in [gp.oldpath, gp.path]] - copyfile(src, dst) + copyfile(gp.oldpath, gp.path, cwd) changed[gp.path] = gp else: raise util.Abort(_('unsupported parser state: %s') % state) diff -r d8cd79fbed3c -r b3ae5d52c405 tests/test-mq-missingfiles --- a/tests/test-mq-missingfiles Wed Dec 10 16:29:53 2008 +0000 +++ b/tests/test-mq-missingfiles Thu Dec 11 23:36:43 2008 +0100 @@ -71,3 +71,15 @@ cat b.rej cd .. +echo % test push creating directory during git copy or rename +hg init missingdir +cd missingdir +echo a > a +hg ci -Am adda +mkdir d +hg copy a d/a2 +hg mv a d/a +hg qnew -g -f patch +hg qpop +hg qpush +cd .. diff -r d8cd79fbed3c -r b3ae5d52c405 tests/test-mq-missingfiles.out --- a/tests/test-mq-missingfiles.out Wed Dec 10 16:29:53 2008 +0000 +++ b/tests/test-mq-missingfiles.out Thu Dec 11 23:36:43 2008 +0100 @@ -47,3 +47,8 @@ literal 2 Jc${No0000400IC2 +% test push creating directory during git copy or rename +adding a +Patch queue now empty +applying patch +Now at: patch