Commit Graph

4915 Commits

Author SHA1 Message Date
Matt Mackall
e8c6616c42 match: redefine always and never in terms of match and exact 2009-05-24 02:56:14 -05:00
Matt Mackall
dad8161beb match: fold _globprefix into _roots 2009-05-24 02:56:14 -05:00
Matt Mackall
870bafcadb match: optimize escaping in _globre
- localize re.escape
- fastpath escaping of non-special characters
2009-05-24 02:56:14 -05:00
Matt Mackall
fb6d5f4ec6 match: remove head and tail args from _globre 2009-05-24 02:56:14 -05:00
Matt Mackall
6cec04c6af match: fold _matcher into match.__init__ 2009-05-24 02:56:14 -05:00
Matt Mackall
0b844e4b36 match: rename _matchfn to _buildmatch 2009-05-24 02:56:14 -05:00
Matt Mackall
64e6241687 match: optimize _patsplit 2009-05-24 02:56:14 -05:00
Matt Mackall
8ba6e48c01 match: tweak some names 2009-05-24 02:56:14 -05:00
Matt Mackall
cb5cd35394 match: simplify _matcher
- get rid of special case
- simplify anypats logic
- fold inckinds and exckinds
2009-05-24 02:56:14 -05:00
Matt Mackall
d9e0a2ed6d match: split up _normalizepats 2009-05-24 02:56:14 -05:00
Matt Mackall
3d1ba9cdd7 match: optimize _globprefix 2009-05-24 02:56:14 -05:00
Matt Mackall
e01c72ad8b match: unnest functions in _matcher 2009-05-24 02:56:14 -05:00
Matt Mackall
556e496bdb match: kill unused defaults on _globre 2009-05-24 02:56:14 -05:00
Matt Mackall
85df20c19d match: kill test in matchfn 2009-05-24 02:56:14 -05:00
Matt Mackall
d65d73641a match: refactor matchfn generation 2009-05-24 02:56:14 -05:00
Matt Mackall
f1f37a33cf match: move util match functions over 2009-05-24 02:56:14 -05:00
Matt Mackall
2658db5c8c util: privatize globre 2009-05-24 02:56:14 -05:00
Matt Mackall
b287cf72fe match: refactor patkind
add patkind(pat) to match
change external users
change util.patkind to _patsplit
2009-05-24 02:56:14 -05:00
Matt Mackall
89c18ad8ce match: add some default args 2009-05-24 02:56:14 -05:00
Matt Mackall
532c58d931 match: change all users of util.matcher to match.match 2009-05-24 02:56:14 -05:00
Sune Foldager
2161b139a6 named branches: improve pre-push logic (issue736)
Each named branch is considered separately, and the push is allowed if
no new branch heads are created for any named branch to be pushed.

Due to some tests's use of --debug, their output will change after this
addition. This has been fixed as well.

Co-contributor: Henrik Stuart <henrik.stuart@edlund.dk>
2009-05-23 17:04:31 +02:00
Henrik Stuart
a4975b3627 named branches: client branchmap wire protocol support (issue736)
Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-23 17:03:51 +02:00
Henrik Stuart
e3379206dc named branches: server branchmap wire protocol support (issue736)
The repository command, 'branchmap', returns a dictionary, branchname
-> [branchheads], and will be implemented for localrepo, httprepo and
sshrepo.

The following wire format is used for returning data:

branchname1 branch1head2 branch1head2 ...
branchname2 ...
...

Branch names are URL encoded to escape white space, and branch heads
are sent as hex encoded node ids. All branches and all their heads are
sent.

The background and motivation for this command is the desire for a
richer named branch semantics when pushing changesets. The details are
explained in the original proposal which is included below.


1. BACKGROUND

The algorithm currently implemented in Mercurial only considers the
graph theoretical heads when determining whether new heads are
created, rather than using the branch heads as a count (the algorithm
considers a branch head effectively closed when it is merged into
another branch or a new named branch is started from that point
onward).

Our particular problem with the algorithm is that we'd like to see the
following case working without forcing a push:

Upsteam has:

(0:dev) ---- (1:dev)
\
 `--- (2:stable)

Someone merges stable into dev:

(0:dev) ---- (1:dev) ------(3:dev)
\                         /
 `--- (2:stable) --------´

