# HG changeset patch # User Patrick Mezard # Date 1304869709 -7200 # Node ID d035ede73434e256d8096d9da8c1b27cf66f6c3b # Parent d04ba50e104defa88aef377fb572a0553031f2eb mq: explicitly updatedir() even if patch() fails It already works that way in practice, and we intend to merge updatedir() into patch(). diff -r d04ba50e104d -r d035ede73434 hgext/mq.py --- a/hgext/mq.py Fri May 06 19:55:46 2011 +0300 +++ b/hgext/mq.py Sun May 08 17:48:29 2011 +0200 @@ -614,16 +614,18 @@ patchfile: name of patch file''' files = {} try: - fuzz = patchmod.patch(patchfile, self.ui, strip=1, cwd=repo.root, - files=files, eolmode=None) + try: + fuzz = patchmod.patch(patchfile, self.ui, strip=1, + cwd=repo.root, files=files, eolmode=None) + finally: + files = cmdutil.updatedir(self.ui, repo, files) + return (True, files, fuzz) except Exception, inst: self.ui.note(str(inst) + '\n') if not self.ui.verbose: self.ui.warn(_("patch failed, unable to continue (try -v)\n")) return (False, files, False) - return (True, files, fuzz) - def apply(self, repo, series, list=False, update_status=True, strict=False, patchdir=None, merge=None, all_files=None): wlock = lock = tr = None @@ -707,7 +709,6 @@ p1, p2 = repo.dirstate.parents() repo.dirstate.setparents(p1, merge) - files = cmdutil.updatedir(self.ui, repo, files) match = cmdutil.matchfiles(repo, files or []) n = repo.commit(message, ph.user, ph.date, match=match, force=True) @@ -2280,7 +2281,6 @@ (patchsuccess, files, fuzz) = q.patch(repo, pf) if not patchsuccess: raise util.Abort(_('error folding patch %s') % p) - cmdutil.updatedir(ui, repo, files) if not message: ph = patchheader(q.join(parent), q.plainmode) diff -r d04ba50e104d -r d035ede73434 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Fri May 06 19:55:46 2011 +0300 +++ b/mercurial/cmdutil.py Sun May 08 17:48:29 2011 +0200 @@ -335,7 +335,7 @@ def updatedir(ui, repo, patches, similarity=0): '''Update dirstate after patch application according to metadata''' if not patches: - return + return [] copies = [] removes = set() cfiles = patches.keys() diff -r d04ba50e104d -r d035ede73434 tests/test-mq-missingfiles.t --- a/tests/test-mq-missingfiles.t Fri May 06 19:55:46 2011 +0300 +++ b/tests/test-mq-missingfiles.t Sun May 08 17:48:29 2011 +0200 @@ -101,8 +101,8 @@ applying changeb unable to find 'b' for patching 1 out of 1 hunks FAILED -- saving rejects to file b.rej + b: No such file or directory patch failed, unable to continue (try -v) - b: No such file or directory patch failed, rejects left in working dir errors during apply, please fix and refresh changeb [2]