Commit Graph

922 Commits

Author SHA1 Message Date
Mateusz Kwapich
d57229b8c9 wrappers: improve push performance by reusing the existing metadata
Push operation for n commits regenerated SVNMeta class 2*n+1 times
(one time at beginning, n times in push() loop, 1 time per each of n
pulls). This operation is very costly when the revision map is big.

This commit reuses this metadata every time when there is no rebase
made between svn commits which leads to 1 metadata rebuild in optimistic
case and n+1 metadata rebuilds in pessimistic case (rebase after every commit).

To achieve this I added extra parameter to pull command to pass metadata
to it.

All unit tests are passing for this change.
2014-12-12 16:17:11 -08:00
Sean Farley
19e09234d3 wrappers: use meta.layout instead of accessing config directly 2014-03-24 11:20:54 -05:00
Sean Farley
a502f09e25 svnmeta: turn layout into a cached property
It turns out we don't need the fancy checks that were in the layout property
before so we use our new fancy property generator to cache this property.
2014-03-24 11:20:54 -05:00
Sean Farley
02fc964d97 wrappers: call new meta.layout_from_subversion 2014-03-24 11:20:54 -05:00
Sean Farley
37a50aac70 svnmeta: copy layout_from_subversion from detect 2014-03-24 11:20:54 -05:00
Sean Farley
cd8d43735f svnmeta: copy layout_from_commit from detect
This isn't used currently but will be in a future patch when we get rid of
layouts/detect.py and banish the import hgext_ business once and for all.
2014-03-24 11:20:54 -05:00
Sean Farley
88a2f791c1 layouts: turn taglocations method into a property
We no longer need to pass the meta path since we have an internal reference to
the meta object, so we remove the parameter from the taglocations method.
2014-03-24 11:20:53 -05:00
Sean Farley
d3d99c1127 wrappers: use meta.branch instead of ui.config directly 2014-03-24 11:20:53 -05:00
Sean Farley
32e0b804f2 layouts: generate cached taglocations property
Now that we have the machinery, we use the generator to define this
property. As a bonus, we no longer have to import util which saves from having
to import hgext_util.
2014-03-24 11:20:53 -05:00
Sean Farley
b7b85146d2 svnmeta: add generated cached branch property 2014-03-24 11:20:53 -05:00
Sean Farley
1761dd403f svnmeta: remove taglocations property
This is now unused so we'll remove it in favor of generating a cached property.
2014-03-24 11:20:53 -05:00
Sean Farley
59ebc066f2 svnmeta: remove unneeded call to self.taglocations
This is the only call to taglocations, therefore we remove it so that we can
remove the property in the next patch.
2014-03-24 11:20:53 -05:00
Sean Farley
516f2e922c util: remove unused getmessage function 2014-03-24 11:20:52 -05:00
Sean Farley
05d6756d06 stupid: call meta.getmessage instead of util 2014-03-24 11:20:52 -05:00
Sean Farley
07525f5144 wrappers: call meta.getmessage instead of util 2014-03-24 11:20:52 -05:00
Sean Farley
379a588508 replay: call meta.getmessage instead of util 2014-03-24 11:20:52 -05:00
Sean Farley
5ff98830ae svnmeta: call self.getmessage instead of util 2014-03-24 11:20:52 -05:00
Sean Farley
88684b15c8 svnmeta: use self.defaultmessage instead of ui.config call 2014-03-24 11:20:52 -05:00
Sean Farley
391bc23c61 svnmeta: generate cached defaultmessage property 2014-03-24 11:20:51 -05:00
Sean Farley
67e1752a84 svnmeta: copy util.getmessage to here so we can refactor
This doesn't do anything currently but will be used in upcoming patches to
refactor the call to ui.config.
2014-03-24 11:20:51 -05:00
Augie Fackler
dba3b45d3a Merge with stable. 2014-12-10 22:47:18 -05:00
Sean Farley
ecbf375c81 pull: adapt from upstream changes to transactions
Mercurial rev 1660b80d8083 introduced a transaction manager upstream. This
means that the closetransaction and releasetransaction methods on the pull
operation have gone away.