This can be pushed without --force (as it should).
Now someone else does some coding on stable (a bug fix, say):

(0:dev) ---- (1:dev) ------(3:dev)
\                          /
 `--- (2:stable) ---------´---------(4:stable)

This time we need --force to push.

We allow this to be pushed without using --force by getting all the
remote branch heads (by extending the wire protocol with a new
function).

We would, furthermore, also prefer if it is impossible to push a new
branch without --force (or a later --newbranch option so --force isn't
shoe-horned into too many disparate functions, if need be), except of
course in the case where the remote repository is empty.

This is what our patches accomplish.


2. ALTERNATIVES

We have, of course, considered some alternatives to reconstructing
enough information to decide whether we are creating new remote branch
heads, before we added the new wire protocol command.

2.1. LOOKUP ON REMOTE

The main alternative is to use the information from remote.heads() and
remote.lookup() to try to reconstruct enough graph information to
decide whether we are creating new heads. This is not adequate as
illustrated below.

Remember that each lookup is typically a request-response pair over
SSH or HTTP(S).

If we have a simple repository at the remote end like this:

(0:dev) ---- (1:dev) ---- (3:stable)
\
 `--- (2:dev)

then remote.heads() will yield [2, 3]. Assume we have nodes [0, 1, 2]
locally and want to create a new node, 4:dev, as a descendant from
(1:dev), which should be OK as 1:dev is a branch head.

If we do remote.lookup('dev') we will get [2]. Thus, we can get
information about whether a branch exists on the remote server or not,
but this does not solve our problem of figuring out whether we are
creating new heads or not.

Pushing 4:dev ought to be OK, since after the push, we still only have
two heads on branch a.

Using remote.lookup() and remote.heads() is thus not adequate to
consistently decide whether we are creating new remote heads (e.g. in
this situation the latter would never return 1:dev).

2.2. USING INCOMING TO RECONSTRUCT THE GRAPH

An alternative would be to use information equivalent to hg incoming
to get the full remote graph in addition to the local graph.

To do this, we would have to get a changegroup(subset) bundle
representing the remote end (which may be a substantial amount of
data), getting the branch heads from an instantiated bundlerepository,
deleting the bundle, and finally, we can compute the prepush logic.

While this is backwards compatible, it will cause a possibly
substantial slowdown of the push command as it first needs to pull in
all changes.


3. FURTHER ARGUMENTS IN FAVOUR OF THE BRANCHMAP WIRE-PROTOCOL EXTENSION

Currently, the commands incoming and pull, work based on the tip of a
given branch if used with "-r branchname", making it hard to get all
revisions of a certain branch only (if it has multiple heads). This
can be solved by requesting the remote's branchheads and letting the
revisions to be used with the command be these heads. This can be done
by extending the commands with a new option, e.g.:

hg pull -b branchname

which will be turned into the equivalent of:

hg pull -r branchhead1 -r branchhead2 -r branchhead3

We have a simple follow-up patch that can do this ready as well
(although not submitted yet as it is pending the acceptance of the
branch patch).


4. WRAP-UP

We generally find that the branchmap wire protocol extension can
provide better named branch support to Mercurial. Currently, some
things, like the initial push scenario in this mail, are fairly
counter-intuitive, and the more often you have to force push, the more
it is likely you will get a lot of spurious and unnecessary merge
nodes. Also, restricting incoming and pull to all changes on a branch
rather than changes on the tip-most head would be a sensible extension
to making named branches a first class citizen in Mercurial.
Currently, named branches sometimes feel like a late-coming unwanted
step-child.

We have run it in a production environment for a while, with fewer
multiple heads occurring in our repositories and fewer confused users
as a result.

Also, it fixes the long-standing issue 736.

