Changeset bc93972daa6d…
Parent c7a36a455451…
by
Changes to 4 files · Browse files at bc93972daa6d Showing diff from parent c7a36a455451 Diff from another changeset...
@@ -191,6 +191,16 @@
def load_patch_details(self, patchfile):
'Load specified patch details into buffer and file list'
+ pf = open(patchfile)
+ self.load_patch_details_from_file_object(pf, patchfile)
+
+ def load_patch_details_from_file_object(self, pf, patchfile, isTemp=False):
+ """ Load patch details into buffer and file list
+ :param pf: open file object
+ :param patchfile: path and name of patch file
+ :param isTemp: if True, then pf is a temporary file
+ and patchfile does not exist
+ """
self._filelist.clear()
self._filelist.append(('*', _('[All Files]'), ''))
@@ -198,7 +208,11 @@ self.currev = -1
self.curphunks = {}
self.curpatch = patchfile
- pf = open(self.curpatch)
+ if isTemp:
+ # pf is a temporary, so update panel cache while we can
+ patch_ctx = csinfo.patchctx(patchfile, self.repo, patchHandle=pf)
+ self.summarypanel.update(patch_ctx, self.patchstyle)
+ pf.seek(0)
def get_path(a, b):
type = (a == '/dev/null') and 'A' or 'M'
type = (b == '/dev/null') and 'R' or type
|
@@ -136,18 +136,31 @@
class patchctx(object):
- def __init__(self, patchpath, repo):
+ def __init__(self, patchpath, repo, patchHandle=None):
+ """ Read patch context from file
+ :param patchHandle: If set, then the patch is a temporary.
+ The provided handle is used to read the patch and
+ the patchpath contains the name of the patch.
+ The handle is NOT closed.
+ """
self._path = patchpath
self._patchname = os.path.basename(patchpath)
self._repo = repo
- pf = open(patchpath)
+ if patchHandle:
+ pf = patchHandle
+ pf_start_pos = pf.tell()
+ else:
+ pf = open(patchpath)
try:
data = patch.extract(self._repo.ui, pf)
tmpfile, msg, user, date, branch, node, p1, p2 = data
if tmpfile:
os.unlink(tmpfile)
finally:
- pf.close()
+ if patchHandle:
+ pf.seek(pf_start_pos)
+ else:
+ pf.close()
if not msg and hasattr(repo, 'mq'):
# attempt to get commit message
from hgext import mq
@@ -469,6 +482,13 @@ return self.info.get_widget(item, self, self.ctx, self.custom, **kargs)
def update(self, target=None, custom=None, repo=None):
+ self.ctx = None
+ if type(target) == patchctx:
+ # If a patchctx is specified as target, use it instead
+ # of creating a context from revision or patch file
+ self.ctx = target
+ target = None
+ self.target = None
if target is None:
target = self.target
if target is not None:
@@ -480,7 +500,8 @@ repo = self.repo
if repo is not None:
self.repo = repo
- self.ctx = create_context(repo, target)
+ if self.ctx is None:
+ self.ctx = create_context(repo, target)
if self.ctx is None:
return False # cannot update
return True
|
@@ -834,6 +834,22 @@ else:
self.goto_rev(revid)
+ def pbranch_selected(self, pbranchwidget, revid, patchname):
+ 'if revid < 0 then the patch is listed in .hg/pgraph but not in repo'
+ self.stbar.set_status_text('')
+ pf = tempfile.TemporaryFile()
+ try:
+ try:
+ pf.writelines(pbranchwidget.pdiff(patchname))
+ except (util.Abort, hglib.RepoError), e:
+ self.stbar.set_status_text(str(e))
+ return
+ self.currevid = self.lastrevid = None
+ pf.seek(0)
+ self.changeview.load_patch_details_from_file_object(pf, patchname, isTemp=True)
+ finally:
+ pf.close()
+
def repo_invalidated(self, widget):
'Emitted from MQWidget and PBranchWidget'
self.reload_log()
@@ -1557,6 +1573,7 @@ # create PBranchWidget
self.pbranchwidget = thgpbranch.PBranchWidget(
self, self.repo, self.stbar, accelgroup, self.tooltips)
+ self.pbranchwidget.connect('patch-selected', self.pbranch_selected)
self.pbranchwidget.connect('repo-invalidated', self.repo_invalidated)
def wrapframe(widget):
|
@@ -73,6 +73,10 @@ 'repo-invalidated': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE,
()),
+ 'patch-selected': (gobject.SIGNAL_RUN_FIRST,
+ gobject.TYPE_NONE,
+ (int, # revision number for patch head
+ str)) # patch name
}
def __init__(self, parentwin, repo, statusbar, accelgroup=None, tooltips=None):
@@ -148,6 +152,7 @@ # To support old PyGTK (<2.12)
if hasattr(self.list, 'set_tooltip_column'):
self.list.set_tooltip_column(M_MSGESC)
+ self.list.connect('cursor-changed', self.list_sel_changed)
self.list.connect('button-press-event', self.list_pressed)
self.list.connect('row-activated', self.list_row_activated)
self.list.connect('size-allocate', self.list_size_allocated)
@@ -396,6 +401,18 @@ cmdline = ['hg', 'peditmessage', patch_name]
self.cmd.execute(cmdline, self.cmd_done)
+ def pdiff(self, patch_name):
+ """
+ [pbranch] Execute 'pdiff --tips' command.
+
+ :param patch_name: Name of patch-branch
+ :retv: list of lines of generated patch
+ """
+ opts = {}
+ mgr = self.pbranch.patchmanager(self.repo.ui, self.repo, opts)
+ graph = mgr.graphattips()
+ return graph.diff(patch_name, None, opts)
+
def pnew_ui(self):
"""
Create new patch.
|
Loading...