Commit Graph

183 Commits

Author SHA1 Message Date
Martin von Zweigbergk
242bbe216d addremove: print relative paths when called with -I/-X (BC)
For "hg addremove 'glob:*.py'", we print any paths added or removed as
relative to the current directory, but when "hg addremove -I
'glob:*.py'" is used, we use the absolute path (relative from the repo
root). It seems like they should be the same, so change it so we use
relative paths in both cases. Continue to use absolute paths when no
patterns are given.
2014-12-01 21:48:32 -08:00
FUJIWARA Katsunori
86bc73ffa9 vfs: add "writelines"
This patch allows "writelines" to take "mode" and "notindexed"
arguments, because subsequent patch for subrepo requires both.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
f60bafa1b3 vfs: add "notindexed" argument to invoke "ensuredir" with it in write mode
This patch uses "False" as default value of "notindexed" argument,
even though "vfs.makedir()" uses "True" for it, because "os.mkdir()"
doesn't set "_FILE_ATTRIBUTE_NOT_CONTENT_INDEXED" attribute to newly
created directories.
2014-11-19 18:35:14 +09:00
FUJIWARA Katsunori
b1ff97d24c vfs: add "readlines" and "tryreadlines"
This patch allows "readlines" and "tryreadlines" to take "mode"
argument, because "subrepo" requires to read files not in "rb"
(binary, default for vfs) but in "r" (text) mode in subsequent patch.
2014-11-19 18:35:14 +09:00
Martin von Zweigbergk
98fbfc44f9 addremove: add back forgotten files (BC)
After running "hg forget README && hg addremove", README will still be
reported as removed, while "hg forget README && hg add README" adds it
back so it gets reported as clean. It seems like they should behave
the same. Furthermore, it seems like no files should remain untracked
after 'hg addremove && hg commit' (or 'hg commit -A'). For these
reasons, change the behavior of addremove so it does add forgotten
files back.

The problem is with scmutil._interestingfiles(), which reports the
file as removed, so scmutil.addremove() does not add it. Fix by
teaching _interestingfiles() to report forgotten files separately from
removed files and make addremove() add forgotten files back. However,
do not treat forgotten files as sources for rename detection. Note
that since removed and forgotten files are treated the same before
this change, forgotten files were considered sources for rename
detection.

Also update the other caller, marktouched(), in the same way as
addremove().
2014-11-08 23:13:39 -08:00
Mads Kiilerich
7f5af5ba4c config: introduce "built-in" default configuration settings in default.d
This helps providing a more consistent user experience on all platforms and
with all packaging.

The exact location of default.d depends on how Mercurial is installed and
whether it is 'frozen'. The exact location should never be relevant to users
and is intentionally not explained in details in the documentation. It will
however always be next to the help and templates files.

Note that setting HGRCPATH also disables these defaults. I don't know if that
should be considered a bug or a feature.
2014-09-04 21:36:35 +02:00
Martin von Zweigbergk
8b968ecfe2 status: update and move documentation of status types to status class
The various status types are currently documented on the
dirstate.status() method. Now that we have a class for the status
types, it makese sense to document the status types there
instead. Only leave the bits related to lookup/unsure in the status()
method documentation.
2014-10-10 10:14:35 -07:00
Martin von Zweigbergk
41a4138ec7 status: create class for status lists
Callers of various status() methods (on dirstate, context, repo) get a
tuple of 7 elements, where each element is a list of files. This
results in lots of uses of indexes where names would be much more
readable. For example, "status.ignored" seems clearer than "status[4]"
[1]. So, let's introduce a simple named tuple containing the 7 status
fields: modified, added, removed, deleted, unknown, ignored, clean.

This patch introduces the class and updates the status methods to
return instances of it. Later patches will update the callers.

 [1] Did you even notice that it should have been "status[5]"?

(tweaked by mpm to introduce the class in scmutil and only change one user)
2014-10-10 14:32:36 -07:00
Pierre-Yves David
c05e6afd86 revpair: use first and last instead of direct indexing
This makes it compatible with all smarsets classes.
2014-10-06 23:37:39 -07:00
Pierre-Yves David
d6d95b6b1f revsingle: use last instead of direct indexing
This makes it compatible with all smarsets classes.
2014-10-06 23:37:08 -07:00
Pierre-Yves David
e2d1bcc06d revset-limit: use boolean testing instead of len(revs) < 1
I'm not sure why we wrote it that way. But smartsets have faster/lazier non-zero
testing than length computation.
2014-10-06 11:43:32 -07:00
Chinmay Joshi
0db86c64a5 vfs: add listdir for os.listdir in vfs
This patch adds listdir() in vfs to use os.listdir().
2014-06-20 21:18:14 +05:30
Chinmay Joshi
ecc3ce679c vfs: add unlinkpath to vfs
This patch adds unlinkpath() function in vfs to replace util.unlinkpath().
2014-06-05 15:16:44 +05:30
Chinmay Joshi
46bebd3c8d vfs: add lexists() in current api
lexists is added in current API of vfs.
2014-05-27 23:02:05 +05:30
Mads Kiilerich
df98b5168a match: improve documentation - docstrings and more descriptive variable naming
No real changes.

