changeset 27679:6822f9382b4c

dispatch: copy inferrepo attribute to alias commands The other attributes are copied. Let's do the same for the inferrepo.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 04 Jan 2016 21:40:05 +0900
parents b97004648028
children c750245c6b85
files mercurial/dispatch.py tests/test-alias.t
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Wed Jan 06 04:59:46 2016 +0000
+++ b/mercurial/dispatch.py	Mon Jan 04 21:40:05 2016 +0900
@@ -434,6 +434,7 @@
         self.help = ''
         self.norepo = True
         self.optionalrepo = False
+        self.inferrepo = False
         self.badalias = None
         self.unknowncmd = False
 
@@ -499,6 +500,8 @@
                 self.norepo = False
             if cmd in commands.optionalrepo.split(' '):
                 self.optionalrepo = True
+            if cmd in commands.inferrepo.split(' '):
+                self.inferrepo = True
             if self.help.startswith("hg " + cmd):
                 # drop prefix in old-style help lines so hg shows the alias
                 self.help = self.help[4 + len(cmd):]
@@ -557,6 +560,8 @@
             commands.norepo += ' %s' % alias
         if aliasdef.optionalrepo:
             commands.optionalrepo += ' %s' % alias
+        if aliasdef.inferrepo:
+            commands.inferrepo += ' %s' % alias
 
 def _parse(ui, args):
     options = {}
@@ -723,9 +728,11 @@
         strict = True
         norepo = commands.norepo
         optionalrepo = commands.optionalrepo
+        inferrepo = commands.inferrepo
         def restorecommands():
             commands.norepo = norepo
             commands.optionalrepo = optionalrepo
+            commands.inferrepo = inferrepo
         cmdtable = commands.table.copy()
         addaliases(lui, cmdtable)
     else:
--- a/tests/test-alias.t	Wed Jan 06 04:59:46 2016 +0000
+++ b/tests/test-alias.t	Mon Jan 04 21:40:05 2016 +0900
@@ -173,6 +173,16 @@
   $ hg commit -Amfoo
   adding foo
 
+infer repository
+
+  $ cd ..
+
+#if no-outer-repo
+  $ hg shortlog alias/foo
+  0 e63c23eaa88a | 1970-01-01 00:00 +0000
+#endif
+
+  $ cd alias
 
 with opts