Commit Graph

237 Commits

Author SHA1 Message Date
Siddharth Agarwal
9ad5c8f0a6 scmutil.addremove: factor out code to mark added/removed/renames
An upcoming patch will reuse this code in another function.
2013-04-03 15:53:59 -07:00
Siddharth Agarwal
c89587db25 scmutil.addremove: factor out code to find renames
This code will be used in a different context in upcoming patches.
2013-04-03 16:32:41 -07:00
Siddharth Agarwal
76d8b6d164 scmutil.addremove: rename local 'copies' to 'renames'
An upcoming patch will refactor some code out into a method called
_findrenames. Having a line saying "copies = _findrenames..." is confusing.
Besides, 'renames' is a more precise name for this local anyway.
2013-04-03 15:32:15 -07:00
Siddharth Agarwal
5839ae6e69 scmutil.addremove: factor out dirstate walk into another function
Upcoming patches will reuse and expand on this function for other purposes.
2013-04-02 17:19:36 -07:00
Durham Goode
1b7b932cfc translations: change label integer error to not specify the kind of label
The current error message used the kind (bookmark, branch, tag) in the message.
Unfortunately this isn't easily translatable since some languages give different
genders to these words. The fix is to not specify it at all, since it should be
implicit based on the command the user just ran.

Relevant discussions around this area:
http://selenic.com/pipermail/mercurial-devel/2012-October/045567.html
http://selenic.com/pipermail/mercurial-devel/2012-October/045600.html
2013-04-19 10:55:11 -07:00
FUJIWARA Katsunori
2dcdc7d9fa localrepo: use "vfs.setflags()" instead of "util.setflags()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
721696db5d localrepo: use "vfs.readlink()" instead of "os.readlink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
bc43776a26 localrepo: use "vfs.islink()" instead of "os.path.islink()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
8e88b218bd localrepo: use "vfs.rename()" instead of "util.rename()" 2013-04-15 01:22:15 +09:00
FUJIWARA Katsunori
0860626b09 vfs: split "expand" into "realpath"/"expandpath" to apply each separately
Before this patch, vfs constructor applies both "util.expandpath()"
and "os.path.realpath()" on "base" path, if "expand" is True.

This patch splits it into "realpath" and "expandpath", to apply each
functions separately: this splitting can allow to use vfs also where
one of each is not needed.
2013-04-15 01:22:15 +09:00
Bryan O'Sullivan
8f78d582d5 scmutil: rewrite dirs in C, use if available
This is over twice as fast as the Python dirs code. Upcoming changes
will nearly double its speed again.

perfdirs results for a working dir with 170,000 files:
  Python     638 msec
  C          244
2013-04-10 15:08:27 -07:00
Bryan O'Sullivan
c1db508ee8 scmutil: add a dirs class
This encapsulates the "multiset of directories" structures that are
currently open-coded (and duplicated) in both the dirstate and
context modules.

This will be used, and optionally replaced by a C implementation,
in upcoming changes.
2013-04-10 15:08:26 -07:00
Bryan O'Sullivan
00ff38c9c3 scmutil: migrate finddirs from dirstate 2013-04-10 15:08:25 -07:00
Siddharth Agarwal
070b188489 scmutil.addremove: use iteritems on walk results
Now that we no longer sort all the walk results, using iteritems becomes
possible.

This is a relatively minor speedup: on a large repository with 170,000 files,
perfaddremove goes from 2.13 seconds to 2.10.
2013-04-02 14:50:50 -07:00
Siddharth Agarwal
cf3792485f scmutil.addremove: stop sorting all walk results
The only place where the order matters is in printing out added or removed
files. We already sort that set.

On a large repository with 170,000 files, this speeds up perfaddremove from
2.34 seconds to 2.13.
2013-04-02 14:50:31 -07:00
Siddharth Agarwal
eff1b30357 scmutil.addremove: pull ui.status printing out of the loop
This will let us stop sorting all the results in an upcoming patch.

This also permits future refactorings where the same code consumes
dirstate.walk results but doesn't print anything out.

An argument could be made that printing out results as we go along is more
responsive UI-wise. However, at this point iterating through walk results is
actually faster than sorting them, so once we stop sorting all the results the
argument ceases to be valid.
2013-04-02 10:56:24 -07:00
Siddharth Agarwal
c4b1cf0480 scmutil.addremove: remove redundant directory and symlink checks
dirstate.walk only does lstats and never returns stat objects for directories.

