diff mercurial/context.py @ 25600:70ac1868b707

subrepo: allow a representation of the working directory subrepo Some code cannot handle a subrepo based on the working directory (e.g. sub.dirty()), so the caller must opt in. This will be useful for archive, and perhaps some other commands. The git and svn methods where this is used may need to be fixed up on a case by case basis.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 16 Jun 2015 23:03:36 -0400
parents 183965a00c76
children 328739ea70c3
line wrap: on
line diff
--- a/mercurial/context.py	Tue Jun 16 22:13:19 2015 +0900
+++ b/mercurial/context.py	Tue Jun 16 23:03:36 2015 -0400
@@ -249,11 +249,18 @@
             return ''
 
     def sub(self, path):
+        '''return a subrepo for the stored revision of path, never wdir()'''
         return subrepo.subrepo(self, path)
 
     def nullsub(self, path, pctx):
         return subrepo.nullsubrepo(self, path, pctx)
 
+    def workingsub(self, path):
+        '''return a subrepo for the stored revision, or wdir if this is a wdir
+        context.
+        '''
+        return subrepo.subrepo(self, path, allowwdir=True)
+
     def match(self, pats=[], include=None, exclude=None, default='glob',
               listsubrepos=False, badfn=None):
         r = self._repo