Commit Graph

954 Commits

Author SHA1 Message Date
Greg Ward
cf0ea44613 rollback: only restore dirstate and branch when appropriate.
If the working dir parent was destroyed by rollback, then the old
behaviour is perfectly reasonable: restore dirstate, branch, and
bookmarks. That way the working dir moves back to an existing
changeset rather than becoming an orphan.

But if the working dir parent was unaffected -- say, you updated to an
older changeset and then did rollback -- then it's silly to restore
dirstate and branch. So don't do that. Leave the status of the working
dir alone. (But always restore bookmarks, because that file refers to
changeset IDs that may have been destroyed.)
2011-09-18 19:59:33 -04:00
Greg Ward
50490dab06 rollback: refactor for readability; cosmetics.
- clarify how we parse undo.desc
- fix bad grammar in an error message
- factor out ui local
- rename some local variables
- standardize string quoting
2011-09-16 21:38:06 -04:00
Greg Ward
5dc38028a3 share: allow trailing newline on .hg/sharedpath.
This is extremely handy for those occasional circumstances where you
need to edit .hg/sharedpath manually, since modern Unix text editors
make it surprisingly difficult to create a text file with no trailing
newline.
2011-09-14 22:28:27 -04:00
Greg Ward
897039c55d rollback: improve readability; clarify that the return value is an int. 2011-09-11 21:21:58 -04:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Idan Kamara
e37d7b9cbe localrepo: unify tag related info into a tagscache class 2011-07-25 15:08:57 +03:00
Idan Kamara
00456bfe26 localrepo: make invalidate() walk _filecache 2011-07-25 15:08:37 +03:00
Idan Kamara
a2947574cb localrepo: decorate manifest() with filecache 2011-07-25 15:08:37 +03:00
Idan Kamara
91c5accca8 localrepo: decorate _bookmarks/current with filecache
nodebookmarks() can be cached as well, leaving for later
2011-07-25 15:08:37 +03:00
Idan Kamara
61b90b0061 localrepo: decorate changelog() with filecache 2011-07-25 15:08:37 +03:00
Idan Kamara
398def5032 localrepo: refresh filecache entries after releasing a repo.lock() 2011-07-25 15:08:37 +03:00
Idan Kamara
e627b89651 localrepo: decorate dirstate() with filecache
We refresh the stat info when releasing repo.wlock(), right after writing it.

Also, invalidate the dirstate by deleting its attribute. This will force a
stat by the decorator that actually checks if anything changed, rather than
reading it again every time.

Note that prior to this, there was a single dirstate instance created for a
localrepo. It was invalidated by calling dirstate.invalidated(), clearing
its internal attributes.

As a consequence, the following construct is no longer safe:

  ds = repo.dirstate # keep a reference to the repo's dirstate
  wlock = repo.wlock()
  try:
      ds.setparents(...)
  finally:
      wlock.release() # dirstate should be written here

Since it's possible that the dirstate was modified between lines #1 and #2,
therefore changes to the old dirstate won't get written when the lock releases,
because a new instance was created by the decorator.
2011-07-25 15:08:37 +03:00
Idan Kamara
1c37933f72 localrepo: add a cache with stat info for files under .hg/ 2011-07-25 15:08:37 +03:00
Andrew Pritchard
99a944ad65 localrepo: make requirements attribute of newly-created repos contain a set
This is for internal consistency, as this attribute typically contains a set
2011-07-20 18:23:06 -04:00
Matt Mackall
fa1960ed0a localrepo: fix comment on set 2011-07-22 16:46:22 -05:00
Matt Mackall
5d4db33567 localrepo: add set method to iterate over a given revset
This should allow replacing a number of hand-rolled graph algorithms.
2011-07-21 14:06:55 -05:00
Matt Mackall
c78a7611d4 subrepo: use working copy of .hgsub to filter status (issue2901) 2011-07-13 17:41:49 -05:00
Mads Kiilerich
e8138203dd util: rename the util.localpath that uses url to urllocalpath (issue2875)
util is never imported by any other name than util, so this is mostly just a
simple search and replace from util.localpath to util.urllocalpath (assuming
other uses of util.localpath already has been renamed).
2011-07-01 17:37:09 +02:00
Wagner Bruna
a57ec020c9 localrepo: mark progress step for translation 2011-06-26 15:47:39 -03:00
Idan Kamara
3910bf241e localrepo: don't attempt to open .hgtags twice if the error isn't ENOENT 2011-06-15 23:15:04 +03:00
Matt Mackall
abe73723fb localrepo: local() returns self
Temporary measure for introducing peers
2011-06-13 12:51:38 -05:00
Matt Mackall
1b52b02896 check-code: catch misspellings of descendant
This word is fairly common in Mercurial, and easy to misspell.
2011-06-07 17:02:54 -05:00
Matt Mackall
c347d649b8 subrepo: be more careful with deletions of .hgsub and .hgsubstate (issue2844)
We shouldn't try to process subrepos if .hgsub isn't present and we
should remove .hgsubstate if .hgsub is marked for removal.
2011-06-06 15:17:40 -05:00
Patrick Mezard
f99a853422 localrepo: add savecommitmessage() to write last-message.txt 2011-06-04 15:56:48 +02:00
Sune Foldager
5d8acb706f localrepo: simplify file bundling code and fix progress bug
Progress for files was off by one, and the code was rather hackish.
2011-06-03 20:23:32 +02:00
Sune Foldager
307e81bf40 localrepo: use list comprehension instead of generators
The lists in question are iterated and kept in memory further down the code
path anyway, and this simplifies things.
2011-06-03 20:15:06 +02:00
Sune Foldager
e4e3ee35de localrepo: add total to changeset progress in bundle/push 2011-06-03 20:12:37 +02:00
Martin Geisler
af8a35e078 check-code: flag 0/1 used as constant Boolean expression 2011-06-01 12:38:46 +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
97c6e7b48d dirstate: rename forget to drop
It has substantially different semantics from forget at the command
layer, so change it to avoid confusion.