On a large repository with 170,000 files, this speeds perfaddremove up from
2.40 seconds to 2.34.
2013-04-02 14:49:34 -07:00
Siddharth Agarwal
392b6d1872 scmutil.addremove: pull repo.dirstate fetch out of the loop
On a large repository with 170,000 files, this speeds up perfaddremove from
2.78 seconds to 2.40.
2013-04-02 14:46:55 -07:00
Siddharth Agarwal
64922bc1af scmutil: remove dead updatedir code
This code has not been used in a long while.
2013-04-01 20:38:37 -07:00
Kevin Bullock
d24c25031a scmutil: split platform-specific bits into their own modules
This parallels what's done for the util module, which imports either
mercurial.posix or mercurial.windows as 'platform' and then slurps the
appropriate functions into its own namespace.
2013-02-12 11:36:21 -06:00
Bryan O'Sullivan
9b9339ed49 util: make ensuredirs safer against races 2013-02-13 12:20:10 -08:00
Bryan O'Sullivan
ede7482a3a scmutil: create directories in a race-safe way during update
With the new parallel update code, it is possible for multiple
workers to try to create a hierarchy of directories at the same
time. This is hard to trigger in general, but most likely during
initial checkout.

To deal with these races, we introduce a new ensuredirs function
whose contract is to ensure that a directory hierarchy exists - it
will ignore a failure that implies that the desired directory already
exists.
2013-02-11 16:15:12 -08:00
Durham Goode
89fa09c11d addremove: don't audit the path for paths already in the dirstate
Now that dirstate.walk returns None for paths under symlink directories,
addremove doesn't need to validate each path it sees to look for files
under symlinks.

On a large repository this brings addremove from 6.3 seconds down to 3.65 (42%)
since addremove no longer has to stat every directory of every file to determine
if the file is inside a symlink directory. I put it through our benchmark and
see no perf hit to any other commands.
2013-02-05 14:36:19 -08:00
Durham Goode
2aa5fd3151 pathauditor: add check() method
The pathauditor currently throws exceptions when it encounters an invalid
path. This change adds a method to allow people to treat it as a boolean.
This is currently used by scmutil.addremove and in a subsequent patch it
will be used by dirstate.walk
2013-02-05 14:24:14 -08:00
Pierre-Yves David
306badf4c6 outgoing: fix possible filtering crash in outgoing (issue3814)
If there is no outgoiing changesets but we have filtered revision in outgoing.excluded
We run into a filtering related crash. The excluded revision should not be there
in the first place but discovery need cleanup in default, not stable.
2013-02-09 17:54:01 +00:00
Durham Goode
fe6e42c6ab bookmark: don't allow integers as bookmark/branch/tag names
Bookmarks/branches/tags shouldn't be allowed to be integers because that
overlaps with revision numbers.  Right now if a user created one they can't
use it anyway because the revision numbers take precedence.

The check only happens when creating a new bookmark/etc from a command so it
shouldn't affect existing bookmarks/branches/tags or importing branches from
git.

This fix was prompted by us having a user create a bookmark named "404" then
accidentally checkout a very old version of our repository.
2013-02-05 16:22:53 -08:00
Durham Goode
4d8644ea85 addremove: don't perform m.exact/rel until needed
Moves the m.exact and m.rel calls within the conditionals they are used in.
On a large repo this brings addremove from 7.1 seconds down to 6.3 (13%).
2013-02-04 14:10:09 -08:00
Durham Goode
633431ef38 addremove: don't call lexists, isdir, and islink
The dirstate walk results contain the stat information for each path, so we
don't need to query it again.  On a large repo this makes addremove go from
8.35 seconds to 7.1 (15%).
2013-02-04 14:06:20 -08:00
Durham Goode
74fdcdca03 addremove: only query dirstate once per path
Previously the addremove code queried the dirstate 4 times per path. Now it
only does so once.  On a large repo this brings addremove from 9.5 seconds
to 8.35 seconds (12%).
2013-02-04 14:01:40 -08:00
Sean Farley
5d92124a63 log: remove any ancestors of nullrev (issue3772)
For the special case, ":null" we remove the implied revision 0 since that
wouldn't make any sense here. A test case is added to make sure only nullrev is
shown.
2013-01-23 00:12:52 -06:00
Mads Kiilerich
84f8ae3223 scmutil: localize and improve 'not under root' message 2013-01-18 01:24:29 +01:00
Mads Kiilerich
0d0f5ceab6 scmutil: simplify vfs.audit - drop wrapped vfs.auditor 2013-01-09 00:01:33 +01:00
Idan Kamara
ad6fc4bb63 filecache: create an entry in _filecache when __set__ is called for a missing one
Preserve the invariant that if P is a filecached property on X then
P in X.__dict__ => P in X._filecache.

