by
Changes to 5 files · Browse files at ac1a90bf293b Showing diff from parent dd3702788cde aaff0d60ad32 Diff from another changeset...
@@ -261,7 +261,9 @@ cachethg.MODIFIED: ('cvs-modified', 'modified'),
cachethg.UNKNOWN: ('new', 'unrevisioned'),
cachethg.IGNORED: (None, 'ignored'),
- cachethg.NOT_IN_REPO: (None, '')}
+ cachethg.NOT_IN_REPO: (None, ''),
+ cachethg.ROOT: ('generic', 'root'),
+ cachethg.UNRESOLVED: ('cvs-confilict', 'unresolved')}
emblem, status = cache2state.get(cachestate, (None, '?'))
return emblem, status
|
|
|
@@ -1,5 +1,5 @@ import os
-from mercurial import hg, cmdutil, util, ui
+from mercurial import hg, cmdutil, util, ui, node, merge
import thgutil
import sys
try:
@@ -35,13 +35,11 @@ def debugf(str, args=None):
pass
-UNCHANGED = "unchanged"
-ADDED = "added"
-MODIFIED = "modified"
-UNKNOWN = "unknown"
-IGNORED = "ignored"
-NOT_IN_REPO = "n/a"
-ROOT = "root"
+STATUS_STATES = 'MAR!?IC'
+MODIFIED, ADDED, REMOVED, DELETED, UNKNOWN, IGNORED, UNCHANGED = STATUS_STATES
+NOT_IN_REPO = ' '
+ROOT = "r"
+UNRESOLVED = 'U'
# file status cache
overlay_cache = {}
@@ -68,7 +66,8 @@ """
Get the state of a given path in source control.
"""
- return get_states(upath, repo)[-1]
+ states = get_states(upath, repo)
+ return states and states[0] or NOT_IN_REPO
def get_states(upath, repo=None):
@@ -94,9 +93,9 @@ if not status:
if os.path.isdir(os.path.join(path, '.hg')):
add(path, ROOT)
- status = ROOT,
+ status = ROOT
else:
- status = overlay_cache.get(pdir, [NOT_IN_REPO])
+ status = overlay_cache.get(pdir, NOT_IN_REPO)
debugf("%s: %s (cached)", (path, status))
return status
else:
@@ -106,7 +105,7 @@ # path is a drive
if path.endswith(":\\"):
add(path, NOT_IN_REPO)
- return [NOT_IN_REPO]
+ return NOT_IN_REPO
# open repo
if cache_pdir == pdir:
root = cache_root
@@ -115,7 +114,7 @@ root = thgutil.find_root(path)
if root == path:
add(path, ROOT)
- return [ROOT]
+ return ROOT
cache_root = root
cache_pdir = pdir
@@ -123,12 +122,12 @@ debugf("_get_state: not in repo")
overlay_cache = {None: None}
cache_tick_count = GetTickCount()
- return [NOT_IN_REPO]
+ return NOT_IN_REPO
debugf("_get_state: root = " + root)
hgdir = os.path.join(root, '.hg', '')
if pdir == hgdir[:-1] or pdir.startswith(hgdir):
add(pdir, NOT_IN_REPO)
- return [NOT_IN_REPO]
+ return NOT_IN_REPO
try:
tc1 = GetTickCount()
if not repo or (repo.root != root and repo.root != os.path.realpath(root)):
@@ -143,17 +142,17 @@ debugf("%s: overlayicons disabled", path)
overlay_cache = {None: None}
cache_tick_count = GetTickCount()
- return [NOT_IN_REPO]
+ return NOT_IN_REPO
except RepoError:
# We aren't in a working tree
debugf("%s: not in repo", pdir)
add(pdir, IGNORED)
- return [IGNORED]
+ return IGNORED
except StandardError, e:
debugf("error while handling %s:", pdir)
debugf(e)
add(pdir, UNKNOWN)
- return [UNKNOWN]
+ return UNKNOWN
# get file status
tc1 = GetTickCount()
@@ -164,32 +163,37 @@ except util.Abort, inst:
debugf("abort: %s", inst)
debugf("treat as unknown : %s", path)
- return [UNKNOWN]
+ return UNKNOWN
debugf("status() took %g ticks", (GetTickCount() - tc1))
- modified, added, removed, deleted, unknown, ignored, clean = repostate
+ mergestate = repo.dirstate.parents()[1] != node.nullid and \
+ hasattr(merge, 'mergestate')
+
# cached file info
tc = GetTickCount()
overlay_cache = {}
- for grp, st in (
- (ignored, IGNORED),
- (unknown, UNKNOWN),
- (clean, UNCHANGED),
- (added, ADDED),
- (removed, MODIFIED),
- (deleted, MODIFIED),
- (modified, MODIFIED)):
+ add(root, ROOT)
+ states = STATUS_STATES
+ if mergestate:
+ mstate = merge.mergestate(repo)
+ unresolved = [f for f in mstate if mstate[f] == 'u']
+ if unresolved:
+ modified = repostate[0]
+ modified[:] = set(modified) - set(unresolved)
+ repostate.insert(0, unresolved)
+ states = [UNRESOLVED] + states
+ states = zip(repostate, states)
+ states[-1], states[-2] = states[-2], states[-1] #clean before ignored
+ for grp, st in states:
add_dirs(grp)
for f in grp:
fpath = os.path.join(root, os.path.normpath(f))
add(fpath, st)
- add(root, ROOT)
- status = overlay_cache.get(path, [UNKNOWN])
- debugf("\n%s: %s", (path, status))
+ status = overlay_cache.get(path, UNKNOWN)
+ debugf("%s: %s", (path, status))
cache_tick_count = GetTickCount()
return status
def add(path, state):
- c = overlay_cache.setdefault(path, [])
- c.append(state)
+ overlay_cache[path] = overlay_cache.get(path, '') + state
|
@@ -58,7 +58,7 @@ try:
cache_lock.acquire()
tc = win32api.GetTickCount()
- if cachethg.get_state(path) == self.state:
+ if cachethg.get_state(path) in self.state:
return S_OK
return S_FALSE
finally:
@@ -93,6 +93,11 @@ globals()[classname] = cls
_overlay_classes = []
-make_icon_overlay("Changed", "Modified", cachethg.MODIFIED, "{4D0F33E1-654C-4A1B-9BE8-E47A98752BAB}")
-make_icon_overlay("Unchanged", "Normal", cachethg.UNCHANGED, "{4D0F33E2-654C-4A1B-9BE8-E47A98752BAB}")
-make_icon_overlay("Added", "Added", cachethg.ADDED, "{4D0F33E3-654C-4A1B-9BE8-E47A98752BAB}")
+THG_CLSID = "{4D0F33E1-654C-4A1B-9BE8-E47A98752BAB}"
+modified = cachethg.REMOVED + cachethg.DELETED + cachethg.MODIFIED
+
+make_icon_overlay("Changed", "Modified", modified, THG_CLSID)
+make_icon_overlay("Unchanged", "Normal", cachethg.UNCHANGED, THG_CLSID)
+make_icon_overlay("Added", "Added", cachethg.ADDED, THG_CLSID)
+make_icon_overlay("Ignored", "Ignored", cachethg.IGNORED, THG_CLSID)
+make_icon_overlay("Conflict", "Conflict", cachethg.UNRESOLVED, THG_CLSID)
|
@@ -147,14 +147,14 @@ drag_repo = None
drop_repo = None
- drag_path = self.srcfiles[0]
+ drag_path = srcfiles[0]
drag_repo = open_repo(drag_path)
if not drag_repo:
return []
if drag_repo and drag_repo.root != drag_path:
return [] # dragged item must be a hg repo root directory
- drop_repo = open_repo(self._folder)
+ drop_repo = open_repo(destfolder)
menu = thg_menu(drag_repo.ui, self.name)
menu.add_menu(_("Create Clone"),
|
@@ -17,7 +17,10 @@
# shell extension classes
from tortoise.contextmenu import ContextMenuExtension
-from tortoise.iconoverlay import ChangedOverlay, AddedOverlay, UnchangedOverlay
+import tortoise.iconoverlay
+
+overlays = [getattr(tortoise.iconoverlay, overlay) for overlay in
+ tortoise.iconoverlay.__dict__ if overlay.endswith('Overlay')]
bin_path = os.path.dirname(os.path.join(os.getcwd(), sys.argv[0]))
print "bin path = ", bin_path
@@ -50,17 +53,15 @@def DllRegisterServer():
check_tortoise_overlays()
RegisterServer(ContextMenuExtension)
- RegisterServer(ChangedOverlay)
- RegisterServer(AddedOverlay)
- RegisterServer(UnchangedOverlay)
+ for overlay in overlays:
+ RegisterServer(overlay)
register_tortoise_path()
# for COM registration via py2exe
def DllUnregisterServer():
UnregisterServer(ContextMenuExtension)
- UnregisterServer(ChangedOverlay)
- UnregisterServer(AddedOverlay)
- UnregisterServer(UnchangedOverlay)
+ for for overlay in overlays:
+ UnregisterServer(overlay)
register_tortoise_path(unregister=True)
def RegisterServer(cls):
|
Loading...