Co-contributor: Sune Foldager <cryo@cyanite.org>
2009-05-23 17:02:49 +02:00
Henrik Stuart
fa95cc9642 windows: make openhardlinks work
Despite the intention, openhardlinks would always evaluate to False.
2009-05-23 19:57:25 +02:00
Matt Mackall
2c2304d400 revlog: fix reading of larger revlog indices on Windows 2009-05-23 11:53:23 -05:00
Steve Borho
2cd8aa240a merge: give hint as to how to discover uncommitted changes
Many users will try 'hg diff' here, and it will not show them missing files.
2009-05-22 11:42:21 -05:00
Ori Avtalion
f4e11a6715 commands: standardize parents command meta data 2009-05-22 18:57:53 +02:00
Martin Geisler
583bfda1f1 commands: remove unnecessary quotes in backout help 2009-05-21 17:36:19 +02:00
Patrick Mezard
f8fb6f0d87 ui: honor interactive=off even if isatty() 2009-05-21 20:59:36 +02:00
Patrick Mezard
89b691f7f6 Merge with crew-stable 2009-05-21 22:41:18 +02:00
Patrick Mezard
1e0e3ba6d6 hgwebdir: fix [collections] evaluation under Windows
Virtual and real path separators are not the same under Windows.
2009-05-21 20:32:45 +02:00
Martin Geisler
6355b4950b cmdutil: mark string for translation 2009-05-20 12:20:27 +02:00
Martin Geisler
5b0900d7be util: use "is" for True/False/None comparisons 2009-05-20 10:50:23 +02:00
Benoit Boissinot
58c694795e remove: warn if unversionned files are specified (issue1454) 2009-05-20 21:16:04 +02:00
Benoit Boissinot
5b1d4a56ec filelog encoding: move the encoding/decoding into store
the escaping of directories ending with .i or .d doesn't
really belong to filelog.

we put the encoding/decoding in store instead, for backwards
compat, streamclone and the fncache file format still uses the
partially encoded filenames.
2009-05-20 18:35:47 +02:00
Benoit Boissinot
ee58830640 store: refactor the fncache handling
put all the fncache file writing and reading in
the same place.
2009-05-20 18:35:41 +02:00
Jeremy Whitlock
c090150d2d hgweb: make hgwebdir handle dict/list paths the same as config paths
Before this patch, the only way to get hgwebdir to honor the recursive paths
was to create a config object or a config file with the recursive paths in it.
This patch makes hgwebdir treat paths the same whether passed in as a list,
tuple, config or however hgwebdir supports passing paths.
2009-05-20 16:04:37 +02:00
Benoit Boissinot
37cf6c6d68 workingfilectx: always use the same filelog, even for renames
workingfilectx() was using the "src" filelog in case the file was renamed in
the working copy.
For consistency, stop special-casing it. This allows us to remove some
duplication between filectx and workingfilectx.
2009-05-20 02:08:53 +02:00
Martin Geisler
0a365d5ca2 use 'x is None' instead of 'x == None'
The built-in None object is a singleton and it is therefore safe to
compare memory addresses with is. It is also faster, how much depends
on the object being compared. For a simple type like str I get:

            | s = "foo" | s = None
  ----------+-----------+----------
  s == None | 0.25 usec | 0.21 usec
  s is None | 0.17 usec | 0.17 usec
2009-05-20 00:52:46 +02:00
Martin Geisler
d4730b32a3 patch: simplify Boolean expression slightly
The context variable is either True, False or None. Abbreviate it as C
and we get the following truth table where the second column is the
original expression and the third column is the new expression:

  C     | C or C == None | C is not False
  True  | True           | True
  False | False          | False
  None  | True           | True
2009-05-20 00:43:23 +02:00
Martin Geisler
fc8a97dac3 changelog: refuse to add revisions with empty usernames
An empty username or a username with a "\n" will make the revision
text contain two "\n\n" sequences -> corrupt repository.