Code mostly based on Siddharth Agarwal's work on hg-git.
2014-12-10 14:04:55 -08:00
Augie Fackler
cb25d7e692 stupid: dedent some code
Done as two changes to make the previous change slightly easier to review.
2014-12-08 16:50:22 -05:00
Augie Fackler
71c13997fb stupid: remove code that's only used by hg < 1.9
Mercurial 1.9 is over three years old at this point, so I'm willing to
drop this code, as there's been an Ubuntu LTS release since then.
2014-12-08 16:49:52 -05:00
peter.geer
10dd76f73d genignore: fitler out empty lines in svn:ignore. 2014-11-13 22:09:06 -05:00
Siddharth Agarwal
8725bb6044 maps.RevMap: avoid O(revs) property lookups on dict
Loading a million-entry revmap goes from 3.72 seconds to 3.65.
2014-11-02 01:34:34 -08:00
Siddharth Agarwal
f3d5fd3d7d maps: avoid O(n) property lookups on the node module
The particular improvement we're interested in here is with loading the revmap.
Loading a million-entry revmap goes from 3.82 seconds to 3.72.
2014-11-02 01:27:38 -08:00
Siddharth Agarwal
58517c3aab maps.RevMap: while loading, read lastpulled and firstpulled once
Loading a million-entry revmap goes from 6.28 seconds to 3.82.
2014-11-02 01:23:47 -08:00
Siddharth Agarwal
96155571c7 maps.RevMap: disable GC while loading the revmap
The revmap load process creates lots of tiny objects.

With just the bare minimum Mercurial runtime, loading a million-file revmap
goes from 6.83 seconds to 6.28. For longer running processes (e.g. hg push a
series of changes) the difference will probably be dramatic.
2014-11-02 02:01:05 -08:00
Siddharth Agarwal
d65e15c2c2 util: add a decorator to disable Python's garbage collector
Python's GC can cause serious performance regressions if lots of small objects
are created within a function. We've empirically found that that happens while
loading the revmap.
2014-11-02 01:55:18 -08:00
Siddharth Agarwal
6829703912 wrappers.push: call pull instead of repo.pull
repo.pull went away in Mercurial rev 20bb6e6b4dc5. Calling pull directly is the
easiest way of maintaining compatibility across the change.
2014-10-13 23:57:21 -07:00
Siddharth Agarwal
04641fe869 pull: wrap exchange.pull if localrepository.pull isn't available
Mercurial rev 20bb6e6b4dc5 removed localrepository.pull. We don't do it the
other way round (wrap pull if exchange.pull is available) because that's been
available with a different signature since Mercurial 3.0.
2014-10-13 23:56:13 -07:00
Siddharth Agarwal
15bce1949a push: wrap exchange.push when localrepository.push isn't available
Mercurial rev 88d9d4ec499e removed localrepository.push. We don't do it the
other way round (wrap push if exchange.push is available) because that's been
available with a different signature since Mercurial 3.0.
2014-10-13 23:55:27 -07:00
Augie Fackler
566f9ebf7b stupid: add another None check
This seems to be required on my Linux machine, but not on my Mac. I'm
not motivated enough right now to try and figure out what's going on
here, so I'm just adding it (it can't hurt, after all) and moving on
so that hgsubversion works again with hg 3.2.
2014-09-17 11:25:52 -04:00
Siddharth Agarwal
5dccbf405a stupid: in svnbackend, adapt for core Mercurial changes
There's no efficient way to capture this API change in compathacks.
2014-09-16 16:19:43 -07:00
Siddharth Agarwal
2661c72b03 replay: use compat hack for filectxfn for deleted files 2014-09-16 16:35:21 -07:00
Siddharth Agarwal
1f57daf81a stupid: in fetch_branchrev, use compat hack for filectxfn for deleted files 2014-09-16 16:16:26 -07:00
Siddharth Agarwal
b39f0bfbdd stupid: in diff_branchrev, use compat hack for filectxfn for deleted files 2014-09-16 16:15:17 -07:00
Siddharth Agarwal
63cb2ec81a compathacks: add hacks for filectxfn deletion contract changing
Mercurial rev 2eef89bfd70d changed the contract for filectxfn, and rev
6c946e059d3b added a way for us to detect the change.
2014-09-16 16:42:57 -07:00
David Schleimer
02682b7f4c push: update to branch tip instead of tip
We previously updated to the repository tip after pushing a revision,
presumably on the assumption that tip would be the last revision we
just pushed.  This assumption is flawed for high traffic repositories.
In particular, you previsouly would sometimes end up on a completley
unrelated commit if someone else commits to a different branch in
between the time we push a revision and pull it back from the server.

