Commit Graph

28 Commits

Author SHA1 Message Date
Augie Fackler
6d4a8aa3a9 bookmarks: delegate writing to the repo just like reading
This makes it easier for alternate storage backends to not use flat
files for bookmarks storage.
2011-10-12 11:09:57 -05: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
Augie Fackler
139280a0ab bookmarks: use getattr instead of hasattr 2011-07-25 15:07:09 -05:00
Matt Mackall
a4528a6eaf bookmarks: simplify warning code 2011-07-06 19:25:56 -05:00
Matt Mackall
1278299c3f bookmarks: drop superfluous strip 2011-07-06 19:25:56 -05:00
Pierre-Yves David
31fc6f84be bookmarks: add a warning for non empty malformed line 2011-07-05 10:20:27 +02:00
Pierre-Yves David
5984ee96d7 bookmarks: more robust parsing of bookmarks file 2011-07-05 10:13:54 +02:00
LUO Zheng
04c821e46b bookmarks: recognize the current bookmark when the local encoding isn't UTF-8
The current bookmark is stored in bookmark.current, supposingly in UTF-8.
But the call to encoding.fromlocal() is missing, therefore Hg is not able
to recognize the current bookmark in the case that bookmark uses
characters of which the bit stream is different between local encoding
and UTF-8.
For example, the Chinese version of Windows cmd uses gbk(cp936), not UTF-8.
Therefore I won't be able to make a Chinese bookmark current.

By wrapping mark in a encoding.fromlocal() call, the problem is solved.
2011-06-08 21:25:18 +08:00
Matt Mackall
511ac574fb merge with stable 2011-05-08 16:16:41 -05: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
Benoit Boissinot
4e06bc9a34 bookmarks: discard current bookmark if absent from the bookmarks (issue2692)
After a rollback, the current bookmark might be absent from the bookmarks
file. In that case we discard it instead of displaying a traceback during
commit.
2011-03-13 14:36:47 +01:00
David Soria Parra
36125c089f bookmarks: restrict moving a bookmark to its descendants (issue1502)
A bookmark can only move to a descendant on commit, pull or
unbundle. Bookmarks cannot jump between heads anymore. This fixese
issue 1502.

We explicitly use new.node(), to emphasise that we are updating the
current bookmark to the new node.
2011-02-24 14:38:50 +01:00
David Soria Parra
90a5744f74 bookmarks: forbid \0 \r \n : in bookmark names (BC)
We restrict : to 1. make it easer to convert bookmarks to git branches,
2. use : later for a syntax to push a local bookmark to a remote bookmark
of a different name. \0, \n, \r are fobbidden they are used to separate
bookmarks in the bookmark file.

This change breaks backward compatbility as ':' was an allowed character in
previous versions.
2011-02-16 18:36:45 +01:00
David Soria Parra
12aa64e430 bookmarks: make track.current=True default behaviour and remove option (BC) 2011-02-16 01:29:26 +01:00
David Soria Parra
c2b26a0902 bookmarks: read current bookmark as utf-8 and convert it to local 2011-02-11 19:32:49 +01:00
Matt Mackall
1b243d934f bookmarks: move diff to core 2011-02-10 13:46:27 -06:00
Matt Mackall
3d6c8e8713 bookmarks: move pushkey functions into core 2011-02-10 13:46:27 -06:00
Matt Mackall
2580f39614 bookmarks: move update into core 2011-02-10 13:46:27 -06:00
Matt Mackall
7b71e510e5 bookmarks: move read methods to core 2011-02-10 13:46:27 -06:00
Matt Mackall
0506b0dd9c bookmarks: move basic io to core 2011-02-10 13:46:27 -06:00
Dan Villiom Podlaski Christiansen
511c941422 prevent transient leaks of file handle by using new helper functions
These leaks may occur in environments that don't employ a reference
counting GC, i.e. PyPy.

This implies:
 - changing opener(...).read() calls to opener.read(...)
 - changing opener(...).write() calls to opener.write(...)
 - changing open(...).read(...) to util.readfile(...)
 - changing open(...).write(...) to util.writefile(...)
2011-05-02 10:11:18 +02:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Idan Kamara
903182ef3d bookmarks: further restrict IOError on write
This won't risk losing the undo file when the error
was something other than file not found
2011-04-29 18:43:36 +03:00
Benoit Boissinot
ce0250b974 bookmarks: be more restrictive in our Exception catching 2011-03-13 15:02:49 +01:00
Idan Kamara
762d333ae9 eliminate various naked except clauses 2011-04-23 00:51:25 +03:00
David Soria Parra
10510a0de1 bundle: update current bookmark to most recent revision on current branch
We check if the current bookmark is set to the first parent of the
dirstate. Is this the case we move the bookmark to most recent revision
on the current branch (where hg update will update you to).
2011-03-14 23:03:56 +01:00
David Soria Parra
a43d669108 bookmarks: remove API limitation in setcurrent
setcurrent refuses to set a new current bookmark if the current bookmark
points to the current dirstate. This restriction is not needed. A current
bookmark can point to a different bookmark.
2011-03-14 09:36:17 +01:00
David Soria Parra
4e5087c547 bookmarks: separate bookmarks update code from localrepo's pull.
We explicitly want to update bookmarks from a remote. This will avoid
duplicate calls to listkeys if we clone (which calls pull) and keep
bookmark related code together.
2011-03-14 00:10:43 +01:00