Changeset 47ac907e2b8c…
Parent 7ad3aeca6803…
by
Changes to 3 files · Browse files at 47ac907e2b8c Showing diff from parent 7ad3aeca6803 Diff from another changeset...
@@ -86,34 +86,16 @@ self.flabel += _(' <i>(is a symlink)</i>')
return
- wsub, wfileinsub, sctx = \
- hglib.getDeepestSubrepoContainingFile(wfile, ctx)
- if wsub:
- topctx = ctx
- topwfile = wfile
- ctx = sctx
- wfile = wfileinsub
- if ctx2:
- # If a revision to compare to was provided, we must put it in
- # the context of the subrepo as well
- # Here we had two choices:
- # We could translate the seo
+ if ctx2:
+ # If a revision to compare to was provided, we must put it in
+ # the context of the subrepo as well
+ if ctx2._repo.root != ctx._repo.root:
wsub2, wfileinsub2, sctx2 = \
- hglib.getDeepestSubrepoContainingFile(topwfile, ctx2)
+ hglib.getDeepestSubrepoContainingFile(wfile, ctx2)
if wsub2:
ctx2 = sctx2
- else:
- # Note that this is NOT THE SAME as topctx.p1()!
- # [TODO] Perhaps we should try instead to get the context from
- # the state of the supreop at topctx.p1(), that is, something
- # such as: wsub2, wfileinsub2, ctx2 = \
- # ... hglib.getDeepestSubrepoContainingFile(topwfile, topctx.p1())
- pass # This is set below to ctx2 = ctx.p1()
- else:
- topctx = ctx
- topwfile = wfile
- absfile = repo.wjoin(os.path.join(wsub or '', wfile))
+ absfile = repo.wjoin(wfile)
if (wfile in ctx and 'l' in ctx.flags(wfile)) or \
os.path.islink(absfile):
if wfile in ctx:
@@ -213,7 +195,7 @@ out = []
_ui = uimod.ui()
- if srepo is None or (topctx.rev() is not None and ctx.rev() is not None):
+ if srepo is None or ctx.rev() is not None:
data = []
else:
_ui.pushbuffer()
@@ -225,7 +207,7 @@ out.append(u'\n')
sstatedesc = 'changed'
- if topctx.rev() is not None and ctx.rev() is not None:
+ if ctx.rev() is not None:
sparent = ctx.p1().substate.get(wfile, subrepo.nullstate)[1]
subrepochange, sstatedesc = \
genSubrepoRevChangedDescription(wfile,
@@ -286,7 +268,7 @@ return
if status in ('I', '?', 'C'):
- if topctx.rev() is None or ctx.rev() is None:
+ if ctx.rev() is None:
if status in ('I', '?'):
self.flabel += _(' <i>(is unversioned)</i>')
if os.path.getsize(absfile) > maxdiff:
|
@@ -459,11 +459,24 @@ def setPath(self, path):
"""Change path to show"""
self._treeview.setCurrentIndex(self._treemodel.indexFromPath(path))
-
+
+ def displayFile(self):
+ ctx, path = self._treemodel.fileSubrepoCtxFromPath(self.path)
+ if ctx is None:
+ ctx = self._repo[self._rev]
+ else:
+ ctx._repo.tabwidth = self._repo.tabwidth
+ ctx._repo.maxdiff = self._repo.maxdiff
+ self._fileview.setContext(ctx)
+ self._fileview.displayFile(path, self.status)
+
@pyqtSlot()
def _updatecontent(self):
- self._fileview.setContext(self._repo[self._rev])
- self._fileview.displayFile(self.path, self.status)
+ if True:
+ self.displayFile()
+ else:
+ self._fileview.setContext(self._repo[self._rev])
+ self._fileview.displayFile(self.path, self.status)
@pyqtSlot()
def _emitPathChanged(self):
|
|
@@ -32,6 +32,7 @@
self._repo = repo
self._rev = rev
+ self._subinfo = {}
assert util.all(c in 'MARSC' for c in statusfilter)
self._statusfilter = statusfilter
@@ -56,6 +57,20 @@
return index.internalPointer().path
+ def fileSubrepoCtx(self, index):
+ """Return the subrepo context of the specified index"""
+ path = self.filePath(index)
+ return self.fileSubrepoCtxFromPath(path)
+
+ def fileSubrepoCtxFromPath(self, path):
+ """Return the subrepo context of the specified file"""
+ if not path:
+ return None, path
+ for subpath in sorted(self._subinfo.keys())[::-1]:
+ if path.startswith(subpath):
+ return self._subinfo[subpath], path[len(subpath)+1:]
+ return None, path
+
def fileIcon(self, index):
ic = QApplication.style().standardIcon(
self.isDir(index) and QStyle.SP_DirIcon or QStyle.SP_FileIcon)
@@ -224,7 +239,7 @@ e.setstatus('C')
# Add subrepos to the tree
- def addrepocontentstotree(roote, ctx):
+ def addrepocontentstotree(roote, ctx, toproot=''):
subpaths = ctx.substate.keys()
for path in subpaths:
if not 'S' in self._statusfilter:
@@ -235,17 +250,17 @@ if not p in e:
e.addchild(p)
e = e[p]
-
+
p = pathelements[-1]
if not p in e:
e.addchild(p)
e = e[p]
e.setstatus('S')
-
+
# If the subrepo exists in the working directory
# and it is a mercurial subrepo,
- # add the files that it contains to the tree as well, according ot
- # the status filter
+ # add the files that it contains to the tree as well, according
+ # to the status filter
abspath = os.path.join(ctx._repo.root, path)
if os.path.isdir(abspath):
# Add subrepo files to the tree
@@ -254,17 +269,32 @@ if srev and isinstance(sub, hgsubrepo):
srepo = sub._repo
sctx = srepo[srev]
- e = addrepocontentstotree(e, sctx)
-
+
+ # Add the subrepo info to the _subinfo dictionary:
+ # The value is the subrepo context, while the key is
+ # the path of the subrepo relative to the topmost repo
+ if toproot:
+ # Note that we cannot use os.path.join() because we
+ # need path items to be separated by "/"
+ toprelpath = '/'.join([toproot, path])
+ else:
+ toprelpath = path
+ self._subinfo[toprelpath] = sctx
+
+ # Add the subrepo contents to the tree
+ e = addrepocontentstotree(e, sctx, toprelpath)
+
# Add regular files to the tree
status, uncleanpaths, files = getctxtreeinfo(ctx, self._repo)
-
+
addfilestotree(roote, files, status, uncleanpaths)
return roote
-
+
+ # Clear the _subinfo
+ self._subinfo = {}
roote = _Entry()
ctx = self._repo[self._rev]
-
+
addrepocontentstotree(roote, ctx)
roote.sort()
|
Loading...