Previously, it was possible for a filecached property to become out of sync
with the filesystem if it was set before getting it first, since the initial
filecacheentry was created in __get__.

Old behaviour:

  repo.prop = x
  repo.invalidate() # prop has no entry in _filecache, it's not removed
                    # from __dict__
  repo.prop         # returns x like before without checking with the
                    # filesystem

New:

  repo.prop = x     # an empty entry is created in _filecache
  repo.invalidate() # prop is removed from __dict__
  repo.prop         # recreates prop
2012-12-17 15:25:45 +02:00
Idan Kamara
542705b00a filecache: allow filecacheentry to be created without stating in __init__
Will be used for properties that are set without getting them first.
2013-01-10 23:54:53 +02:00
Pierre-Yves David
ecb9a9d217 vfs: add a read only vfs
This read only wrapper is intended to be used bundle repo. See follow up commit
for details.
2013-01-04 01:07:25 +01:00
Matt Mackall
fe2cbf4904 merge with stable 2013-01-02 00:24:28 -06:00
Matt Mackall
567c0ff1dc scmutil: don't try to match modes on filesystems without modes (issue3740) 2012-12-20 15:52:23 -06:00
Augie Fackler
83ede3fe35 scmutil: clean up use of two-argument raise
This makes any attempt to port to Python 3 harder, and the new syntax
is supported in 2.4 already.
2013-01-01 12:51:00 -06:00
Pierre-Yves David
8bebd5c244 clfilter: remove usage of range and xrange in scmutil.revrange
For changelog level filtering to take effect it need to be used for any
iteration.

This changeset removes usage of `range` and `xrange` that survived the first
pass.
2012-11-20 19:05:46 +01:00
Adrian Buehlmann
1600cb1ed4 vfs: optimize __call__ by not calling util.split for reads
dirname and basename are not used on reads
2012-11-03 10:40:36 +01:00
Wagner Bruna
cc8c722c61 scmutil: generalize message to make it more i18n-friendly 2012-10-21 11:20:33 -02:00
Bryan O'Sullivan
9d4dd6b048 scmutil: add mustaudit delegation to filtervfs (issue3673) 2012-10-22 12:00:21 -07:00
Bryan O'Sullivan
b59090c617 scmutil: abstract out mustaudit delegation 2012-10-22 11:59:11 -07:00
Kevin Bullock
13bf0fbbec scmutil: add bad character checking to checknewlabel
This factors out the checks from tags and bookmarks, and newly applies
the same prohibitions to branches. checknewlabel takes a new parameter,
kind, indicating the kind of label being checked.

Test coverage is added for all three types of labels.
2012-10-17 21:42:06 -05:00
Kevin Bullock
a3ac9141ee scmutil: add function to validate new branch, tag, and bookmark names
For now the new function only checks to make sure the new label name
isn't a reserved name ('tip', '.', or 'null'). Eventually more of the
checks will be unified between the different types of labels.

The `tag` command is trivially updated to use it. Updating branches and
bookmarks to use it is slightly more invasive and thus reserved for
later patches.
2012-10-17 16:34:46 -05:00
Matt Mackall
5b51bfe8c9 vfs: use self.write to write symlink placeholders
The existing write() path is much more robust than the hand-rolled
version that was inlined here.
2012-10-13 15:10:39 -05:00
Matt Mackall
c3b65813c8 vfs: backout fchmod change from 0232a1565a3d
Only works on Unix with Python >= 2.6, need a different fix.
2012-10-13 15:03:00 -05:00
Matt Mackall
98c3be16ec vfs: use fchmod for _fixfilemode
On general principle, we should use fchmod instead of chmod to avoid
security pitfalls, although none is likely possible here.
2012-10-11 22:58:34 -05:00
FUJIWARA Katsunori
bcd74985e5 store: invoke "osutil.listdir()" via vfs
This patch invokes "osutil.listdir()" via vfs object.