This changes to instead update to the branch tip of the branch we were
on at the beginning of the push.  This should be either the revision
we just pushed or a linear descendent of the revision we just pushed,
with a fair degree of reliability.
2014-08-30 09:23:31 -07:00
David Schleimer
d5cff1b9a7 editor: fix replay handling for copied + modified symlinks
We strip the 'link ' prefix from symlinks when we store it in
Mercurial.  We reapply it when we start editing the file via
open_file, but not via add_file.  this means that modified symlniks
would replay correctly, but not copied and modified symlinks.  This
corrects that ommission.
2014-04-07 18:44:46 -07:00
David Schleimer
b56740789e editor: correctly import symlink copy+modify with non-empty prefix
We alwasy fail editing for symlinks, since we strip the leading 'link '
subversion includes when storing in mercurial, and then let svn
attempt to apply deltas against the stripped version.  This
unsurprisingly fails, and we write the resulting empty-string to the
Filestore for the current revision, and add the symlink in question to
the missing list to handle stupidly later.

Unfortunately, this would break down because editing adds files to the
store using their absolute path whereas missing files are added
relative to our subdir.  the absolut path file appears to win, which
results in us getting a symlink whose target is the empty string.

This fixes the problem by adding missing files to the fileStore using
their absolute path.
2014-04-07 18:28:35 -07:00
David Schleimer
f5fa156f6a editor: fix edge case with in memory file-store size limit
There are a few cases where we will set a single file into to the
editor's FileStore object more than once.  Notably, for copied and
then modified files, we will set it at least twice.  Three times if
editing fails (which it can for symlinks).

If we pass the in-memory storage limit in between the first (or second
if editing fails) time we set the file and the last time we set the
file, we will write the data to the in memory store the first time and
the file store the last time.  We didn't remove it form the in-memory
store though, and we always prefer reading from the in-memory store.
This means we can sometimes end up with the wrong version of a file.

