by
Changes to 12 files · Browse files at ca98dcc20b29 Showing diff from parent 7a6fc5821d9c f4b2cdbcdde5 Diff from another changeset...
@@ -569,12 +569,10 @@ self.glog_parent.custombutton.set_active(True)
self.glog_parent.reload_log(**opts)
else:
- # Else launch our own GLog instance
+ # Else launch our own glog instance
from hggtk import history
- dialog = history.GLog(self.ui, self.repo, self.cwd,
- [self.repo.root], {})
- dialog.open_with_file(self.curfile)
- dialog.display()
+ dlg = history.run(self.ui, filehist=self.curfile)
+ dlg.display()
def revert_file(self, menuitem):
'User selected file revert from the file list context menu'
|
@@ -151,8 +151,7 @@
def cmenu_file_log(self, menuitem):
from hggtk import history
- dlg = history.GLog(self.ui, self.repo, self.cwd, [self.repo.root], {})
- dlg.open_with_file(self.curpath)
+ dlg = history.run(self.ui, filehist=self.curpath)
dlg.display()
def grep_button_release(self, widget, event):
|
@@ -16,7 +16,6 @@ import atexit
from mercurial import cmdutil, util, ui, hg, commands
-from hgext import extdiff
from thgutil.i18n import _
from thgutil import settings, hglib, paths
@@ -406,43 +405,16 @@
return True, textout
- def _do_diff(self, patterns, options, modal=False):
- from hggtk import visdiff, thgconfig
- if self.ui.configbool('tortoisehg', 'vdiffnowin'):
- tools = visdiff.readtools(self.ui)
- preferred = self.ui.config('tortoisehg', 'vdiff', 'vdiff')
- if not preferred or preferred not in tools:
- Prompt(_('No visual diff configured'),
- _('Please select a visual diff application.'), self).run()
- dlg = thgconfig.ConfigDialog(self.repo.root, False)
- dlg.show_all()
- dlg.focus_field('tortoisehg.vdiff')
- dlg.run()
- dlg.hide()
- self.ui = ui.ui()
- self._parse_config()
- return
-
- file = len(patterns) == 1 and patterns[0] or ''
- diffcmd, diffopts = tools[preferred]
- opts = {'change': options.get('change')}
- if not opts['change']:
- opts['rev'] = options.get('rev')
-
- def dodiff():
- extdiff.dodiff(self.ui, self.repo, diffcmd, diffopts,
- [self.repo.wjoin(file)], opts)
-
- thread = threading.Thread(target=dodiff, name='diff:' + file)
- thread.setDaemon(True)
- thread.start()
-
- else:
- dialog = visdiff.FileSelectionDialog(patterns, options)
- dialog.show_all()
- if modal:
- dialog.run()
- dialog.hide()
+ def _do_diff(self, canonpats, options, modal=False):
+ from hggtk import visdiff
+ options['canonpats'] = canonpats
+ dialog = visdiff.run(self.ui, **options)
+ if not dialog:
+ return
+ dialog.show_all()
+ if modal:
+ dialog.run()
+ dialog.hide()
def _diff_file(self, stat, file):
self._do_diff(file and [file] or [], self.opts)
|
@@ -251,6 +251,8 @@ def gtkrun(dlgfunc, ui, *args, **opts):
portable_fork(ui, opts)
win = dlgfunc(ui, *args, **opts)
+ if not win:
+ return
global mainwindow, gtkmainalive
mainwindow = win
if hasattr(win, 'display'):
@@ -402,7 +404,10 @@
def vdiff(ui, *pats, **opts):
"""launch configured visual diff tool"""
- from hggtk.visdiff import run
+ from hggtk.visdiff import run, rawextdiff
+ if opts.get('raw'):
+ rawextdiff(ui, *pats, **opts)
+ return
gtkrun(run, ui, *pats, **opts)
### help management, adapted from mercurial.commands.help_()
@@ -662,7 +667,8 @@ ('hgtk update')),
"^vdiff": (vdiff,
[('c', 'change', '', _('changeset to view in diff tool')),
- ('r', 'rev', [], _('revisions to view in diff tool'))],
+ ('r', 'rev', [], _('revisions to view in diff tool')),
+ ('', 'raw', None, _('directly use raw extdiff command'))],
_('launch visual diff tool')),
"^version": (version,
[('v', 'verbose', None, _('print license'))],
|
@@ -221,10 +221,6 @@ menu.show_all()
return menu
- def open_with_file(self, file):
- 'Call this before display() to open with file history'
- self.opts['filehist'] = file
-
def prepare_display(self):
'Called at end of display() method'
self.ready = True
@@ -233,13 +229,13 @@ os.chdir(self.repo.root) # for paths relative to repo root
self.graphview.set_property('original-tip-revision', self.origtip)
- if 'orig-tip' in self.opts:
+ if self.opts.get('orig-tip') is not None:
origtip = self.opts['orig-tip']
if origtip != len(self.repo):
self.origtip = origtip
self.graphview.set_property('original-tip-revision', origtip)
self.newbutton.set_active(True)
- elif 'filehist' in self.opts:
+ elif self.opts.get('filehist') is not None:
self.custombutton.set_active(True)
self.reload_log(pats = [self.opts['filehist']])
elif 'revrange' in self.opts:
@@ -960,12 +956,13 @@ return True
def run(ui, *pats, **opts):
- limit = opts.get('limit')
cmdoptions = {
'follow':False, 'follow-first':False, 'copies':False, 'keyword':[],
- 'limit':limit, 'rev':[], 'removed':False, 'no_merges':False,
+ 'limit':0, 'rev':[], 'removed':False, 'no_merges':False,
'date':None, 'only_merges':None, 'prune':[], 'git':False,
- 'verbose':False, 'include':[], 'exclude':[]
+ 'verbose':False, 'include':[], 'exclude':[], 'from-synch':False,
+ 'orig-tip':None, 'filehist':None
}
+ cmdoptions.update(opts)
pats = hglib.canonpaths(pats)
return GLog(ui, None, None, pats, cmdoptions)
|
@@ -148,7 +148,7 @@ self.grapher = None
return
- if 'filehist' in opts:
+ if opts.get('filehist') is not None:
self.grapher = filelog_grapher(self.repo, opts['filehist'])
elif graphcol:
end = 0
|
@@ -774,12 +774,13 @@ if not paths:
return
wfile = self.filemodel[paths[0]][FM_PATH]
+ pfile = util.pconvert(wfile)
difftext = []
if self.merging:
difftext = [_('===== Diff to first parent =====\n')]
wctx = self.repo[None]
pctxs = wctx.parents()
- matcher = cmdutil.matchfiles(self.repo, [wfile])
+ matcher = cmdutil.matchfiles(self.repo, [pfile])
for s in patch.diff(self.repo, pctxs[0].node(), None,
match=matcher, opts=patch.diffopts(self.ui, self.opts)):
difftext.extend(s.splitlines(True))
@@ -834,7 +835,8 @@ difftext = cStringIO.StringIO()
ctx = self.repo[self._node1]
try:
- fctx = ctx.filectx(wfile)
+ pfile = util.pconvert(wfile)
+ fctx = ctx.filectx(pfile)
except hglib.LookupError:
fctx = None
if fctx and fctx.size() > hglib.getmaxdiffsize(self.ui):
@@ -847,7 +849,7 @@ difftext.writelines(lines)
difftext.seek(0)
else:
- matcher = cmdutil.matchfiles(self.repo, [wfile])
+ matcher = cmdutil.matchfiles(self.repo, [pfile])
diffopts = mdiff.diffopts(git=True, nodates=True)
for s in patch.diff(self.repo, self._node1, self._node2,
match=matcher, opts=diffopts):
|
@@ -340,7 +340,7 @@
def _view_pulled_changes(self, button):
opts = {'orig-tip' : self.origchangecount, 'from-synch' : True}
- dlg = history.GLog(self.ui, None, None, [], opts)
+ dlg = history.run(self.ui, **opts)
dlg.display()
def _update_to_tip(self, button):
|
@@ -273,5 +273,58 @@ tools[cmd] = [path, diffopts]
return tools
+def rawextdiff(ui, *pats, **opts):
+ 'launch raw extdiff command, block until finish'
+ from hgext import extdiff
+ try:
+ repo = hg.repository(ui, path=paths.find_root())
+ except hglib.RepoError:
+ # hgtk should catch this earlier
+ ui.warn(_('No repository found here') + '\n')
+ return
+ tools = readtools(ui)
+ preferred = ui.config('tortoisehg', 'vdiff', 'vdiff')
+ try:
+ diffcmd, diffopts = tools[preferred]
+ except KeyError:
+ ui.warn(_('Extdiff command not recognized\n'))
+ return
+ pats = hglib.canonpaths(pats)
+ ret = extdiff.dodiff(ui, repo, diffcmd, diffopts, pats, opts)
+ if ret == 0:
+ gdialog.Prompt(_('No file changes'),
+ _('There are no file changes to view'), None).run()
+
def run(ui, *pats, **opts):
- return FileSelectionDialog(hglib.canonpaths(pats), opts)
+ if ui.configbool('tortoisehg', 'vdiffnowin'):
+ import sys
+ # Spawn background process and exit
+ if hasattr(sys, "frozen"):
+ args = [sys.argv[0]]
+ else:
+ args = [sys.executable] + [sys.argv[0]]
+ args.extend(['vdiff', '--nofork', '--raw'])
+ revs = opts.get('rev', [])
+ change = opts.get('change')
+ if change:
+ args.extend(['--change', str(change)])
+ if len(revs) == 1:
+ args.extend(['--change', str(revs[0])])
+ else:
+ for r in revs:
+ args.extend(['--rev', str(r)])
+ args.extend(pats)
+ args.extend(opts.get('canonpats', []))
+ if os.name == 'nt':
+ args = ['"%s"' % arg for arg in args]
+ oldcwd = os.getcwd()
+ root = paths.find_root()
+ os.chdir(root)
+ os.spawnv(os.P_NOWAIT, sys.executable, args)
+ os.chdir(oldcwd)
+ return None
+ else:
+ pats = hglib.canonpaths(pats)
+ if opts.get('canonpats'):
+ pats = list(pats) + opts['canonpats']
+ return FileSelectionDialog(pats, opts)
|
@@ -31,8 +31,10 @@
Dirstate* Dirstatecache::get(
- const std::string& hgroot, const std::string& cwd)
+ const std::string& hgroot, const std::string& cwd, bool& unset)
{
+ unset = false;
+
typedef std::list<E>::iterator Iter;
Iter iter = cache().begin();
@@ -92,6 +94,8 @@
if (iter->dstate)
{
+ unset = iter->unset;
+
if (!new_stat)
return iter->dstate;
@@ -108,15 +112,27 @@ TDEBUG_TRACE("Dirstatecache::get: reading " << hgroot);
}
- bool unset = false;
+ unset = false;
unsigned tc0 = GetTickCount();
std::auto_ptr<Dirstate> ds = Dirstate::read(path, unset);
unsigned tc1 = GetTickCount();
+ bool request_thgstatus_update = true;
+
if (unset)
{
- TDEBUG_TRACE("Dirstatecache::get: has unset entries");
+ if (iter->unset)
+ {
+ TDEBUG_TRACE(
+ "Dirstatecache::get: **** old and new have unset entries");
+ request_thgstatus_update = false;
+ }
+ else
+ {
+ TDEBUG_TRACE("Dirstatecache::get: new has unset entries");
+ }
}
+
iter->unset = unset;
delete iter->dstate;
@@ -129,7 +145,15 @@ iter->dstate_mtime = stat.mtime;
iter->dstate_size = stat.size;
- Thgstatus::update(cwd);
+ if (request_thgstatus_update)
+ {
+ TDEBUG_TRACE("Dirstatecache::get: calling Thgstatus::update");
+ Thgstatus::update(cwd);
+ }
+ else
+ {
+ TDEBUG_TRACE("Dirstatecache::get: omitting Thgstatus::update");
+ }
return iter->dstate;
}
|
@@ -47,7 +47,8 @@ static std::list<E>& cache();
public:
- static Dirstate* get(const std::string& hgroot, const std::string& cwd);
+ static Dirstate* get(
+ const std::string& hgroot, const std::string& cwd, bool& unset);
static void invalidate(const std::string& hgroot);
};
|
@@ -182,11 +182,13 @@ return 0;
}
+ bool unset = false;
+
if (cur.isdir)
{
if (!relpath.empty())
{
- Dirstate* pds2 = Dirstatecache::get(cur.hgroot, cur.basedir);
+ Dirstate* pds2 = Dirstatecache::get(cur.hgroot, cur.basedir, unset);
if (pds2 && !pds2->root().getdir(relpath))
{
last = cur;
@@ -198,7 +200,7 @@ }
else
{
- Dirstate* pds = Dirstatecache::get(cur.hgroot, cur.basedir);
+ Dirstate* pds = Dirstatecache::get(cur.hgroot, cur.basedir, unset);
if (!pds)
{
TDEBUG_TRACE("HgQueryDirstate: Dirstatecache::get("
@@ -245,7 +247,17 @@
if (basedir_status != 'M')
{
- Thgstatus::update(cur.hgroot);
+ if (unset)
+ {
+ TDEBUG_TRACE(
+ "HgQueryDirstate: omitting Thgstatus::update");
+ }
+ else
+ {
+ TDEBUG_TRACE(
+ "HgQueryDirstate: calling Thgstatus::update");
+ Thgstatus::update(cur.hgroot);
+ }
}
}
}
|
Loading...