The problem is that changelog.read expects to find exactly one "\n\n"
separator and thus cannot unpack the revision.
2009-05-16 11:12:49 +02:00
Martin Geisler
aed75cf65f util: import random, missing since 5c703a28d882 2009-05-14 22:59:12 +02:00
Simon Heimberg
1b0d5c18bb match: use self.exact instead of lambda
self.exact uses a set and does not need an extra copy of the files
2009-05-15 09:43:30 +02:00
Simon Heimberg
23a0184faf dirstate: use quicker matchfn() instead of match() everywhere
matchfn does the same as match(), but a direct "link"
2009-05-14 19:47:52 +02:00
Benoit Boissinot
fc43ae9519 update --clean: do not unlink added files (issue575) 2009-05-19 03:59:58 +02:00
Martin Geisler
e651951731 templater: lowercase error message
Changing this messages should be safe: automated scripts ought to have
debugged their templates and wont grep for this error message.
2009-05-17 16:25:48 +02:00
Simon Heimberg
e859b5a899 util: use set instead of dict 2009-05-19 09:57:06 +02:00
Benoit Boissinot
32cfb07e37 localrepo: update commit*() docstrings 2009-05-19 11:39:12 +02:00
Matt Mackall
2c76d48a96 commit: tidy up mergestate slightly 2009-05-18 17:36:24 -05:00
Matt Mackall
74e80399a4 commit: drop unneeded dirstate invalidate logic
We no longer touch the dirstate in the middle of a commit, so a
failing commit doesn't require invalidating the dirstate.
2009-05-18 17:36:24 -05:00
Matt Mackall
4a8855a861 commit: some tidying
- simplify handling of 'close'
- kill silly wlock=None
- sort/uniq files later
2009-05-18 17:36:24 -05:00
Matt Mackall
7e42b4325d commit: remove unused lock var 2009-05-18 17:36:24 -05:00
Matt Mackall
98aa07c578 commit: move description trimming into changelog 2009-05-18 17:36:24 -05:00
Matt Mackall
6489ae039f commit: simplify manifest commit 2009-05-18 17:36:24 -05:00
Matt Mackall
16d4ef56bc commit: explain how to abort commit in editor 2009-05-18 17:36:24 -05:00
Matt Mackall
89cb6de980 commit: move editor outside transaction
The commit editor is now invoked before files and manifest are
committed. The editor is now run with only the wlock held and aborting
an edit no longer requires rolling back a transaction. Changes to
files during a commit still result in undefined behavior.

(This is preliminary work for committing subrepositories)
2009-05-18 17:36:24 -05:00
Matt Mackall
cfe14089d0 templater: replace eval with closure 2009-05-17 18:17:04 -05:00
Benoit Boissinot
bee6cb3d55 addremove/findrenames: find renames according to the match object (issue1527)
Instead of only finding similarities in the added/removed files found
by the addremove step, follow the match object:

hg addremove -s80 foo -> add and removes files in foo
                         + find similarities between files in foo
hg addremove -s80 -> add and removes files in the whole repo
                     + find similarities between files in the whole repo

hg import --similarity will still work correctly (only find similarities
between files found in the patch).
2009-05-17 22:51:17 +02:00
Benoit Boissinot
6f0577d081 addremove: mapping isn't really needed, simplify 2009-05-17 22:40:04 +02:00
Martin Geisler
1dfd32f41d hbisect: use set.update for bulk updates 2009-05-17 16:57:12 +02:00
Martin Geisler
6668b0e4a5 localrepo: use set.update for bulk updates 2009-05-17 16:56:53 +02:00
Martin Geisler
f7fa8ce35f store: create set directly from iterable 2009-05-17 16:56:20 +02:00
Martin Geisler
7901628fb3 repair: bulk update sets
Use a single set.update and set.difference_update call instead of many
set.add and set.discard calls.
2009-05-17 16:55:51 +02:00
Martin Geisler
698fece124 ui: use set instead of dict 2009-05-17 16:20:27 +02:00
Dirkjan Ochtman
140e5350fc templater: keep a cache of Python functions for filter expressions 2009-05-17 16:08:47 +02:00
Dirkjan Ochtman
56f023f70e templater: replace regex complexity by simple str containment checks 2009-05-17 16:06:48 +02:00
Dirkjan Ochtman
f421494a6a templater: clean up the process method, separating code paths 2009-05-17 16:05:50 +02:00
Benoit Boissinot
491d11faff localrepo: use set instead of dict 2009-05-17 04:33:39 +02:00
Benoit Boissinot
b23ce9123e copies: use set instead of dict 2009-05-17 04:20:59 +02:00
Benoit Boissinot
3f0d683495 store: use set instead of dict 2009-05-17 04:16:44 +02:00
Benoit Boissinot
f23fc93dd5 verify: use set instead of dict 2009-05-17 04:14:15 +02:00
Benoit Boissinot
1f59ef6f81 ancestor: use set instead of dict 2009-05-17 03:53:13 +02:00
Benoit Boissinot
c97e6590bb revlog: use set instead of dict 2009-05-17 03:49:59 +02:00
Benoit Boissinot
dbf61e11b8 bisect: use set instead of dict 2009-05-17 03:40:54 +02:00
Benoit Boissinot
21c663ad08 repair: use set instead of dict 2009-05-17 03:38:03 +02:00
Benoit Boissinot
a59b10003e patch: use set instead of dict 2009-05-17 03:28:49 +02:00
Benoit Boissinot
c8bc34d692 revlog.missing(): use sets instead of a dict 2009-05-17 02:44:12 +02:00
Martin Geisler
b43ec973e1 changelog: turn {de,en}code_extra methods into functions
The methods were not really methods -- they didn't use 'self'. Having
them as functions in the module it useful for other modules (like the
commitsigs extension) that want to recompute the changeset hash and
thus want to encode dicts the same way as changelog does it.