The function added newly to "abstractvfs" is named not as "listdir()"
but as "readdir()", because:

  - "os.listdir()" seems to be more familiar as "listdir()" than
    "osutil.listdir()"

  - "osutil.listdir()" returns also type of each files like
    "readdir()" POSIX API: even though "d_type" field of "dirent"
    structure is defined mainly only on BSD/Linux

This patch invokes "osutil.listdir()" via "rawvfs" object to avoid
filename encoding, because the path passed to "osutil.listdir()"
shouldn't be encoded.

This patch also omits importing "osutil" module, because it is no
longer used.
2012-10-09 16:17:55 +09:00
FUJIWARA Katsunori
e100683d0e store: invoke "os.stat()" for "createmode" initialization via vfs
This just replaces "os.stat()" invocation: refactoring around
"self.createmode" and "vfs.createmode" initialization is omitted.

This patch also newly adds "stat()" function to "abstractvfs".
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
f503d56231 vfs: define "join()" in each classes derived from "abstractvfs"
This patch defines "join()" in each classes derived from "abstractvfs"
except "vfs", which already defines it.

This allows all vfs instances to be used for indirect file API
invocation.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
159588adfd scmutil: reorder newly added functions for vfs support in dictionary order
Definition functions for vfs support in dictionary order increases
readability/maintainability, because there are functions which invoke
file API:

  - with same name: "os.listdir" and "osutil.listdir", for example
  - with ambiguous names: "os.mkdir" and "util.makedirs", for example
2012-10-09 01:41:55 +09:00
Matt Mackall
3a2547f38e scmutil: backout ea219479a44b (issue3643) 2012-09-29 11:57:16 -05:00
Pierre-Yves David
df82aab75f clfilter: remove usage of range in favor of iteration over changelog
If we want to apply filtering at changelog level, we need to iterate over it.
See previous changeset description for details.
2012-09-20 19:01:53 +02:00
FUJIWARA Katsunori
97278fdfa7 scmutil: rename classes from "opener" to "vfs"
For backwards compatibility, aliases for the old names are added,
except for "abstractopener", "statichttpopener" and "_fncacheopener",
because these are not used in Mercurial core implementation after this
patch.

"_fncacheopener" was only referred in "fncachestore" constructor, so
this patch also renames from "_fncacheopener" to "_fncachevfs" there.
2012-08-31 02:06:29 +09:00
Bryan O'Sullivan
1dc1178198 scmutil: use the new faster path split
Combined with a few other patches in this series, this contributes
to improving stream_out performance by 10%.
2012-09-14 12:08:55 -07:00
Bryan O'Sullivan
7df4ae95dc scmutil: make join cheaper
Combined with a few followup patches, this contributes to improving
stream_out performance by 10%.
2012-09-14 12:07:33 -07:00
Bryan O'Sullivan
51dda0ee74 scmutil: turn opener._audit into a property, mustaudit
This will be used by an upcoming patch.
2012-09-14 12:04:35 -07:00
Patrick Mezard
7221d12e58 discovery: add extinct changesets to outgoing.excluded
Before this change, push would incorrectly fast-path the bundle
generation when extinct changesets are involved, because they are not
added to outgoing.excluded. The reason to do so are related to
outgoing.excluded being assumed to contain only secret changesets by
scmutil.nochangesfound(), when displaying warnings like:

 changes found (ignored 9 secret changesets)

Still, outgoing.excluded seems like a good API to report the extinct
changesets instead of dedicated code and nothing in the docstring
indicates it to be bound to secret changesets. This patch adds extinct
changesets to outgoing.excluded and fixes scmutil.nochangesfound() to
filter the excluded node list.

Original version and test by Pierre-Yves.David@ens-lyon.org
2012-07-25 19:34:31 +02:00
Joshua Redstone
30df933365 scmutil: 25% speedup in casecollisionauditor
On a large repository, switching casecollisionauditor to lowercasing all file
names at once rather than one at a time improves hg-add time by 25%.
2012-07-06 13:56:40 -07:00
FUJIWARA Katsunori
64cae05faf localrepo: use file API via vfs while ensuring repository directory
As a part of migration to vfs, this patch invokes some file API
indirectly via vfs, while ensuring repository directory in the
constructor of "localrepository" class.

New file API are added to "scmutil.abstractopener" class, because they
are also used via other derived classes than "scmutil.opener".

