# HG changeset patch
# User Sune Foldager <c...@cyanite.org>
# Date 1253033536 -7200
# Node ID b212f9190513ac55d49310893411f1ae48f009f3
# Parent  3fc4c85abd0e057942518dc321892b538b0ad5dd
history: enable file patterns

Strings entered in the 'File Patterns' field can be prefixed with one of the
mercurial match types (glob, re, path, relglob, relpath, relre). If not 
prefixed,
the default will either glob or path depending on the presense of one or more of
the characters '[{*?'.

File history mode is enabled when there is only one pattern item, it is of type
path or defaults to path and it is not an existing directory.

diff --git a/tortoisehg/hgtk/history.py b/tortoisehg/hgtk/history.py
--- a/tortoisehg/hgtk/history.py
+++ b/tortoisehg/hgtk/history.py
@@ -12,7 +12,7 @@
 import pango
 import StringIO
 
-from mercurial import ui, hg, cmdutil, commands, extensions, util
+from mercurial import ui, hg, cmdutil, commands, extensions, util, match
 
 from tortoisehg.util.i18n import _
 from tortoisehg.util import hglib, paths
@@ -428,11 +428,14 @@
             ftitle(_('%s branch') % branch)
         elif self.filter == 'custom':
             ftitle(_('custom filter'))
-            if len(pats) == 1 and not os.path.isdir(pats[0]):
-                opts['filehist'] = pats[0]
-                self.graphview.refresh(self.graphcol, pats, opts)
-            else:
-                self.graphview.refresh(False, pats, opts)
+            npats = hglib.normpats(pats)
+            if len(npats) == 1:
+                kind, name = match._patsplit(npats[0], None)
+                if kind == 'path' and not os.path.isdir(name):
+                    opts['filehist'] = name
+                    self.graphview.refresh(self.graphcol, [name], opts)
+            if not opts.get('filehist'):
+                self.graphview.refresh(False, npats, opts)
         elif self.filter == 'all':
             ftitle(None)
             self.graphview.refresh(self.graphcol, None, opts)
diff --git a/tortoisehg/hgtk/logview/revgraph.py 
b/tortoisehg/hgtk/logview/revgraph.py
--- a/tortoisehg/hgtk/logview/revgraph.py
+++ b/tortoisehg/hgtk/logview/revgraph.py
@@ -418,8 +418,6 @@
 
     stack = []
     get = util.cachefunc(lambda r: repo[r])
-    if pats != None:
-        pats = ['path:'+p for p in pats]
     changeiter, matchfn = cmdutil.walkchangerevs(repo.ui, repo, pats, get, 
opts)
     for st, rev, fns in changeiter:
         if st == 'iter':
diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -10,7 +10,7 @@
 import traceback
 import shlib
 import time
-from mercurial import hg, ui, util, extensions, commands, hook
+from mercurial import hg, ui, util, extensions, commands, hook, match
 
 from i18n import _
 import paths
@@ -136,8 +136,22 @@
                 # May already be canonical
                 canonpats.append(f)
     return canonpats
-    
-    
+
+def normpats(pats):
+    'Normalize file patterns'
+    normpats = []
+    for pat in pats:
+        kind, p = match._patsplit(pat, None)
+        if kind:
+            normpats.append(pat)
+        else:
+            if '[' in p or '{' in p or '*' in p or '?' in p:
+                normpats.append('glob:' + p)
+            else:
+                normpats.append('path:' + p)
+    return normpats
+
+
 def mergetools(ui, values=None):
     'returns the configured merge tools and the internal ones'
     if values == None:

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to