Patchwork subrepo: fix exception on revert when "all" option is omitted

login
register
mail settings
Submitter Yuya Nishihara
Date April 15, 2013, 3:52 p.m.
Message ID <27e8dfc2c33868b49c9e.1366041163@gimlet>
Download mbox | patch
Permalink /patch/1317/
State Accepted
Commit 27e8dfc2c33868b49c9e6b2c2d8279ce92558592
Headers show

Comments

Yuya Nishihara - April 15, 2013, 3:52 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1366037577 -32400
#      Mon Apr 15 23:52:57 2013 +0900
# Node ID 27e8dfc2c33868b49c9e6b2c2d8279ce92558592
# Parent  6891e361bec6831ada94b7c2b49950769aba7be9
subrepo: fix exception on revert when "all" option is omitted

Since fafdff7e9c43, backout does not set opts['all'], which causes KeyError
at hgsubrepo.revert.
Yuya Nishihara - April 15, 2013, 4:18 p.m.
On Mon, 15 Apr 2013 11:02:56 -0500, Kevin Bullock wrote:
> On Apr 15, 2013, at 10:52 AM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1366037577 -32400
> > #      Mon Apr 15 23:52:57 2013 +0900
> > # Node ID 27e8dfc2c33868b49c9e6b2c2d8279ce92558592
> > # Parent  6891e361bec6831ada94b7c2b49950769aba7be9
> > subrepo: fix exception on revert when "all" option is omitted
> > 
> > Since fafdff7e9c43, backout does not set opts['all'], which causes KeyError
> > at hgsubrepo.revert.
> 
> Is there a bug filed for this?

I searched the bugzilla, but nothing found. I just hit this exception today.

Regards,

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -764,7 +764,7 @@  class hgsubrepo(abstractsubrepo):
             opts['rev'] = substate[1]
 
             pats = []
-            if not opts['all']:
+            if not opts.get('all'):
                 pats = ['set:modified()']
             self.filerevert(ui, *pats, **opts)
 
@@ -774,7 +774,7 @@  class hgsubrepo(abstractsubrepo):
     def filerevert(self, ui, *pats, **opts):
         ctx = self._repo[opts['rev']]
         parents = self._repo.dirstate.parents()
-        if opts['all']:
+        if opts.get('all'):
             pats = ['set:modified()']
         else:
             pats = []
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -461,6 +461,20 @@  update
   $ hg ci -m13
   committing subrepository t
 
+backout calls revert internally with minimal opts, which should not raise
+KeyError
+
+  $ hg backout ".^"
+  reverting .hgsubstate
+  reverting subrepo s
+  reverting s/a
+  reverting subrepo ss
+  reverting subrepo t
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg up -C # discard changes
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
 pull
 
   $ cd ../tc