But "join()" is not yet defined other than "scmutil.opener" class,
because it should not be used via other opener classes yet.
2012-07-06 18:45:27 +09:00
FUJIWARA Katsunori
d20072de6a localrepo: use path expansion API via vfs
As a part of migration to vfs, this patch moves path expansion API
invocations in the constructor of "localrepository" to the constructor
of "opener", because the root path to the repository is very important
to handle paths using non-ASCII characters correctly.

This patch also rearrange initialization order of "wvfs" field,
because it is required to initialize "self.root".
2012-07-06 18:45:27 +09:00
Mads Kiilerich
ff855a00ed help: improve hgweb help
The existing help only walked through an example.

Now we first explain the basic rules and then show an example.

The 'collections' example and description only cause confusion and is removed.

Bikeshedded by Patrick Mezard <patrick@mezard.eu>
2012-06-21 12:50:15 +02:00
Bryan O'Sullivan
4bb35317bc scmutil: speed up new-style range extension
This improves perfrevset performance by 10% for 2222::33333 on a
kernel repo.
2012-06-22 12:00:41 -07:00
Adrian Buehlmann
9a9882a6d8 scmutil: change canonpath to use util.samefile (issue2167)
Fixes (on Windows in cmd.exe):

  $ hg -R v:\x\a status V:\x\a\bar
  abort: V:\x\a\bar not under root

