by
Changes to 7 files · Browse files at e32407c7a099 Showing diff from parent cb03cecd4876 2c98ae1e0f42 Diff from another changeset...
@@ -1,7 +1,7 @@ @echo off
-:: calls hg thgstatus for all directories in current dir
-
+:: calls hgtk thgstatus for all directories in current dir
+
for /F "tokens=*" %%G in ('dir /b /A:D') do (
- echo %%G
- hg -R %%G thgstatus --notify %%G)
+ echo updating %%G
+ call hgtk -R %%G thgstatus --notify %%G)
|
|
|
@@ -1,114 +0,0 @@ - # thgstatus.py - TortoiseHg status cache extension for Mercurial
-#
-# Copyright (C) 2009 Adrian Buehlmann
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-'''update directory status cache for TortoiseHg'''
-
-from mercurial.i18n import _
-from mercurial import commands
-import os
-import time
-
-def cachefilepath(repo):
- return repo.join("thgstatus")
-
-def dirname(f):
- return f[:max(0, f.rfind("/"))]
-
-def showentry(f, e):
- f("%s %s\n" % (e[0], e[1:-1]))
-
-def thgstatus(ui, repo, **opts):
- '''update directory status cache for TortoiseHg
-
- Caches the information provided by 'hg status' in the file .hg/thgstatus
- which can then be used by the TortoiseHg shell extension to display
- overlay icons for directories.
-
- The file .hg/thgstatus contains one line for each directory that has
- removed, modified or added files (in that order of preference). Each line
- consists of one char for the status of the directory (r, m or a), followed
- by the relative path of the directory in the repo.
- If the file is empty, then the repo is clean.
-
- Specify --delay to wait until the system clock ticks to the next second
- before accessing the dirstate. This is useful when the dirstate contains
- unset entries (in output of "hg debugstate"). unset entries happen if the
- dirstate was updated within the same second as the respective file in the
- working tree was updated. This happens with a high probability for example
- when cloning a repo. The TortoiseHg shell extension will display unset
- dirstate entries as (potentially false) modified. Specifying --delay ensures
- that there are no unset entries in the dirstate.
- '''
-
- if opts.get('remove'):
- try:
- os.remove(cachefilepath(repo))
- except OSError:
- pass
- return
-
- if opts.get('show'):
- try:
- f = open(cachefilepath(repo), 'rb')
- for e in f:
- showentry(ui.status, e)
- f.close()
- except IOError:
- ui.status("*no status*\n")
- return
-
- if opts.get('delay'):
- tref = time.time()
- tdelta = float(int(tref)) + 1.0 - tref
- if (tdelta > 0.0):
- time.sleep(tdelta)
-
- repostate = repo.status()
- modified, added, removed, deleted = repostate[:4]
- dirstatus = {}
- for fn in added:
- dirstatus[dirname(fn)] = 'a'
- for fn in modified:
- dirstatus[dirname(fn)] = 'm'
- for fn in removed + deleted:
- dirstatus[dirname(fn)] = 'r'
-
- f = open(cachefilepath(repo), 'wb')
- for dn in sorted(dirstatus):
- e = dirstatus[dn] + dn + '\n'
- f.write(e)
- showentry(ui.note, e)
- f.close()
-
- if opts.get('notify'):
- from mercurial import demandimport
- demandimport.disable()
- from thgutil import shlib
- shlib.shell_notify(opts.get('notify'))
- demandimport.enable()
- ui.note("thgstatus updated\n")
-
-cmdtable = {
- 'thgstatus':
- (thgstatus,
- [ ('', 'delay', None, _('wait until the second ticks over')),
- ('n', 'notify', [], _('notify the shell for path(s) given')),
- ('', 'remove', None, _('remove the status file')),
- ('s', 'show', None, _('just show the contents of '
- 'the status file (no update)')) ],
- _('hg thgstatus [OPTION]...')),
-}
|
@@ -175,6 +175,7 @@ lui = ui
if options['repository']:
path = lui.expandpath(options['repository'])
+ cmdoptions['repository'] = path
_loaded = {}
extensions.loadall(ui)
@@ -232,9 +233,9 @@ shlib.shell_notify([os.getcwd()])
def thgstatus(ui, *pats, **opts):
- """update thgstatus"""
- shlib.update_thgstatus(ui, paths.find_root())
- shlib.shell_notify([os.getcwd()])
+ """update TortoiseHg status cache"""
+ from hggtk.thgstatus import run
+ run(ui, *pats, **opts)
def clone(ui, *pats, **opts):
"""clone tool"""
@@ -612,7 +613,13 @@ (serve,
[('', 'webdir-conf', '', _('name of the webdir config file'))],
_('hgtk serve [OPTION]...')),
- "thgstatus": (thgstatus, [], _('hgtk thgstatus')),
+ "thgstatus": (thgstatus,
+ [('', 'delay', None, _('wait until the second ticks over')),
+ ('n', 'notify', [], _('notify the shell for path(s) given')),
+ ('', 'remove', None, _('remove the status cache')),
+ ('s', 'show', None, _('show the contents of the'
+ ' status cache (no update)'))],
+ _('hgtk thgstatus [OPTION]')),
"^update|checkout|co": (update,
[('r', 'rev', '', _('revision to update'))],
('hgtk update')),
|
|
@@ -0,0 +1,47 @@ + #
+# thgstatus.py - update TortoiseHg status cache
+#
+# Copyright (C) 2009 Adrian Buehlmann
+#
+
+'''update TortoiseHg status cache'''
+
+from mercurial import hg
+from thgutil import shlib
+import os
+
+def cachefilepath(repo):
+ return repo.join("thgstatus")
+
+def dirname(f):
+ return f[:max(0, f.rfind("/"))]
+
+def run(_ui, *pats, **opts):
+ path = '.'
+ if opts.get('repository'):
+ path = opts.get('repository')
+ repo = hg.repository(_ui, path)
+
+ if opts.get('remove'):
+ try:
+ os.remove(cachefilepath(repo))
+ except OSError:
+ pass
+ return
+
+ if opts.get('show'):
+ try:
+ f = open(cachefilepath(repo), 'rb')
+ for e in f:
+ _ui.status("%s %s\n" % (e[0], e[1:-1]))
+ f.close()
+ except IOError:
+ _ui.status("*no status*\n")
+ return
+
+ wait = opts.get('delay') is not None
+ shlib.update_thgstatus(_ui, path, wait=wait)
+
+ if opts.get('notify'):
+ shlib.shell_notify(opts.get('notify'))
+ _ui.note("thgstatus updated\n")
|
@@ -94,7 +94,9 @@ dirstatus[dirname(fn)] = 'r'
f = open(repo.join("thgstatus"), 'wb')
for dn in sorted(dirstatus):
- f.write(dirstatus[dn] + dn + '\n')
+ s = dirstatus[dn]
+ f.write(s + dn + '\n')
+ ui.note("%s %s\n" % (s, dn))
f.close()
else:
|
@@ -481,6 +481,7 @@ std::string hgroot = GetHgRepoRoot(cwd);
if (!hgroot.empty())
Dirstatecache::invalidate(hgroot);
+ hgcmd += " --notify .";
}
LaunchCommand(hgcmd, cwd);
|
@@ -35,6 +35,10 @@ int read(FILE* f, std::vector<char>& relpath);
char status(const Winstat& stat) const;
+ bool unset() const {
+ return (state == 'n') && (mode == 0) && (size == -1) && (mtime == -1);
+ }
+
private:
static uint32_t ntohl(uint32_t x)
{
|
Loading...