Removed the underbars from their names at the same time.
2009-05-15 01:21:24 +02:00
Martin Geisler
f138e91851 merge with crew-stable 2009-05-16 11:16:23 +02:00
Martin Geisler
49d93faf0c changelog: removed bad default arguments in add method
The arguments defaulted to None, but

- user cannot be None since it is immediately stripped.

- p1 and p2 cannot be None since they are passed directly to
  revlog.addrevision, where they are mandatory.
2009-05-15 00:55:14 +02:00
Sune Foldager
adc90b2605 posixfile: remove posixfile_nt and fix import bug in windows.py
The posixfile_nt class has been superseded by posixfile in osutils.c,
which works on Windows NT and above. All other systems get the regular
python file class which is assigned to posixfile in posix.py (for POSIX)
and in the pure python version of osutils.py (for Win 9x or Windows NT
in pure mode).
2009-05-13 21:36:16 +02:00
Bryan O'Sullivan
496cd5e84c util: make atomictempfile saner if mktempcopy fails 2009-05-14 14:12:32 -07:00
Brett Carter
d69cd3912f clone: try updating to the actual changeset specified in options
When cloning with the -r option or # url format from a tag the destination
repo most likely won't have the tag. We can save the lookup result to get to
the correct parent anyway. Similar to issue1306, but for tags.
2009-05-14 22:00:56 +02:00
Matt Mackall
1317ac7a01 commit: hoist the rest of the dirstate manipulation out of commitctx 2009-05-14 13:24:39 -05:00
Matt Mackall
c2aadfc41a commit: hoist up dirstate invalidate 2009-05-14 13:24:39 -05:00
Matt Mackall
a8b0644dec commitctx: use contexts more fully 2009-05-14 13:24:26 -05:00
Matt Mackall
188df2eaa9 context: add new manifestnode method 2009-05-14 13:21:20 -05:00
Matt Mackall
3a18f346a9 commitctx: eliminate some variables 2009-05-14 13:21:20 -05:00
Matt Mackall
38ebdc6dd1 commit: move lots of commitctx outside of the repo lock 2009-05-14 13:21:20 -05:00
Matt Mackall
a9fbdd49f0 commit: combine _commitctx and commitctx, drop unused force argument 2009-05-14 13:21:20 -05:00
Matt Mackall
5534a9c3e3 editor: move HG: filtering from ui to commiteditor 2009-05-14 13:21:17 -05:00
Matt Mackall
2e4dd0c345 grep: make cache LRU rather than unlimited
grep could cache an unbounded number of revlogs, limit to 20 with an
LRU cache.
2009-05-14 13:20:40 -05:00
Matt Mackall
ebe3b0ebc3 commit: move commit editor to cmdutil, pass as function 2009-05-14 13:20:40 -05:00
Matt Mackall
9a5dcd2974 context: add p1 and p2 methods 2009-05-14 13:20:40 -05:00
Matt Mackall
ad33c59077 commit: push repo lock down into _commitctx 2009-05-14 13:20:40 -05:00
Matt Mackall
580ab4b4ab commit: move 'nothing changed' test into commit() 2009-05-14 13:20:40 -05:00
Matt Mackall
771b18c870 commit: drop unused p1 and p2 args 2009-05-14 13:20:40 -05:00
Matt Mackall
d229f38315 tag: drop unused use_dirstate and parent from _tag() 2009-05-14 13:20:40 -05:00
Matt Mackall
49e6e0b6c0 filecommit: swallow some bits from _commitctx, add _ 2009-05-14 13:20:40 -05:00
Matt Mackall
e77584d5e2 commitctx: replace wctx with ctx 2009-05-14 13:20:40 -05:00