We can't simply combine it with remove because we need to explicitly
drop non-added files in some cases like commit.
2011-05-26 17:15:35 -05:00
Sune Foldager
9a73f9bed3 revlog: linearize created changegroups in generaldelta revlogs
This greatly improves the speed of the bundling process, and often reduces the
bundle size considerably. (Although if the repository is already ordered, this
has little effect on both time and bundle size.)

For non-generaldelta clients, the reduced bundle size translates to a reduced
repository size, similar to shrinking the revlogs (which uses the exact same
algorithm). For generaldelta clients the difference is minor.

When the new bundle format comes, reordering will not be necessary since we
can then store the deltaparent relationsships directly. The eventual default
behavior for clients and servers is presented in the table below, where "new"
implies support for GD as well as the new bundle format:

                    old client                    new client
old server          old bundle, no reorder        old bundle, no reorder
new server, non-GD  old bundle, no reorder[1]     old bundle, no reorder[2]
new server, GD      old bundle, reorder[3]        new bundle, no reorder[4]

[1] reordering is expensive on the server in this case, skip it
[2] client can choose to do its own redelta here
[3] reordering is needed because otherwise the pull does a lot of extra
    work on the server
[4] reordering isn't needed because client can get deltabase in bundle
    format

Currently, the default is to reorder on GD-servers, and not otherwise. A new
setting, bundle.reorder, has been added to override the default reordering
behavior. It can be set to either 'auto' (the default), or any true or false
value as a standard boolean setting, to either force the reordering on or off
regardless of generaldelta.


Some timing data from a relatively branch test repository follows. All
bundling is done with --all --type none options.

Non-generaldelta, non-shrunk repo:
-----------------------------------
Size: 276M

Without reorder (default):
Bundle time: 14.4 seconds
Bundle size: 939M

With reorder:
Bundle time: 1 minute, 29.3 seconds
Bundle size: 381M

Generaldelta, non-shrunk repo:
-----------------------------------
Size: 87M

Without reorder:
Bundle time: 2 minutes, 1.4 seconds
Bundle size: 939M

With reorder (default):
Bundle time: 25.5 seconds
Bundle size: 381M
2011-05-18 23:26:26 +02:00
Martin Geisler
b8eb9675f3 localrepo, sshrepo: use Boolean create argument in __init__ 2011-05-18 19:30:17 +02:00
Sune Foldager
d7f01e602b revlog: get rid of defversion
defversion was a property (later option) on the store opener, used to propagate
the changelog revlog format to the other revlogs, so they would be created with
the same format.

This required that the changelog instance was created before any other revlog;
an invariant that wasn't directly enforced (or documented) anywhere.

We now use the revlogv1 requirement instead, which is transfered to the store
opener options. If this option is missing, v0 revlogs are created.
2011-05-16 12:44:34 +02:00
Matt Mackall
5169d5397d merge with crew 2011-05-08 16:41:41 -05:00
Sune Foldager
1c7dece034 revlog: support writing generaldelta revlogs
With generaldelta switched on, deltas are always computed against the first
parent when adding revisions. This is done regardless of what revision the
incoming bundle, if any, is deltaed against.

The exact delta building strategy is subject to change, but this will not
affect compatibility.