where v:\x\a is a valid repository with a checked-out file "bar"
(Note the difference in casing: "v:\" versus "V:\")
2012-06-14 11:43:48 +02:00
Matt Mackall
da90115a02 merge with stable 2012-06-01 15:14:29 -05:00
Bryan O'Sullivan
ca79cf4afa scmutil: seen.union should be seen.update (issue3476) 2012-05-31 20:55:30 -07:00
Matt Mackall
d4e4a5b5be revpair: handle odd ranges (issue3474) 2012-05-30 14:13:57 -05:00
Adrian Buehlmann
19b92fcf59 scmutil: use _winreg.HKEY_LOCAL_MACHINE 2012-05-27 11:30:03 +02:00
Matt Mackall
bfe92722a0 merge with stable 2012-05-30 14:21:58 -05:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Thomas Arendsen Hein
243e5232c0 opener: coding style, use triple quotes for doc string 2012-04-18 15:16:15 +02:00
Matt Mackall
b55cd4a40b opener: introduce tryread helper
This makes it easier to follow the common pattern "read a file or give
an empty string if it's missing".
2012-04-17 11:11:59 -05:00
Wolfgang Treutterer
00e7333b1b scmutil: fix systemrcpath regression introduced in ebc9c501f13c
Changeset ebc9c501f13c introduced a 'root' path component to look for
hgrc files, which is used both as an absolute path and a path relative
to the <install-root>.
The latter one was broken since 'root' was set to an absolute location
and the subsequent os.path.join discarded the <install-root> path prefix.
2012-04-13 10:08:08 +02:00
Bryan O'Sullivan
ba47c1b0e5 scmutil: speed up revrange
This improves the performance of "hg log -l1" from 0.21 seconds to
0.07 on a Linux kernel tree.

Ideally we could use xrange instead of range on the most common
path, and thus avoid a ton of allocation, but xrange doesn't support
slice-based indexing.
2012-04-09 22:16:26 -07:00
Steven Stallion
d79ff306e5 plan9: initial support for plan 9 from bell labs
This patch contains support for Plan 9 from Bell Labs. A README is
provided in contrib/plan9 which describes the port in greater detail.
A new extension is also provided named factotum which permits the
factotum(4) authentication agent to provide credentials for HTTP
repositories. This extension is also applicable to other POSIX
platforms which make use of Plan 9 from User Space (aka plan9ports).
2012-04-08 12:43:41 -07:00
Matt Mackall
8dac6af07e scmutil: use context instead of lookup 2012-04-08 12:38:23 -05:00
Thomas Arendsen Hein
0f80b37090 merge with stable 2012-03-02 09:57:09 +01:00
Idan Kamara
6f16e78f1f scmutil: add join method to opener to construct path relative to base
Useful when we only have the opener without the base path used when it was
constructed.
2012-03-01 17:39:58 +02:00
Idan Kamara
58bc817cd0 filecache: refactor path join logic to a function
New users of filecache use different names for the function used to compute
the runtime path of the cached file.

Users should subclass filecache and provide their own version of this
function to call the appropriate join function on 'obj' (an instance
of the class that its member function was decorated).
2012-03-01 17:39:58 +02:00
Patrick Mezard
22a413e426 graphlog: restore FILE glob expansion on Windows
On platforms not supporting shell expansion, scmutil.match() performs glob
expansion on 'pats' arguments. But _matchfiles() revset calls match.match()
directly, bypassing this behaviour. To avoid duplicating scmutil.match(), a
secondary scmutil.matchandpats() is introduced returning both the match object
and the expanded inputs. Note the expanded pats are also needed in the fast
path, and will be used by --follow code path.
2012-02-25 22:11:34 +01:00
Matt Mackall
7c3342ed27 addremove: return 1 if we failed to handle any explicit files 2012-02-24 16:52:32 -06:00
Idan Kamara
f729c0ef8a scmutil: update cached copy when filecached attribute is assigned (issue3263)
When assigning a new object to filecached properties, the cached object that
was kept in the _filecache map was still holding the old object.

By implementing __set__, we track these changes too and update the cached
copy as well.
2012-02-15 20:02:35 +02:00
FUJIWARA Katsunori
d93ccafb52 use util.localpath() instead of 'str.replace()' to unify path conversion 2012-02-05 22:58:31 +09:00
Matt Mackall
e4d11ad28c scmutil: unify some 'no changes found' messages
This keeps the wording more consistent for secret csets
2012-01-25 17:14:08 -06:00
Dan Villiom Podlaski Christiansen
6ee655e337 canonpath: allow canonicalization of non-existant paths
Such as a copy destination; see the added test.
2012-01-08 15:23:26 +01:00
Matt Mackall
dc09090fed merge with stable 2011-12-26 18:08:20 -06:00
FUJIWARA Katsunori
529dcf14a4 windows: force specified path to be audited in localpath form
pathauditor is invoked not only for localpath form using "os.sep" as
separator, but also for normalized form using "/": for example, hg
internal path like "store/data" under ".hg", or ones normalized by
match object

this causes insufficient repository nesting check, because current
pathauditor implementation divides specified path into components by
"os.sep", and this causes to treat multiple path components joined by
"/" as single one on Windows environment.

this patch applies "util.localpath()" on specified path to force it to
be divided into components correctly.

in fact, root for pathauditor also uses multiple path separator on
Windows. but this does not affect audit itself, so "util.localpath()"
is not applied on it.
2011-12-24 19:01:07 +09:00
FUJIWARA Katsunori
44af3b0ebf pathauditor: switch normcase logic according to case sensitivity of filesystem
this patch applies 'util.normcase()' to audit path only on case
insensitive filesystem.
2011-12-16 21:09:40 +09:00
FUJIWARA Katsunori
6b07b41e4f pathauditor: preserve case in abort messages
this patch uses both plain and normcase()-ed pathes to preserve letter
case of path in abort messages.
2011-12-16 21:09:40 +09:00
FUJIWARA Katsunori
afdb157d48 pathauditor: use normcase()-ed path for audit result cache
in current pathauditor implementation, un-normcase()-ed path is
stored into and compared with audit result cache.

this is not efficiency on case insensitive filesystem.
2011-12-16 21:09:40 +09:00
Matt Mackall
7cf4e6eacb merge with stable 2011-12-16 19:05:59 -06:00
Mads Kiilerich
782d103c42 cmdutil: don't use repr on paths in pathauditor - it looks strange on windows 2011-11-07 02:49:00 +01:00
Matt Mackall
7cae202e57 merge with stable 2011-07-29 17:27:38 -05:00
FUJIWARA Katsunori
a423a1ab9d i18n: use UTF-8 string to lower filename for case collision check
Some character sets, cp932 (known as Shift-JIS for Japanese) for
example, use 0x41('A') - 0x5A('Z') and 0x61('a') - 0x7A('z') as second
or later character.

In such character set, case collision checking recognizes different
files as CASEFOLDED same file, if filenames are treated as byte
sequence.

win32mbcs extension is not appropriate to handle this problem, because
this problem can occur on other than Windows platform only if
problematic character set is used.

Callers of util.checkcase() use known ASCII filenames as last
component of path, and string.lower() is not applied to directory part
of path. So, util.checkcase() is kept intact, even though it applies
string.lower() to filenames.
2011-07-28 14:36:07 +09:00
Steve Borho
bb2fdf8f33 scmutil: add missing import of re
see https://bitbucket.org/tortoisehg/thg/issue/929
2011-07-08 20:24:19 -05:00
Pierre-Yves David
2ebc0660c3 requirements: show all missing features in the error message.
Displaying all missing featureis help people to solve the issue (choosing the
right version, creation the right repo)
2011-06-25 02:30:24 +02:00
Adrian Buehlmann
a6cb8dc613 opener: add self._audit (issue2862) 2011-06-22 10:13:44 +02:00
Matt Mackall
deda228cd7 scmutil: match no longer accepts repo objects 2011-06-18 16:52:51 -05:00
Matt Mackall
5ab97592f7 scmutil: switch match users to supplying contexts
The most appropriate context is not always clearly defined. The obvious cases:

For working directory commands, we use None
For commands (eg annotate) with single revs, we use that revision

The less obvious cases:

For commands (eg status, diff) with a pair of revs, we use the second revision
For commands that take a range (like log), we use None
2011-06-18 16:52:51 -05:00
Matt Mackall
7fe2a75e90 scmutil: match now accepts a context or a repo 2011-06-18 16:52:51 -05:00
Matt Mackall
3ca86d272f context: add a match builder method
This is groundwork for matching against filesets in contexts
2011-06-18 16:52:51 -05:00
Matt Mackall
86143efd7d scmutil: improve path calculation for install-relative RC files (issue2841)
This code was ugly and might do the wrong thing with symlinks.
2011-06-03 15:08:08 -05:00
Matt Mackall
b0048281b5 requires: note apparent corruption 2011-05-31 15:55:23 -05:00
Adrian Buehlmann
cfc4484960 readrequires: provide easier to understand error message
NEW:

  $ hg id
  abort: unknown repository format: requires feature 'foo' (upgrade Mercurial)!

OLD:

  $ hg id
  abort: requirement 'foo' not supported!
2011-05-31 19:16:25 +02:00
Adrian Buehlmann
924c56c606 introduce new function scmutil.readrequires
for reading and parsing the .hg/requires file
2011-05-31 19:16:18 +02:00
Matt Mackall
c6e850b04b context: make forget work like commands.forget
Switch users of wctx.delete(..., False) to forget.
2011-05-26 17:15:35 -05:00
Adrian Buehlmann
60c5ff105b opener: add audit function 2011-05-21 23:13:59 +02:00
Matt Mackall
03aaf3756d scmutil: fold in wdutil 2011-05-13 14:07:16 -05:00
Matt Mackall
cf07129983 scmutil: move revsingle/pair/range from cmdutil
This allows users at levels below the command layer to avoid import loops.
2011-05-13 14:06:28 -05:00
Augie Fackler
7d6e3ac2bb walkrepos: use getattr instead of hasattr for samestat 2011-07-25 15:45:11 -05:00
Idan Kamara
3b6032fdaf scmutil: introduce filecache
The idea is being able to associate a file with a property, and watch
that file stat info for modifications when we decide it's important for it to
be up-to-date. Once it changes, we recreate the object.

On filesystems that can't uniquely identify a file, we always recreate.

As a consequence, localrepo.invalidate() will become much less expensive in the
case where nothing changed on-disk.
2011-07-09 19:06:59 +03:00
Adrian Buehlmann
98828d8530 opener: rename _can_symlink to _cansymlink 2011-05-07 20:22:32 +02:00
Adrian Buehlmann
b84ce08e82 rename util.executable_path to executablepath 2011-05-06 15:36:05 +02:00
Adrian Buehlmann
554b565228 rename util.lookup_reg to lookupreg 2011-05-06 15:16:22 +02:00
Adrian Buehlmann
c451efca8a scmutil: rename local function _add_dir_if_not_there 2011-05-06 15:02:53 +02:00
Adrian Buehlmann
9804b19041 rename scmutil.user_rcpath to userrcpath 2011-05-06 14:58:04 +02:00
Adrian Buehlmann
5b97603cc4 rename scmutil.system_rcpath to systemrcpath 2011-05-06 14:54:05 +02:00
Adrian Buehlmann
761f9b4904 rename scmutil.os_rcpath to osrcpath 2011-05-06 14:52:25 +02:00
Adrian Buehlmann
e981d64ef2 rename path_auditor to pathauditor
The Mercurial 1.9 release is moving a lot of stuff around anyway and we are
already moving path_auditor from util.py to scmutil.py for that release.

So this seems like a good opportunity to do such a rename. It also strengthens
the current project policy to avoid underbars in names.
2011-05-06 09:54:06 +02:00
Dan Villiom Podlaski Christiansen
88e742876f util & scmutil: adapt read/write helpers as request by mpm 2011-05-02 10:11:05 +02:00
Adrian Buehlmann
c14abef27b scmutil: introduce casecollisionauditor
and cleaning up portability functions
2011-04-30 23:27:00 +02:00
Dan Villiom Podlaski Christiansen
e36632966a opener: add read & write utility methods
The two new methods are useful for quickly opening a file for reading
or writing. Unlike 'opener(...).read()', they ensure they the file is
immediately closed without relying on CPython reference counting.
2011-04-30 19:41:53 +02:00
Dan Villiom Podlaski Christiansen
9b9141450f add filteropener abstraction for store openers 2011-04-30 19:37:13 +02:00
Dan Villiom Podlaski Christiansen
30ecd40f14 opener: introduce an abstact superclass of it
Currently, this class doesn't do anything useful.
2011-04-30 19:36:48 +02:00
Kevin Gessner
e0a808198a add: notify when adding a file that would cause a case-folding collision
On a case-sensitive file system, files can be added with names that differ
only in case (a "case collision"). This would cause an error on case-insensitive
filesystems. A warning or error is now given for such collisions, depending on
the value of ui.portablefilenames ('warn', 'abort', or 'ignore'):

    $ touch file File
    $ hg add --config ui.portablefilenames=abort File
    abort: possible case-folding collision for File
    $ hg add File
    warning: possible case-folding collision for File
2011-04-30 12:39:46 +02:00
Kevin Gessner
3eac7995c0 scmutil: refactor ui.portablefilenames processing
The ui.portablefilenames config handling is generally useful for notifying the
user of various portability problems.
2011-04-30 11:08:24 +02:00
Adrian Buehlmann
a928db8b4e move system_rcpath and user_rcpath to scmutil 2011-04-21 21:16:54 +02:00
Adrian Buehlmann
bee8559898 move os_rcpath from util to scmutil 2011-04-21 20:54:45 +02:00
Adrian Buehlmann
9a67b02dba move rcpath from util to scmutil 2011-04-21 20:14:29 +02:00
Adrian Buehlmann
267c80394b move walkrepos from util to scmutil 2011-04-21 16:06:19 +02:00
Adrian Buehlmann
756a1d3529 move checkfilename from util to scmutil
checkfilename is specific to Mercurial, since it contains the knowledege
that Mercurial can't track files with \n or \r in the name.
2011-04-21 13:18:52 +02:00
Adrian Buehlmann
bf5585ac5b scmutil: fix erroneous Abort call
This fixes d26b1348d3f6 (affected Windows only).
2011-04-21 12:10:03 +02:00
Adrian Buehlmann
307196b733 move path_auditor from util to scmutil 2011-04-20 22:43:31 +02:00
Adrian Buehlmann
f3e8eae526 move canonpath from util to scmutil 2011-04-20 21:41:41 +02:00
Adrian Buehlmann
cf126bb7dd move opener from util to scmutil 2011-04-20 19:54:57 +02:00
Adrian Buehlmann
fc7e20743c add: introduce a warning message for non-portable filenames (issue2756) (BC)
On POSIX platforms, the 'add', 'addremove', 'copy' and 'rename' commands now
warn if a file has a name that can't be checked out on Windows.

Example:

  $ hg add con.xml
  warning: filename contains 'con', which is reserved on Windows: 'con.xml'
  $ hg status
  A con.xml

The file is added despite the warning.

The warning is ON by default. It can be suppressed by setting the config option
'portablefilenames' in section 'ui' to 'ignore' or 'false':

  $ hg --config ui.portablefilenames=ignore add con.xml
  $ hg sta
  A con.xml

If ui.portablefilenames is set to 'abort', then the command is aborted:

  $ hg --config ui.portablefilenames=abort add con.xml
  abort: filename contains 'con', which is reserved on Windows: 'con.xml'

On Windows, the ui.portablefilenames config setting is irrelevant and the
command is always aborted if a problematic filename is found.
2011-04-19 12:42:53 +02:00