pattern: 'kind:pat' as specified on the command line
patterns, pats: list of patterns
kind: 'path', 'glob' or 're' or ...
pat: string in the corresponding 'kind' format
kindpats: list of (kind, pat) tuples
2013-10-03 18:01:21 +02:00
FUJIWARA Katsunori
4956966646 vfs: add "mkstemp()" 2014-03-09 01:03:28 +09:00
Pierre-Yves David
ce5b702bdf revpair: smartset compatibility
Since recent revset changes, revrange now return a smartset. This smart set
probably does not support indexing (_addset does not). This led to crash.
Instead when the smartset is ordered we use the `min` and `max` method of
smart set. Otherwise we turn is into a list and use indexing on it.

The tests have been updated to catch such regression.
2014-03-20 18:44:25 -07:00
Mads Kiilerich
914cc822c9 repo: rephrase the "missing requirement" error message
Unknown requirements will now be reported as:
  abort: repository requires features unknown to this Mercurial: largefiles!
  (see http://mercurial.selenic.com/wiki/MissingRequirement for more information)

Some features of this phrasing:
* avoid double ':' in abort message
* make it more clear who requires and knows what
* don't quote the requirement names - it is not something the user entered or
  need the exact spelling of ... and it is "identifiers" that are unambiguous
  anyway
* remove double hint by removing "(upgrade Mercurial)" comment
* don't mention upgrading Mercurial without mentioning enabling the feature -
  instead, just refer to wiki page for both
* don't just talk about "details", talk about "more information"
2014-03-19 00:18:30 +01:00
Pierre-Yves David
c515a37f0e revpair: drop useless conditional
The `if not revs:` case is tested at the beginning of the function.
2014-03-20 17:34:02 -07:00
Durham Goode
c173245d83 scmutil: fix revrange when multiple revs are specified
revrange was trying to add a list to a revset class, but revset classes only
support adding with other revset classes. So wrap the lists in basesets.
2014-03-20 09:55:44 -07:00
Matt Mackall
2dfc464098 revrange: pass repo to revset parser
This allows handling of hyphenated symbols for command-line revsets.
2014-03-18 17:56:27 -05:00
Pierre-Yves David
4b1a4196e2 require: provide a link to a wiki page in addition of suggesting upgrade
The wiki page is intended to describe several solution to the requirement issue.
Some of those solutions does not involve upgrading mercurial. That is very
useful for people that can't easily upgrade they Mercurial in some place.
2011-06-25 02:46:23 +02:00
Matt Mackall
b93e6d4112 merge with stable 2014-03-13 12:05:08 -05:00
Cristian Zamfir
c85ed151ff hg log: solves bug regarding hg log -r 0:null (issue4039)
'hg log -r 0:null' was showing only one changeset(the '-1' one) instead of the first two changesets.
2014-03-12 10:26:48 +02:00
Lucas Moscovicz
5e0ec4bc97 scmutil: changed revrange code not to use append
Removed one call to the append method
2014-02-24 09:27:32 -08:00
Lucas Moscovicz
ec3c3a2803 scmutil: changed revrange to return lazysets for new style revsets
When there is an old style revset or both it will still return a baseset. This
may be changed in later patches.
2014-02-12 15:30:27 -08:00
Lucas Moscovicz
ba7cfe4ed4 revset: changed revsets to use spanset
Performance Benchmarking:

$ hg perfrevset "first(all())"
! wall 0.304936 comb 0.300000 user 0.280000 sys 0.020000 (best of 33)

$ ./hg perfrevset "first(all())"
! wall 0.175640 comb 0.180000 user 0.160000 sys 0.020000 (best of 56)
2014-02-03 10:15:15 -08:00
Augie Fackler
8bfe6ea1ed itersubrepos: move to scmutil to break a direct import cycle 2014-02-03 18:36:00 -05:00
Lucas Moscovicz
ef8bd69f5f revset: added baseset class (still empty) to improve revset performance
This class is going to be used to cache the set that is created from this list
in many cases while evaluating a revset.
2014-01-21 11:39:26 -08:00
FUJIWARA Katsunori
f2d55c7c7d vfs: add "makelock()" and "readlock()" 2013-11-12 16:23:52 +09:00
FUJIWARA Katsunori
f39330457a vfs: add "chmod()" 2013-11-12 16:23:52 +09:00
FUJIWARA Katsunori
d6fa8a9bfa vfs: add "isfile()" 2013-11-12 16:23:52 +09:00
Siddharth Agarwal
25418f3155 scmutil.filecache: support watching over multiple files 2013-11-16 13:29:39 -08:00
Siddharth Agarwal
fceaf0623e scmutil: introduce a filecacheentry that can watch multiple paths 2013-11-16 13:24:26 -08:00
Siddharth Agarwal
3585a23345 scmutil: rename filecacheentry to filecachesubentry
Upcoming patches will allow the file cache to watch over multiple files, and
call the decorated function again if any of the files change.

The particular use case for this is the bookmark store, which needs to be
invalidated if either .hg/bookmarks or .hg/bookmarks.current changes. (This
doesn't currently happen, which is a bug. This bug will also be fixed in
upcoming patches.)
2013-11-16 13:19:06 -08:00
Siddharth Agarwal
cb19f2bbbe scmutil.filecacheentry: make stat argument to constructor mandatory
There's no real upside to making stat optional -- this constructor has just two
callers.
2013-11-16 13:33:33 -08:00
Augie Fackler
213fff305a pathutil: tease out a new library to break an import cycle from canonpath use 2013-11-06 18:19:04 -05:00
FUJIWARA Katsunori
d759404236 scmutil: skip checks in "casecollisionauditor" if filename is already checked
Before this patch, almost all of check code in
"casecollisionauditor.__call__()" is executed, even if specified
filename is already checked, because "f in self._newfiles" is examined
lastly.

In addition to it, adding "fl" to "self._loweredfiles" and "f" to
"self._newfiles" are also redundant in such case.

This patch checks "f in self._newfiles" first, and returns immediately
to avoid execution of check code for efficiency.
2013-11-12 00:07:23 +09:00
FUJIWARA Katsunori
770590e67f context: use "vfs.lstat()" instead of "os.lstat()"
This patch also changes paths added to "rejected" list from full path
(referred by "p") to relative one (referred by "f"), when type of
target path is neither file nor symlink.

This change should be reasonable, because the path added to "rejected"
list is relative one, when "OSError" is raised at "lstat()".
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
61a538d89f changelog: use "vfs.fstat()" instead of "util.fstat()"
Just invoking "os.fstat()" with "file.fileno()" doesn't require non
ANSI file API, because filename is not used for invocation of
"os.fstat()".

But "util.fstat()" should invoke "os.stat()" with "fp.name", if file
object doesn't have "fileno()" method for portability, and "fp.name"
may cause invocation of non ANSI file API.

So, this patch makes the constructor of appender class invoke
"util.fstat()" via vfs, to encapsulate filename handling.
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
49c8ebb7ec vfs: add "open()" for newly added code paths which open files via vfs
This patch replaces "open()" by own "__call__()" defined in derived
classes at the first invocation, for efficiency of succeeding
invocations.
2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
23a7a98972 bookmarks: use "vfs.utime()" instead of "os.utime()" 2013-10-15 00:51:04 +09:00
FUJIWARA Katsunori
33e3348b3e bookmarks: use "vfs.unlink()" instead of "util.unlink()" 2013-10-15 00:51:04 +09:00
Siddharth Agarwal
4f7171d11d addremove: don't do full walks
Full walks are only necessary when the caller needs the list of clean files.
addremove by definition doesn't need them.

With this patch and an extension that produces a subset of results for
dirstate.walk when full is False, on a repository with over 200,000 files, hg
addremove drops from 2.8 seconds to 0.5.
2013-09-04 18:42:55 -07:00
Matt Mackall
fac649fcb2 revsingle: fix silly API issue (issue2992) 2013-07-26 15:42:10 -05:00
Siddharth Agarwal
c944ae0c27 scmutil: add a function to mark that files have been operated on
Several places use scmutil.addremove as a means to declare that certain files
have been operated on. This is ugly because:
- addremove takes patterns relative to the cwd, not paths relative to the root,
  which means extra contortions for callers.
- addremove doesn't make clear what happens to files whose status hasn't
  changed.

This new method accepts filenames relative to the repo root, and has a much
clearer contract. It also allows future modifications that do more with files
whose status hasn't changed.
2013-04-04 13:38:28 -07:00
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