Patchwork [1,of,3] dispatch: copy inferrepo attribute to alias commands

login
register
mail settings
Submitter Yuya Nishihara
Date Jan. 6, 2016, 3:31 p.m.
Message ID <06021ff117bdcab43cfc.1452094260@mimosa>
Download mbox | patch
Permalink /patch/12570/
State Accepted
Headers show

Comments

Yuya Nishihara - Jan. 6, 2016, 3:31 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1451911205 -32400
#      Mon Jan 04 21:40:05 2016 +0900
# Node ID 06021ff117bdcab43cfc3430531985501c635739
# Parent  0735de9eefe1567c0129d2acefd4be129a4c567f
dispatch: copy inferrepo attribute to alias commands

The other attributes are copied. Let's do the same for the inferrepo.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -434,6 +434,7 @@  class cmdalias(object):
         self.help = ''
         self.norepo = True
         self.optionalrepo = False
+        self.inferrepo = False
         self.badalias = None
         self.unknowncmd = False
 
@@ -499,6 +500,8 @@  class cmdalias(object):
                 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 @@  def addaliases(ui, cmdtable):
             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 @@  def _checkshellalias(lui, ui, args, prec
         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:
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -173,6 +173,16 @@  no usage
   $ 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