14
14
from mercurial import ui, util, extensions, match, bundlerepo, cmdutil
15
from mercurial import encoding, templatefilters, filemerge, error
16
from mercurial import demandimport, revset
15
from mercurial import encoding, templatefilters, filemerge, error, scmutil
17
16
from mercurial import dispatch as hgdispatch
20
demandimport.disable()
23
from mercurial.scmutil import canonpath, userrcpath
24
user_rcpath = userrcpath
25
except (ImportError, AttributeError):
27
from mercurial.util import canonpath, user_rcpath
30
from mercurial.util import localpath
31
except (ImportError, AttributeError):
33
from mercurial.hg import localpath
36
from mercurial.util import hidepassword, removeauth
37
except (ImportError, AttributeError):
39
from mercurial.url import hidepassword, removeauth
42
from mercurial.httpconnection import readauthforuri as hgreadauthforuri
43
except (ImportError, AttributeError):
45
from mercurial.url import readauthforuri as hgreadauthforuri
48
from mercurial.scmutil import revrange, expandpats, revpair, match, matchall
49
except (ImportError, AttributeError):
51
from mercurial.cmdutil import revrange, expandpats, revpair, match, matchall
53
# hg >= 2.1 (0bd17a4bed88)
54
from mercurial.copies import mergecopies, pathcopies
55
except (ImportError, AttributeError):
56
from mercurial.copies import copies as mergecopies
57
def pathcopies(c1, c2):
58
return mergecopies(c1._repo, c1, c2, c1._repo[-1], False)[0]
61
def readauthforuri(ui, uri, user):
63
return hgreadauthforuri(ui, uri, user)
65
return hgreadauthforuri(ui, uri)
67
def revsetmatch(ui, pattern):
70
return revset.match(ui, pattern)
73
return revset.match(pattern)
75
18
_encoding = encoding.encoding
76
19
_encodingmode = encoding.encodingmode
77
20
_fallbackencoding = encoding.fallbackencoding
394
337
root = paths.find_root(cwd)
397
canonpats.append(canonpath(root, cwd, f))
340
canonpats.append(scmutil.canonpath(root, cwd, f))
398
341
except util.Abort:
399
342
# Attempt to resolve case folding conflicts.
401
344
cwdu = cwd.upper()
402
345
if fu.startswith(cwdu):
403
canonpats.append(canonpath(root, cwd, f[len(cwd+os.sep):]))
346
canonpats.append(scmutil.canonpath(root, cwd,
347
f[len(cwd+os.sep):]))
405
349
# May already be canonical
406
350
canonpats.append(f)
500
444
_difftools = tools
447
def tortoisehgtools(ui, selectedlocation=None):
449
Parse 'tortoisehg-tools' section of ini file. Changes:
452
update_to_tip.icon = hg-update
453
update_to_tip.command = hg update tip
454
update_to_tip.tooltip = Update to tip
455
update_to_tip.location = workbench,repowidget
457
into following dictionary
460
{'icon': 'hg-update',
461
'command': 'hg update tip',
462
'tooltip': 'Update to tip',
463
'location': 'workbench,repowidget'}
466
If selectedlocation is set, only return those tools whose
467
location matches the selected location.
468
If a tool has no location set, it will be assumed that it must be
469
shown on the 'workbench' toolbar
473
for key, value in ui.configitems('tortoisehg-tools'):
474
toolname, field = key.split('.')
475
if toolname not in tools:
477
toolnames.append(toolname)
478
bvalue = util.parsebool(value)
479
if bvalue is not None:
481
tools[toolname][field] = value
483
if selectedlocation is None:
484
return tools, toolnames
485
# Only return the tools that are linked to the selected location
487
selectedtoolnames = []
488
for name in toolnames:
490
location = info.get('location', 'workbench').replace(' ', '').split(',')
491
if selectedlocation in location:
492
selectedtools[name] = info
493
selectedtoolnames.append(name)
494
return selectedtools, selectedtoolnames
504
496
def hgcmd_toq(q, label, args):