This is fairly unlikely to happen in normal use since you need to hit
the memory limit between two writes to the store for the same file.
We only write a file multiple times if a) the file (and not one of
it's parent directories) is copied and then modified or b) editing
fails.  From what I can tell, it's only common for editing to fail for
symlinks, and they ten to be relatively small data that is unlikely to
push over the limit.  Finally, the default limit is 100MB which I
would expect to be most often either well over (source code) or well
under (binaries or automated changes) the size of the changes files in
a single commit.

The easiest way to reproduce this is to set the in-memory cache size
to 0 and then commit a copied and modified symlink.  The empty-string
version from the failed editing will be the one that persists.  I
happened to stumble upon this while trying (and failing) to test a
bug-fix for a related bug with identical symptoms (empty simlink). I
have seen this in the wild, once, but couldn't reproduce it at the
time. The repo in question is quite large and quite active, so I am
quite confident in my estimation that this is a real, but very rare,
problem.

The test changes attached to this was mneant to test a related bug,
but turned out not to actually cover the bug in question.  They did
trigger this bug though, and are worthwhile to test, so I kept them.
2014-04-07 17:51:59 -07:00
Sean Farley
6aa3411a72 layouts: remove unused _infix variable in standard 2014-03-24 11:20:51 -05:00
Sean Farley
3b2a06d1c3 layouts: use meta.infix in standard 2014-03-24 11:20:51 -05:00
Sean Farley
3636cc5f2b layouts: add cached infix property to standard 2014-03-24 11:20:51 -05:00
Sean Farley
7f04e01759 layouts: remove unused _trunk variable in standard 2014-03-24 11:20:51 -05:00
Sean Farley
9aded48f7e layouts: use trunk property instead of internal variable 2014-03-24 11:20:50 -05:00
Sean Farley
a103e2eafc layouts: turn trunk into a property for standard 2014-03-24 11:20:50 -05:00
Sean Farley
07038d5202 layouts: remove unused _branch_dir in standard 2014-03-24 11:20:50 -05:00
Sean Farley
db9c05d601 layouts: use meta.branchdir in standard 2014-03-24 11:20:50 -05:00
Sean Farley
3ad0163bd0 layouts: add cached branchdir property to standard
Currently, this does nothing but we will use this in the next patch to remove
the direct call to ui.config.
2014-03-24 11:20:50 -05:00
Sean Farley
67dc5ea17e svnmeta: add pre-transformation parameter to cached generator
This allows us to do some custom transformation of a value when loading a
config value.
2014-03-24 11:20:50 -05:00
Augie Fackler
a83fcbc351 Merge with stable. 2014-11-15 12:35:51 -05:00
Sean Farley
3d8f0df46d layouts: change constructor to take a meta object
This change is another step forward to centralize subversion configuration
options and help refactor.

I couldn't find an easier way to split up this change since there are many
interdependent function calls. There is no functionality change in this patch,
only renaming ui -> meta.
2014-03-24 11:20:49 -05:00
Sean Farley
104c0a8cf1 layouts: remove persist since we no longer use it 2014-03-24 11:20:49 -05:00
Sean Farley
c740a28f7e svnmeta: use util.dump instead of layout_to_file 2014-03-24 11:20:49 -05:00
Sean Farley
b2ea51e1c5 svncommands: use util.dump instead of layout_to_file 2014-03-24 11:20:49 -05:00
Sean Farley
780a840ab4 svnmeta: add a layout_file property 2014-03-24 11:20:49 -05:00
Sean Farley
beb8105077 layouts: use util.load in layout_from_config
This is a temporary move to make refactoring easier. Later patches will
use util.dump for writing layout_from_config, so we need to use
util.load first (since it provides a safe fallback to reading plain
text).

In later patches, all 'from hgext_hgsubversion' statements will be
removed.
2014-03-24 11:20:49 -05:00
Sean Farley
d8563a913b svnmeta: reorder code in __init__ for easier reading 2014-03-24 11:20:48 -05:00
David Schleimer
8645e02745 editor: correctly import copies of directories from non-tracked or closed branches 2013-11-17 09:57:00 -08:00
Augie Fackler
0a239b82dd Merge with stable. 2014-08-12 11:08:41 -04:00
David Schleimer
c2f7ff1156 pushmod: prepend "link " to base text for links
http://svn.apache.org/viewvc?view=revision&revision=1223036 exposes
what is arguably a bug in hgsubversion push code.  Specifically, when
we are receiving text from the server in an editor, we prepend a "link
" to the text of symlinks when opening a file and strip it when
closing a file.  We don't, however, prepend "link " to the base we use
when sending text changes to the server.

This was working before because prior to that revision, the first
thing subversion did was to check whether the entirety of the before
text or the entirety of the after text was less than 64 bytes.  In
that case, it just sent the entirety of the after text as a single
insert operation.  I'd expect most, but not all symlinks to fit under
the 64 byte limit, including the leading "link " text on the
subversion end.

After the change, the first thing subversion does is check for a
leading match that is more than 4 bytes long, or that is the full
length of the after text.  In this case, it sends a copy operation for
the leading match, and then goes into the if < 64 bytes remaining send
the whole thing behavior.  It also looks for trailing matches of more
than 4 bytes even in the <64 byte case, but that's not what breaks the
tests.

Incidentally, changing the destination of long symlinks was broken
even before this subversion change.  This diff includes test additions
that cover that breakage.
2014-08-07 19:30:26 -07:00
Sean Farley
341db7f9d5 stupid: call makememfilectx 2014-06-02 19:09:35 -05:00
Sean Farley
5a4b3add5b replay: call makememfilectx 2014-06-02 19:09:44 -05:00
Sean Farley
7adb488864 svnmeta: call makememfilectx 2014-06-02 19:09:11 -05:00
Sean Farley
a32b171762 compathacks: add wrapper for memfilectx 2014-06-02 19:53:49 -05:00
Dan Villiom Podlaski Christiansen
c38d59a800 push: fix obsolete feature detection
The obsolete feature detection didn't work with demandimport, breaking
hgsubversion when running against 2.0-2.3.
2014-04-22 15:53:11 +02:00
Durham Goode
058d316a53 push: update push logic to match mercurial upstream
Commit 87cd351dd15c in upstream Mercurial changed the checkpush function
signature. So we need to update hgsubversion accordingly.

Ran the tests against the tip of the hg repo, against a version of hg from
January before the exchange module, and against a version of hg after
pushoperations was added but before checkpush used it, and the tests passed in
all cases.
2014-04-09 16:17:13 -07:00
Augie Fackler
77bc017418 pull: fix pull when phases.new-commit=secret
This was causing subtle failures during pull. I believe the line where
we manually "set phase to public" isn't required any more, but more
work is required to verify that behavior on all versions of hg, so
we'll do that as a followup on default if needed.
2014-04-04 21:27:55 -04:00
Sean Farley
466a80a6b6 maps: change filemap to initialize with an svnmeta object
This refactoring will help us in a future patch have all map objects inherit
from a common ancestor.
2014-03-24 11:20:48 -05:00
Sean Farley
976f745417 svnmeta: turn filemap into a lazy property 2014-03-24 11:20:48 -05:00
Sean Farley
126cc70dd3 maps: load commandline filemap in __init__
Funcationally, this is the same as before but consolidates the logic to its own
object so we later refactor all the map objects to inherit from a common base
object.
2014-03-24 11:20:48 -05:00
Sean Farley
0edcd23468 maps: change branchmap to initialize with an svnmeta object
This refactoring will help us in a future patch have all map objects inherit
from a common ancestor.
2014-03-24 11:20:48 -05:00
Sean Farley
0a9978fac3 svnmeta: turn branchmap into a lazy property 2014-03-24 11:20:47 -05:00
Sean Farley
29bf696e86 maps: load commandline branchmap in __init__
Funcationally, this is the same as before but consolidates the logic to its own
object so we later refactor all the map objects to inherit from a common base
object.
2014-03-24 11:20:47 -05:00
Sean Farley
e6155e452f maps: change tagmap to initialize with an svnmeta object
This refactoring will help us in a future patch have all map objects inherit
from a common ancestor.
2014-03-24 11:20:47 -05:00
Sean Farley
df7fbbbc72 svnmeta: turn tagmap into a lazy property 2014-03-24 11:20:47 -05:00
Sean Farley
e3e74b6245 maps: load commandline tagmap in __init__
Funcationally, this is the same as before but consolidates the logic to its own
object so we later refactor all the map objects to inherit from a common base
object.
2014-03-24 11:20:47 -05:00
Sean Farley
6918242b79 svnmeta: turn authors into a lazy property 2014-03-24 11:20:46 -05:00
Sean Farley
d9757ff6c8 stupid: call makememfilectx 2014-06-02 19:09:35 -05:00
Sean Farley
2727cb4aa0 replay: call makememfilectx 2014-06-02 19:09:44 -05:00
Sean Farley
28363acb39 svnmeta: call makememfilectx 2014-06-02 19:09:11 -05:00
Sean Farley
c6ba771e1f compathacks: add wrapper for memfilectx 2014-06-02 19:53:49 -05:00
Sean Farley
8541dc1f47 svnmeta: explicitly test for None
There was a slight error in the way we were checking the value of 'c' via 'if
c'. If the type of 'c' is a bool then this could incorrectly be false. Instead,
we check for None explicitly. Nothing in production should have been affected
by this yet since this was only a problem with patches not yet released.
2014-06-02 16:31:54 -05:00
Sean Farley
291a080f06 maps: use meta.caseignoreauthors intead of accessing ui directly 2014-03-24 11:20:46 -05:00
Sean Farley
fb9db5a2eb maps: use meta.defaultauthors intead of accessing ui directly 2014-03-24 11:20:46 -05:00
Sean Farley
0763e38eab maps: change authormap to initialize with an svnmeta object
This refactoring will help us break AuthorMaps access of global options via
ui.config allowing us to use svnmeta as the central store for reading and
writing configuration options.
2014-03-24 11:20:46 -05:00
Sean Farley
a32fc2e636 maps: load commandline authormap in __init__
Funcationally, this is the same as before but consolidates the logic to its own
object so we later refactor all the map objects to inherit from a common base
object.
2014-03-24 11:20:46 -05:00
Sean Farley
9d33afd121 svnmeta: use generator for usebranchnames property 2014-03-24 11:20:46 -05:00
Sean Farley
a4b937183c svnmeta: add defaulthost property 2014-03-24 11:20:45 -05:00
Sean Farley
81bcb5367f svnmeta: add caseignoreauthors property 2014-03-24 11:20:45 -05:00
Sean Farley
65e7ce934d svnmeta: add defaultauthors property 2014-03-24 11:20:45 -05:00
Sean Farley
29501b71b6 maps: remove trailing whitespace 2014-03-24 11:20:45 -05:00
Sean Farley
170324a962 maps: change tags init to accept svnmeta not a repo
This is to allow us to access config options in one object.
2014-03-24 11:20:45 -05:00
Sean Farley
8a2b735de6 svnmeta: move revmap.oldest to meta.firstpulled
We factor out revmap.oldest and rename it to 'firstpulled' to make it analogous
with 'lastpulled'.
2014-03-24 11:20:45 -05:00
Sean Farley
2f09f19810 svncommands: use meta.lastpulled instead of revmap.youngest 2014-03-24 11:20:44 -05:00
Sean Farley
6a6a200bb6 svnmeta: move revmap.youngest to meta.lastpulled
Using our new generator, we factor out revmap.youngest and renamed it to the
same name as the config file 'lastpulled' because that is the name of the file
and is arguably less confusing to read.
2014-03-24 11:20:44 -05:00
Sean Farley
33a9a0d959 maps: change revmap init to accept svnmeta not a repo
This will allow us to access config options through one object.
2014-03-24 11:20:44 -05:00
Sean Farley
1351223c88 maps: change readmapfile to take a path instead of repo
This is a small refactor for an upcoming change that will change map objects to
store a svnmeta instead of the repo.
2014-03-24 11:20:44 -05:00
Sean Farley
ea456011e4 svnmeta: add generator for cached svn configuration properties
This will allow use to unify the reading and writing of configuration options
into a central object to simplify their use sprinkled throughout the codebase.

The idea is that after this patch, we will move each option to the svnmeta
class thereby allowing us to remove lots of I/O cruft. Once the cruft is gone,
we'll refactor objects where necessary. After refactoring, we'll have a
framework for easily adding new configuration options.
2014-03-24 11:20:44 -05:00
Dan Villiom Podlaski Christiansen
7d64194a42 push: fix obsolete feature detection
The obsolete feature detection didn't work with demandimport, breaking
hgsubversion when running against 2.0-2.3.
2014-04-22 15:53:11 +02:00
Augie Fackler
bf1fb7b5d7 wrappers: note which version of hg 87cd351dd15c is from 2014-04-12 11:02:11 -04:00
Durham Goode
9d71c3f5cd push: update push logic to match mercurial upstream
Commit 87cd351dd15c in upstream Mercurial changed the checkpush function
signature. So we need to update hgsubversion accordingly.

Ran the tests against the tip of the hg repo, against a version of hg from
January before the exchange module, and against a version of hg after
pushoperations was added but before checkpush used it, and the tests passed in
all cases.
2014-04-09 16:17:13 -07:00
Augie Fackler
3e09825ad7 Merge with stable. 2014-04-04 21:28:42 -04:00
Sean Farley
37578922ba svncommands: use RevMap.VERSION instead of hardcoding '1' 2014-03-24 11:20:44 -05:00
Sean Farley
e247109d3d svncommands: use meta.revmap_file 2014-03-24 17:13:06 -05:00
Sean Farley
c98d11684a svncommands: use meta.tags instead of duplicating code 2014-03-24 11:20:43 -05:00
Sean Farley
7809e602b1 svncommands: use meta.branch_info instead of duplicating logic 2014-03-24 11:20:43 -05:00
Sean Farley
eb9cab87ed svncommands: use meta.subdir instead of duplicating code
We now will use meta.subdir which will elminate most of the reading / writing
code in svncommands.
2014-03-24 11:20:43 -05:00
Sean Farley
c0a5b18825 svncommands: use meta.uuid instead of duplicating code
SVNMeta will take care of reading and writing the uuid file so we use that
instead of duplicating the same code.
2014-03-24 11:20:43 -05:00
Sean Farley
a91cf8d102 svncommands: use meta.metapath
This eliminates the need to hardcode '.hg/svn' as the meta data path.
2014-03-24 11:20:43 -05:00
Sean Farley
313a79666e svncommands: add svnmeta object
This patch adds a svnmeta object that currently does nothing but will be used
in upcoming patches to remove code duplication and unify svn meta data.
2014-03-24 11:20:43 -05:00
Sean Farley
60bc6b2e64 svnmeta: unify variable names cleanup
Since we're in the process of centralizing config settings and all metadata,
we'll take this chance to rename variables to be uniform.
2014-03-16 23:42:48 -05:00
Sean Farley
7c5e5a4d48 svnmeta: turn tags into lazy property
This has no effect currently but will be used in a future patch to make it
possible to create a SVNMeta object without having to load the tags file (for
use in rebuilding metadata).

Tests have been updated.
2014-02-22 18:26:48 -06:00
Sean Farley
318594e464 svnmeta: add tagfile property for use with the Tags object
This allows us to have one place for defining the name of this file.
2014-02-21 17:02:45 -06:00
Sean Farley
4468a44aa1 svnmeta: turn revmap into lazy property
This has no effect currently but will be used in a future patch to make it
possible to create a SVNMeta object without having to load the revmap (for use
in rebuilding metadata).
2014-02-17 16:29:54 -06:00
Sean Farley
915d7ce444 svnmeta: add revmap_file property 2014-02-17 16:23:30 -06:00
Sean Farley
4687067708 svnrepo: augment svnmeta method to take new error checking parameter 2014-02-20 13:21:32 -06:00
Sean Farley
c85c564a52 svnmeta: relax error checking with a parameter
This parameter is for an upcoming patch that will use the svnmeta object to
rebuild metadata instead of duplicating logic.
2014-02-18 22:48:45 -06:00
Sean Farley
db954fc19b svnmeta: rename meta_data_dir to metapath
This is part of a cleanup throughout hgsubversion to unify the codebase with
similar variable names and style.
2014-02-16 16:32:00 -06:00
Sean Farley
3a7659ec16 subdir: use util.dump and util.load for writing and reading
We need to change both svnmeta and svncommands at the same time since they are
heavily tied together.

The reason for this change is to remove the duplicate code for reading and
writing subdir present in svncommands.py. We will now use the standard
util.dump and util.load for writing and reading.

Due to the way json reads a string, the old format is still valid for use and
will be read correctly.
2014-02-18 18:28:33 -06:00
Sean Farley
fccbfd105d svncommands: remove unused {read,write}_if_needed methods 2014-02-18 17:29:58 -06:00
Sean Farley
c5bb92cb4a uuid: use util.dump and util.load for writing and reading
We need to change both svnmeta and svncommands at the same time since they are
heavily tied together.

The reason for this change is to remove the duplicate code for reading and
writing uuid present in svncommands.py. We will now use the standard util.dump
and util.load for writing and reading.

This presents a slight change in file format. Previously, the uuid file had the
format:

d073be05-634f-4543-b044-5fe20cf6d1d6[no newline]

and after this change, it is:

"d073be05-634f-4543-b044-5fe20cf6d1d6"[newline optional]

Due to the way json reads a string, the old format is still valid for use and
will be read correctly.
2014-03-14 19:44:35 -05:00
Sean Farley
dbf5c6edc1 util: fallback to raw string reading if pickle fails
This is the next step for getting rid of all the random read and write
functions throughout hgsubversion.
2014-02-18 17:19:29 -06:00
Sean Farley
d86829e2cd util: add resave bool parameter to load
This parameter is needed as a stopgap so that tests can use the common
util.load method without having to change the format of the file. It isn't used
now but will be in upcoming patches.
2014-02-18 17:16:28 -06:00
Sean Farley
9c82d8fd48 svncommands: call util.dump instead of manually writing file 2014-02-17 11:18:30 -06:00
Sean Farley
d356c463d8 util: remove unused save_string 2014-02-15 10:54:35 -06:00
Sean Farley
018df91880 maps: call util.dump instead save_string
Now that we're using json, we can use one centralized way of serializing data.
2014-02-15 10:54:08 -06:00
Sean Farley
c7e8c4663e util: remove unused load_string 2014-02-15 10:52:00 -06:00
Sean Farley
817bb83146 util: remove all calls to load_string
Now that we use json, we no longer need to load strings differently from any
other serialized data.
2014-02-15 10:45:51 -06:00
Sean Farley
5f480aa6d3 util: add default parameter to load
This will help facilitate moving load_string to just use load.
2014-02-15 10:42:54 -06:00
Sean Farley
d69f23e5a5 util: banish pickle to compathacks 2014-02-15 01:58:07 -06:00
Sean Farley
b25303f2f1 compathacks: specify for generic compatibility hacks 2014-02-15 01:59:21 -06:00
Sean Farley
bb091cfb0c compathacks: pep8 2014-02-15 01:53:55 -06:00
Sean Farley
6d7df8c2c9 util: convert pickle to json
If we fallback to loading data with pickle, then we immediately save the data
in json format to avoid any pickling in the future.
2014-02-15 10:09:13 -06:00
Sean Farley
2305362593 util: serialize data with json instead of pickle 2014-02-15 02:00:10 -06:00
Sean Farley
b486c5824e util: try to load data using json
Currently, this will do nothing since no part of hgsubversion writes json but
that will happen in a future patch. The goal of this is to move away from
pickle completely but fallback to reading pickle if json fails.
2014-02-15 01:50:14 -06:00
Sean Farley
12ea9d1c57 util: add visitor pattern for scrubbing json
These functions are for future patches that will add safer serialization via
json. '_convert' is a visitor pattern that will be used for lists,
dictionaries, and strings for helping convert None to the empty string since
json forbids 'null' as a key for a dictionary.

None -> '' is a safe mapping because this is for the 'branch_info' variable
which already maps the empty string to None.

Note, also, that json is chosen instead of, say, csv because json has a concept
of 'null' and will better handle utf8 strings (which subversion supports).

Important: this changes the requirement of hgsubversion to python 2.6+.
2014-02-17 11:10:38 -06:00
Michael Augustin
3ca35279c9 fix promptchoice call, since it changed in mercurial 2.7 (change 774df1869be9) 2014-02-04 22:38:54 +01:00
Sean Farley
4c2645abfc layouts: fix crash when importing hgext_hgsubversion
This change was introduced in 82dea72986d7 and fixed importing issues for
mercurial < 2.8. Unfortunately, this broke imports for newer versions of
mercurial that have hgsubversion installed in sys.path.

We now wrap the import in a try-block to catch this ImportError.
2014-02-06 14:30:05 -06:00
Augie Fackler
6c32a9db56 compathacks: new module to collect hacks to work around hg internals changing
This includes branchset(), which provides a portable way to get the
set of branches present in a repository.
2014-02-03 01:55:56 -05:00
Augie Fackler
27b89abb27 layouts: add importerror ladder so hgsubversion works as an installed module 2014-01-17 11:07:58 -05:00
Greg Ward
80e6876227 layouts: fix crash when importing hgsubversion itself (issue #402)
Mercurial extensions are a bit weird: they aren't normally in
sys.path, so you can't assume that "import hgsubversion" works.
Luckily, Mercurial sneaks a little treat into sys.modules so that
"import hgext_hgsubversion" does work. In fact, to get things working
*as a Mercurial extension*, all that's needed is that trivial change
to two import lines, in layouts/detect.py and layouts/standard.py.

Unfortunately, hgsubversion is also imported as a Python module, in
its own test suite. In that context, there is no "hgext_" trick --
unless we do it in ourselves, which I've done in TestBase.setUp().
That would work fine ... except that test_util imports from
hgsubversion, which ends up importing hgsubversion.layouts.{detect,standard},
which want the "hgext_" trick to work. But it hasn't been done yet
when we're still importing; it doesn't happen until setUp() runs.

So make those two imports happen late, in the functions that need them.

Incidentally, this is only necessary to support Mercurial <= 2.7.
Mercurial got a bit smarter in 2.8:
  http://selenic.com/repo/hg/rev/284a000c67bf
2014-01-02 21:53:39 -05:00
Siddharth Agarwal
17fb2129a5 svnexternals: import pathutil.canonpath if available
hgsubversion broke with upstream Mercurial due to 23ea9c746866. This fixes
that.
2013-11-22 11:09:59 -08:00
David Schleimer
fba6d35793 pull: correctly handle replacing the root of a branch with a non-copied directory
Prior to this diff, we would either crash, or continue past the
replacement without actually recording the change.  This could lead to
later failing varify if the state before and after weren't identical.
2013-11-16 16:16:59 -08:00
Sean Farley
0190702eb7 svncommands: use util.load instead of bare pickle 2013-08-23 11:00:41 -05:00
Sean Farley
d27840483c svncommands: use util.dump instead of pickle.dump 2013-08-23 20:35:05 -05:00
Sean Farley
db9ffd6364 svnmeta: use util.load instead of bare pickle 2013-08-23 10:58:03 -05:00