[PATCH] subrepo: fix exception on revert when "all" option is omitted

Yuya Nishihara yuya at tcha.org
Mon Apr 15 10:52:43 CDT 2013


# HG changeset patch
# User Yuya Nishihara <yuya at 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.

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


More information about the Mercurial-devel mailing list