Generaldelta is switched off by default.
2011-05-08 21:32:33 +02:00
Matt Mackall
511ac574fb merge with stable 2011-05-08 16:16:41 -05:00
Adrian Buehlmann
c415440828 rename util.set_flags to setflags 2011-05-06 15:22:31 +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
Sune Foldager
d959ff1e97 revlog: remove support for parentdelta
We will introduce a more powerful and general delta concept instead,
called generaldelta.
2011-05-05 12:55:12 +02:00
Alexander Solovyov
6240007914 fix bookmarks rollback behavior
Before this patch undo.bookmarks was created on bookmarks write and
not with other transaction-related files. There were two issues: first
is that if you have changed bookmarks few times after a transaction
happened, rollback will give you a state which can point to
non-existing revision. Second is that if you have not changed
bookmarks after a transaction, rollback will touch your state anyway.

This change also adds `localrepo._writejournal` method, which can be
used by other extensions to save their transaction-related backup in
right time.
2011-05-01 13:07:00 +02:00
Martin Geisler
f225a4e198 rollback: lower-case warning issued when branch cannot be reset
Also improved the word order.
2011-04-19 13:25:19 +02:00
Patrick Mezard
ee7651120f Improve unresolved merge conflicts warning (issue2681)
Suggested by Antoine Pitrou <pitrou@free.fr>
2011-03-06 15:21:50 +01:00
Steve Borho
9a4b1e24ec bookmark: fix invalidation of localrepo._bookmarkcurrent 2011-03-02 21:57:20 -06:00
Wagner Bruna
0d89e80dea rollback, i18n: avoid parameterized message 2011-02-21 20:58:54 -03:00
Adrian Buehlmann
a8a418601f introduce new RequirementError (issue2649)
This improves the misleading error message

  $ hg identify
  abort: there is no Mercurial repository here (.hg not found)!

to the more explicit

  $ hg identify
  abort: requirement 'fake' not supported!

for all commands in commands.optionalrepo, which includes the identify
and serve commands in particular.

This is for the case when a new entry in .hg/requires will be defined
in a future Mercurial release.
2011-02-18 20:25:25 +01:00
Gilles Moris
dcdc58f0a5 rollback: clarifies the message about the reverted state (issue2628)
Previously, when rolling back a transaction, some users could be confused
between the level to which the store is rolled back, and the new parents
of the working directory.

  $ hg rollback
  rolling back to revision 4 (undo commit)

With this change:
  $ hg rollback
  repository tip rolled back to tip revision 4 (undo commit)
  working directory now based on revision 2 and 1

So now the user can realize that the store has been rolled back to an older
tip, but also that the working directory may not on the tip (here we are
rolling back the merge of the heads 2 and 1)
2011-02-10 09:03:06 +01:00
Martin Geisler
4009f00b54 remove unnecessary list comprehensions
These result lists were only built for the side effects, and so a
normal loop is just as good and more straight-forward.
2011-02-03 10:31:17 +01:00
Patrick Mezard
1e4894d773 commit: abort if a subrepo is modified and ui.commitsubrepos=no
The default behaviour is to commit subrepositories with uncommitted changes. In
my experience this is usually undesirable:

- Changes to dependencies are often debugging leftovers
- Real changes should generally be applied on the source project directly,
  tested then committed. This is not always possible, subversion subrepos may
  include only a small part of the source project, without the tests.

Setting ui.commitsubrepos=no will now abort commits containing such modified
subrepositories like:

  $ hg --config ui.commitsubrepos=no ci -m msg
  abort: uncommitted changes in subrepo sub

I ruled out the hook solution because it does not easily take --include/exclude
options in account. Also, my main concern is whether this flag could cause
problems with extensions. If there are legitimate reasons for callers to
override this behaviour (I could not find any), they might either override at ui
level, or we could add an argument to localrepo.commit() later.

v2:
- Renamed ui.commitsubs to ui.commitsubrepos
- Mention the configuration entry in hg help subrepos
2011-02-15 22:25:48 +01:00
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Adrian Buehlmann
35765bcb3b fncachestore: defer updating the fncache file to a single file open
Defers updating the fncache file with newly added entries to the end of
the transaction (on e.g. pull), doing a single open call on the fncache
file, instead of opening and closing it each time a new entry is added
to the store.

Implemented by adding a new abstract write() function on store.basicstore
and registering it as a release function on the store lock in
localrepo.lock (compare with dirstate.write).

store.fncachestore overrides write() from basicstore and calls a new
write function on the fncache object, which writes all entries to the
fncache file if it's dirty.

store.fncache.add() now just marks itself as dirty if a new name is added.
2011-01-28 13:38:34 +01:00