annotate hgsubversion/hg_delta_editor.py @ 378:eeefbe104087

Inline HgChangeReceiver.load_base_from_ctx().
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Fri, 29 May 2009 22:48:27 +0200
parents 7e9269555e72
children 639105d25a2f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import cStringIO
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import cPickle as pickle
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4 import sys
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 import tempfile
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6 import traceback
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import context
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 from mercurial import hg
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 from mercurial import ui
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
11 from mercurial import util as hgutil
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 from mercurial import revlog
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13 from mercurial import node
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
14 from mercurial import error
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 from svn import delta
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 from svn import core
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
18 import svnexternals
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
19 import util
317
5dc8fee7fc96 Less import *
Augie Fackler <durin42@gmail.com>
parents: 316
diff changeset
20 import maps
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
21
363
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
22 class MissingPlainTextError(Exception):
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
23 """Exception raised when the repo lacks a source file required for replaying
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
24 a txdelta.
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
25 """
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
26
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
27 class ReplayException(Exception):
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
28 """Exception raised when you try and commit but the replay encountered an
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
29 exception.
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
30 """
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
31
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
32 def pickle_atomic(data, file_path, dir=None):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
33 """pickle some data to a path atomically.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
34
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 This is present because I kept corrupting my revmap by managing to hit ^C
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
36 during the pickle of that file.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
38 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
39 f, path = tempfile.mkstemp(prefix='pickling', dir=dir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
40 f = os.fdopen(f, 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
41 pickle.dump(data, f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
42 f.close()
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
43 except: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
44 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 else:
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
46 hgutil.rename(path, file_path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
48 def ieditor(fn):
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
49 """Helps identify methods used by the SVN editor interface.
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
50
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
51 Stash any exception raised in the method on self.
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
53 This is required because the SWIG bindings just mutate any exception into
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
54 a generic Subversion exception with no way of telling what the original was.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
55 This allows the editor object to notice when you try and commit and really
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
56 got an exception in the replay process.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 def fun(self, *args, **kwargs):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 return fn(self, *args, **kwargs)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
61 except: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 if not hasattr(self, '_exception_info'):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 self._exception_info = sys.exc_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
65 return fun
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 class HgChangeReceiver(delta.Editor):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
69 def add_to_revmap(self, revnum, branch, node_hash):
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
70 f = open(self.revmap_file, 'a')
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
71 f.write(str(revnum) + ' ' + node.hex(node_hash) + ' ' + (branch or '') + '\n')
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
72 f.flush()
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
73 f.close()
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
74 self.revmap[revnum, branch] = node_hash
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
75
225
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
76 def last_known_revision(self):
227
d79843a3d42c Fixing syntax highlighting in emacs.
Augie Fackler <durin42@gmail.com>
parents: 226
diff changeset
77 """Obtain the highest numbered -- i.e. latest -- revision known.
225
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
78
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
79 Currently, this function just iterates over the entire revision map
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
80 using the max() builtin. This may be slow for extremely large
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
81 repositories, but for now, it's fast enough.
227
d79843a3d42c Fixing syntax highlighting in emacs.
Augie Fackler <durin42@gmail.com>
parents: 226
diff changeset
82 """
225
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
83 try:
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
84 return max(k[0] for k in self.revmap.iterkeys())
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
85 except ValueError:
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
86 return 0
2117cb0118fe Get rid of .hg/svn/last_rev:
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
87
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
88 def __init__(self, repo=None, path=None, ui_=None,
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 123
diff changeset
89 subdir='', author_host='',
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
90 tag_locations=[],
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
91 authors=None, filemap=None, uuid=None):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
92 """path is the path to the target hg repo.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
93
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
94 subdir is the subdirectory of the edits *on the svn server*.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
95 It is needed for stripping paths off in certain cases.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
96 """
214
1416429584b2 Reuse ui from the repo if available.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 211
diff changeset
97 if repo and repo.ui and not ui_:
1416429584b2 Reuse ui from the repo if available.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 211
diff changeset
98 ui_ = repo.ui
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
99 if not ui_:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
100 ui_ = ui.ui()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
101 self.ui = ui_
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
102 self.__setup_repo(uuid, repo, path, subdir)
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
103
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
104 if not author_host:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
105 author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
106 if not authors:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
107 authors = self.ui.config('hgsubversion', 'authormap')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
108 if not filemap:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
109 filemap = self.ui.config('hgsubversion', 'filemap')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
110 if not tag_locations:
342
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 339
diff changeset
111 tag_locations = self.ui.configlist('hgsubversion', 'tagpaths', ['tags'])
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
112 self.usebranchnames = self.ui.configbool('hgsubversion',
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
113 'usebranchnames', True)
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 123
diff changeset
114
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
115 # FIXME: test that this hasn't changed! defer & compare?
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
116 self.subdir = subdir
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
117 if self.subdir and self.subdir[0] == '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
118 self.subdir = self.subdir[1:]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
119 self.branches = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
120 if os.path.exists(self.branch_info_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
121 f = open(self.branch_info_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
122 self.branches = pickle.load(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
123 f.close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
124 self.tags = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
125 if os.path.exists(self.tag_info_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
126 f = open(self.tag_info_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
127 self.tags = pickle.load(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
128 f.close()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
129 if os.path.exists(self.tag_locations_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
130 f = open(self.tag_locations_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
131 self.tag_locations = pickle.load(f)
8
c89f53103502 Another fix for Win32 compat.
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents: 6
diff changeset
132 f.close()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
133 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
134 self.tag_locations = tag_locations
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
135 pickle_atomic(self.tag_locations, self.tag_locations_file,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
136 self.meta_data_dir)
295
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
137 # ensure nested paths are handled properly
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
138 self.tag_locations.sort()
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
139 self.tag_locations.reverse()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
141 self.clear_current_info()
317
5dc8fee7fc96 Less import *
Augie Fackler <durin42@gmail.com>
parents: 316
diff changeset
142 self.authors = maps.AuthorMap(self.ui, self.authors_file,
307
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
143 defaulthost=author_host)
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
144 if authors: self.authors.load(authors)
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
145
290
153266401676 hg_delta_editor: add timezone to default date to avoid DST issues
Patrick Mezard <pmezard@gmail.com>
parents: 279
diff changeset
146 self.lastdate = '1970-01-01 00:00:00 -0000'
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
147 self.includepaths = {}
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
148 self.excludepaths = {}
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
149 if filemap and os.path.exists(filemap):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
150 self.readfilemap(filemap)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
151
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
152 def fixdate(self, date):
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
153 if date is not None:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
154 date = date.replace('T', ' ').replace('Z', '').split('.')[0]
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
155 date += ' -0000'
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
156 self.lastdate = date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
157 else:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
158 date = self.lastdate
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
159 return date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
160
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
161 def __setup_repo(self, uuid, repo, path, subdir):
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
162 """Verify the repo is going to work out for us.
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
163
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
164 This method will fail an assertion if the repo exists but doesn't have
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
165 the Subversion metadata.
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
166 """
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
167 if repo:
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
168 self.repo = repo
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
169 self.path = os.path.normpath(self.repo.join('..'))
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
170 elif path:
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
171 self.repo = hg.repository(self.ui, path,
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
172 create=(not os.path.exists(path)))
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
173 self.path = os.path.normpath(os.path.join(path, '..'))
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 317
diff changeset
174 else: #pragma: no cover
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 317
diff changeset
175 raise TypeError("editor requires either a path or a repository "
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 317
diff changeset
176 "specified")
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 317
diff changeset
177
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
178 if not os.path.isdir(self.meta_data_dir):
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
179 os.makedirs(self.meta_data_dir)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
180 self._set_uuid(uuid)
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
181 # TODO: validate subdir too
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
182
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
183 if os.path.isfile(self.revmap_file):
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
184 self.revmap = util.parse_revmap(self.revmap_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
185 else:
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
186 self.revmap = {}
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
187 f = open(self.revmap_file, 'w')
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
188 f.write('%s\n' % util.REVMAP_FILE_VERSION)
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
189 f.flush()
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 33
diff changeset
190 f.close()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
191
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
192 def clear_current_info(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
193 '''Clear the info relevant to a replayed revision so that the next
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
194 revision can be replayed.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
195 '''
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
196 # Map files to raw svn data (symlink prefix is preserved)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
197 self.current_files = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
198 self.deleted_files = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
199 self.current_rev = None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
200 self.current_files_exec = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
201 self.current_files_symlink = {}
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
202 self.dir_batons = {}
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
203 # Map fully qualified destination file paths to module source path
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
204 self.copies = {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
205 self.missing_plaintexts = set()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
206 self.commit_branches_empty = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
207 self.base_revision = None
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
208 self.branches_to_delete = set()
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
209 self.externals = {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
210
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
211 def _save_metadata(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
212 '''Save the Subversion metadata. This should really be called after
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
213 every revision is created.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
214 '''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
215 pickle_atomic(self.branches, self.branch_info_file, self.meta_data_dir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
216 pickle_atomic(self.tags, self.tag_info_file, self.meta_data_dir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
217
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
218 def _path_and_branch_for_path(self, path, existing=True):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
219 return self._split_branch_path(path, existing=existing)[:2]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
220
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
221 def _branch_for_path(self, path, existing=True):
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
222 return self._path_and_branch_for_path(path, existing=existing)[1]
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
223
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
224 def _localname(self, path):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
225 """Compute the local name for a branch located at path.
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
226 """
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
227 assert not path.startswith('tags/')
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
228 if path == 'trunk':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
229 return None
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
230 elif path.startswith('branches/'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
231 return path[len('branches/'):]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
232 return '../%s' % path
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
233
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
234 def _remotename(self, branch):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
235 if branch == 'default' or branch is None:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
236 return 'trunk'
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
237 elif branch.startswith('../'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
238 return branch[3:]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
239 return 'branches/%s' % branch
72
9ec2a12c12ae hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents: 69
diff changeset
240
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
241 def _split_branch_path(self, path, existing=True):
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
242 """Figure out which branch inside our repo this path represents, and
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
243 also figure out which path inside that branch it is.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
244
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
245 Returns a tuple of (path within branch, local branch name, server-side branch path).
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
246
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
247 If existing=True, will return None, None, None if the file isn't on some known
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
248 branch. If existing=False, then it will guess what the branch would be if it were
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
249 known.
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
250 """
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
251 path = self._normalize_path(path)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
252 if path.startswith('tags/'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
253 return None, None, None
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
254 test = ''
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
255 path_comps = path.split('/')
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
256 while self._localname(test) not in self.branches and len(path_comps):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
257 if not test:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
258 test = path_comps.pop(0)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
259 else:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
260 test += '/%s' % path_comps.pop(0)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
261 if self._localname(test) in self.branches:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
262 return path[len(test)+1:], self._localname(test), test
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
263 if existing:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
264 return None, None, None
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
265 if path == 'trunk' or path.startswith('trunk/'):
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
266 path = path.split('/')[1:]
207
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
267 test = 'trunk'
218
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
268 elif path.startswith('branches/'):
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
269 elts = path.split('/')
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
270 test = '/'.join(elts[:2])
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
271 path = '/'.join(elts[2:])
207
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
272 else:
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
273 path = test.split('/')[-1]
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
274 test = '/'.join(test.split('/')[:-1])
218
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
275 ln = self._localname(test)
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
276 if ln and ln.startswith('../'):
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
277 return None, None, None
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
278 return path, ln, test
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 def set_current_rev(self, rev):
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
281 """Set the revision we're currently converting.
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
282 """
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 self.current_rev = rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
285 def set_file(self, path, data, isexec=False, islink=False):
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
286 if islink:
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
287 data = 'link ' + data
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
288 self.current_files[path] = data
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
289 self.current_files_exec[path] = isexec
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
290 self.current_files_symlink[path] = islink
123
58de7aea8a77 Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents: 120
diff changeset
291 if path in self.deleted_files:
58de7aea8a77 Fix a bug in replay convert where replaced files that couldn't use replay
Augie Fackler <durin42@gmail.com>
parents: 120
diff changeset
292 del self.deleted_files[path]
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
293 if path in self.missing_plaintexts:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
294 self.missing_plaintexts.remove(path)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
295
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
296 def delete_file(self, path):
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
297 self.deleted_files[path] = True
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
298 if path in self.current_files:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
299 del self.current_files[path]
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
300 self.current_files_exec[path] = False
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
301 self.current_files_symlink[path] = False
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
302 self.ui.note('D %s\n' % path)
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
303
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
304 def _normalize_path(self, path):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
305 '''Normalize a path to strip of leading slashes and our subdir if we
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
306 have one.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
307 '''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
308 if path and path[0] == '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
309 path = path[1:]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
310 if path and path.startswith(self.subdir):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
311 path = path[len(self.subdir):]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
312 if path and path[0] == '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
313 path = path[1:]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
314 return path
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
315
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
316 def _is_file_included(self, subpath):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
317 def checkpathinmap(path, mapping):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
318 def rpairs(name):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
319 yield '.', name
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
320 e = len(name)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
321 while e != -1:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
322 yield name[:e], name[e+1:]
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
323 e = name.rfind('/', 0, e)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
324
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
325 for pre, suf in rpairs(path):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
326 try:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
327 return mapping[pre]
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
328 except KeyError, err:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
329 pass
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
330 return None
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
331
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
332 if len(self.includepaths) and len(subpath):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
333 inc = checkpathinmap(subpath, self.includepaths)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
334 else:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
335 inc = subpath
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
336 if len(self.excludepaths) and len(subpath):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
337 exc = checkpathinmap(subpath, self.excludepaths)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
338 else:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
339 exc = None
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
340 if inc is None or exc is not None:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
341 return False
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
342 return True
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
343
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
344 def _is_path_valid(self, path):
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
345 if path is None:
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
346 return False
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
347 subpath = self._split_branch_path(path)[0]
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
348 if subpath is None:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
349 return False
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
350 return self._is_file_included(subpath)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
351
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
352 def _is_path_tag(self, path):
365
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
353 """If path could represent the path to a tag, returns the potential tag
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
354 name. Otherwise, returns False.
306
e6853c7fa3af hg_delta_editor: fix _split_tag_path to actually work as intended.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 304
diff changeset
355
365
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
356 Note that it's only a tag if it was copied from the path '' in a branch
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
357 (or tag) we have, for our purposes.
306
e6853c7fa3af hg_delta_editor: fix _split_tag_path to actually work as intended.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 304
diff changeset
358 """
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
359 path = self._normalize_path(path)
365
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
360 for tagspath in self.tag_locations:
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
361 onpath = path.startswith(tagspath)
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
362 longer = len(path) > len('%s/' % tagspath)
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
363 if path and onpath and longer:
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
364 tag, subpath = path[len(tagspath) + 1:], ''
325
4f4db3d2fdbb 2.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents: 322
diff changeset
365 if '/' in tag:
4f4db3d2fdbb 2.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents: 322
diff changeset
366 tag, subpath = tag.split('/', 1)
365
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
367 return tag
e8f5688a0cd9 Merge hge._is_path_tag() and hge._split_tag_path().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 364
diff changeset
368 return False
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
369
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
370 def get_parent_svn_branch_and_rev(self, number, branch):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
371 number -= 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
372 if (number, branch) in self.revmap:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
373 return number, branch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
374 real_num = 0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
375 for num, br in self.revmap.iterkeys():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
376 if br != branch:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
377 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
378 if num <= number and num > real_num:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
379 real_num = num
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
380 if branch in self.branches:
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
381 parent_branch = self.branches[branch][0]
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
382 parent_branch_rev = self.branches[branch][1]
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
383 # check to see if this branch already existed and is the same
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
384 if parent_branch_rev < real_num:
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
385 return real_num, branch
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
386 # if that wasn't true, then this is the a new branch with the
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
387 # same name as some old deleted branch
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
388 if parent_branch_rev <= 0 and real_num == 0:
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
389 return None, None
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
390 branch_created_rev = self.branches[branch][2]
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
391 if parent_branch == 'trunk':
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
392 parent_branch = None
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
393 if branch_created_rev <= number+1 and branch != parent_branch:
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
394 return self.get_parent_svn_branch_and_rev(
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
395 parent_branch_rev+1,
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
396 parent_branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
397 if real_num != 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
398 return real_num, branch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
399 return None, None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
400
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
401 def get_parent_revision(self, number, branch):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
402 '''Get the parent revision hash for a commit on a specific branch.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
403 '''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
404 r, br = self.get_parent_svn_branch_and_rev(number, branch)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
405 if r is not None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
406 return self.revmap[r, br]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
407 return revlog.nullid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
408
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
409 def _svnpath(self, branch):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
410 """Return the relative path in svn of branch.
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
411 """
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
412 if branch == None or branch == 'default':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
413 return 'trunk'
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
414 elif branch.startswith('../'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
415 return branch[3:]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
416 return 'branches/%s' % branch
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
417
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
418 def _determine_parent_branch(self, p, src_path, src_rev, revnum):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
419 if src_path is not None:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
420 src_file, src_branch = self._path_and_branch_for_path(src_path)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
421 src_tag = self._is_path_tag(src_path)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
422 if src_tag != False:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
423 # also case 2
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
424 src_branch, src_rev = self.tags[src_tag]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
425 return {self._localname(p): (src_branch, src_rev, revnum )}
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
426 if src_file == '':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
427 # case 2
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
428 return {self._localname(p): (src_branch, src_rev, revnum )}
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
429 return {}
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
430
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
431 def update_branch_tag_map_for_rev(self, revision):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
432 paths = revision.paths
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
433 added_branches = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
434 added_tags = {}
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
435 self.branches_to_delete = set()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
436 tags_to_delete = set()
131
4d42dbbb5127 hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents: 124
diff changeset
437 for p in sorted(paths):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
438 t_name = self._is_path_tag(p)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
439 if t_name != False:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
440 src_p, src_rev = paths[p].copyfrom_path, paths[p].copyfrom_rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
441 # if you commit to a tag, I'm calling you stupid and ignoring
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
442 # you.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
443 if src_p is not None and src_rev is not None:
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
444 file, branch = self._path_and_branch_for_path(src_p)
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
445 if file is None:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
446 # some crazy people make tags from other tags
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
447 file = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
448 from_tag = self._is_path_tag(src_p)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
449 if not from_tag:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
450 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
451 branch, src_rev = self.tags[from_tag]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
452 if t_name not in added_tags:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
453 added_tags[t_name] = branch, src_rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
454 elif file and src_rev > added_tags[t_name][1]:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
455 added_tags[t_name] = branch, src_rev
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
456 elif (paths[p].action == 'D' and p.endswith(t_name)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
457 and t_name in self.tags):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
458 tags_to_delete.add(t_name)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
459 continue
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
460 # At this point we know the path is not a tag. In that
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
461 # case, we only care if it is the root of a new branch (in
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
462 # this function). This is determined by the following
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
463 # checks:
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
464 # 1. Is the file located inside any currently known
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
465 # branch? If yes, then we're done with it, this isn't
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
466 # interesting.
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
467 # 2. Does the file have copyfrom information? If yes, then
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
468 # we're done: this is a new branch, and we record the
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
469 # copyfrom in added_branches if it comes from the root
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
470 # of another branch, or create it from scratch.
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
471 # 3. Neither of the above. This could be a branch, but it
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
472 # might never work out for us. It's only ever a branch
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
473 # (as far as we're concerned) if it gets committed to,
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
474 # which we have to detect at file-write time anyway. So
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
475 # we do nothing here.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
476 # 4. It's the root of an already-known branch, with an
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
477 # action of 'D'. We mark the branch as deleted.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
478 # 5. It's the parent directory of one or more
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
479 # already-known branches, so we mark them as deleted.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
480 # 6. It's a branch being replaced by another branch - the
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
481 # action will be 'R'.
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
482 fi, br = self._path_and_branch_for_path(p)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
483 if fi is not None:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
484 if fi == '':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
485 if paths[p].action == 'D':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
486 self.branches_to_delete.add(br) # case 4
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
487 elif paths[p].action == 'R':
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
488 parent = self._determine_parent_branch(
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
489 p, paths[p].copyfrom_path, paths[p].copyfrom_rev,
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
490 revision.revnum)
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
491 added_branches.update(parent)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
492 continue # case 1
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
493 if paths[p].action == 'D':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
494 for known in self.branches:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
495 if self._svnpath(known).startswith(p):
279
376ba9399ce6 hg_delta_editor: Fix a bug in marking branches as deleted.
Max Bowsher <maxb@f2s.com>
parents: 263
diff changeset
496 self.branches_to_delete.add(known) # case 5
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
497 parent = self._determine_parent_branch(
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
498 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum)
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
499 if not parent and paths[p].copyfrom_path:
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
500 bpath, branch = self._path_and_branch_for_path(p, False)
352
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
501 if (bpath is not None
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
502 and branch not in self.branches
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
503 and branch not in added_branches):
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
504 parent = {branch: (None, 0, revision.revnum)}
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
505 added_branches.update(parent)
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
506 rmtags = dict((t, self.tags[t][0]) for t in tags_to_delete)
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
507 return {
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
508 'tags': (added_tags, rmtags),
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
509 'branches': (added_branches, self.branches_to_delete),
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
510 }
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
511
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
512 def save_tbdelta(self, tbdelta):
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
513 for t in tbdelta['tags'][1]:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
514 del self.tags[t]
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
515 for br in tbdelta['branches'][1]:
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
516 del self.branches[br]
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
517 for t, info in tbdelta['tags'][0].items():
156
56dae5beae65 hg_delta_editor: Produce some output when creating a tag.
Augie Fackler <durin42@gmail.com>
parents: 155
diff changeset
518 self.ui.status('Tagged %s@%s as %s\n' %
56dae5beae65 hg_delta_editor: Produce some output when creating a tag.
Augie Fackler <durin42@gmail.com>
parents: 155
diff changeset
519 (info[0] or 'trunk', info[1], t))
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
520 self.tags.update(tbdelta['tags'][0])
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
521 self.branches.update(tbdelta['branches'][0])
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
522
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
523 def _updateexternals(self):
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
524 if not self.externals:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
525 return
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
526 # Accumulate externals records for all branches
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
527 revnum = self.current_rev.revnum
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
528 branches = {}
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
529 for path, entry in self.externals.iteritems():
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
530 if not self._is_path_valid(path):
224
2165461d2dd8 Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 211
diff changeset
531 self.ui.warn('WARNING: Invalid path %s in externals\n' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
532 continue
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
533 p, b, bp = self._split_branch_path(path)
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
534 if bp not in branches:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
535 external = svnexternals.externalsfile()
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
536 parent = self.get_parent_revision(revnum, b)
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
537 pctx = self.repo[parent]
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
538 if '.hgsvnexternals' in pctx:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
539 external.read(pctx['.hgsvnexternals'].data())
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
540 branches[bp] = external
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
541 else:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
542 external = branches[bp]
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
543 external[p] = entry
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
544
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
545 # Register the file changes
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
546 for bp, external in branches.iteritems():
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
547 path = bp + '/.hgsvnexternals'
176
c4115b3918e9 Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents: 174
diff changeset
548 if external:
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
549 self.set_file(path, external.write(), False, False)
176
c4115b3918e9 Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents: 174
diff changeset
550 else:
c4115b3918e9 Really delete the .hgsvnexternals file when explicitely removed
Patrick Mezard <pmezard@gmail.com>
parents: 174
diff changeset
551 self.delete_file(path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
552
368
e786253eb565 Abstract out a branchedits() function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 367
diff changeset
553 def branchedits(self, branch, rev):
e786253eb565 Abstract out a branchedits() function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 367
diff changeset
554 check = lambda x: x[0][1] == branch and x[0][0] < rev.revnum
e786253eb565 Abstract out a branchedits() function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 367
diff changeset
555 return sorted(filter(check, self.revmap.iteritems()), reverse=True)
e786253eb565 Abstract out a branchedits() function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 367
diff changeset
556
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
557 def committags(self, delta, rev, endbranches):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
558
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
559 date = self.fixdate(rev.date)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
560 # determine additions/deletions per branch
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
561 branches = {}
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
562 for tag, source in delta[0].iteritems():
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
563 b, r = source
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
564 branches.setdefault(b, []).append(('add', tag, r))
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
565 for tag, branch in delta[1].iteritems():
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
566 branches.setdefault(branch, []).append(('rm', tag, None))
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
567
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
568 for b, tags in branches.iteritems():
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
569
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
570 # modify parent's .hgtags source
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
571 parent = self.repo[{None: 'default'}.get(b, b)]
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
572 if '.hgtags' not in parent:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
573 src = ''
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
574 else:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
575 src = parent['.hgtags'].data()
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
576 for op, tag, r in sorted(tags, reverse=True):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
577 if op == 'add':
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
578 tagged = node.hex(self.revmap[r, b])
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
579 elif op == 'rm':
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
580 tagged = node.hex(node.nullid)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
581 src += '%s %s\n' % (tagged, tag)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
582
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
583 # add new changeset containing updated .hgtags
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
584 def fctxfun(repo, memctx, path):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
585 return context.memfilectx(path='.hgtags', data=src,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
586 islink=False, isexec=False,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
587 copied=None)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
588 extra = util.build_extra(rev.revnum, b, self.uuid, self.subdir)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
589 ctx = context.memctx(self.repo,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
590 (parent.node(), node.nullid),
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
591 rev.message or ' ',
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
592 ['.hgtags'],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
593 fctxfun,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
594 self.authors[rev.author],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
595 date,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
596 extra)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
597 new = self.repo.commitctx(ctx)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
598 if (rev.revnum, b) not in self.revmap:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
599 self.add_to_revmap(rev.revnum, b, new)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
600 if b in endbranches:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
601 endbranches[b] = new
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
602
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
603 def commit_current_delta(self, tbdelta):
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
604 if hasattr(self, '_exception_info'): #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
605 traceback.print_exception(*self._exception_info)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
606 raise ReplayException()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
607 if self.missing_plaintexts:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
608 raise MissingPlainTextError()
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
609 self._updateexternals()
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
610 # paranoidly generate the list of files to commit
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
611 files_to_commit = set(self.current_files.keys())
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
612 files_to_commit.update(self.current_files_symlink.keys())
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
613 files_to_commit.update(self.current_files_exec.keys())
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
614 files_to_commit.update(self.deleted_files.keys())
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
615 # back to a list and sort so we get sane behavior
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
616 files_to_commit = list(files_to_commit)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
617 files_to_commit.sort()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
618 branch_batches = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
619 rev = self.current_rev
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
620 date = self.fixdate(rev.date)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
621
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
622 # build up the branches that have files on them
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
623 for f in files_to_commit:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
624 if not self._is_path_valid(f):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
625 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
626 p, b = self._path_and_branch_for_path(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
627 if b not in branch_batches:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
628 branch_batches[b] = []
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
629 branch_batches[b].append((p, f))
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
630
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
631 closebranches = {}
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
632 for branch in tbdelta['branches'][1]:
368
e786253eb565 Abstract out a branchedits() function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 367
diff changeset
633 branchedits = self.branchedits(branch, rev)
147
22162380c4b9 Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents: 146
diff changeset
634 if len(branchedits) < 1:
22162380c4b9 Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents: 146
diff changeset
635 # can't close a branch that never existed
22162380c4b9 Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents: 146
diff changeset
636 continue
22162380c4b9 Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents: 146
diff changeset
637 ha = branchedits[0][1]
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
638 closebranches[branch] = ha
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
639
370
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
640 # 1. handle normal commits
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
641 closedrevs = closebranches.values()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
642 for branch, files in branch_batches.iteritems():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
643 if branch in self.commit_branches_empty and files:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
644 del self.commit_branches_empty[branch]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
645 files = dict(files)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
646
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
647 parents = (self.get_parent_revision(rev.revnum, branch),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
648 revlog.nullid)
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
649 if parents[0] in closedrevs and branch in self.branches_to_delete:
147
22162380c4b9 Improve branch closing in the case of a single-rev replacement of one branch
Augie Fackler <durin42@gmail.com>
parents: 146
diff changeset
650 continue
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
651 extra = util.build_extra(rev.revnum, branch, self.uuid, self.subdir)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
652 if branch is not None:
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
653 if (branch not in self.branches
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
654 and branch not in self.repo.branchtags()):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
655 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
656 parent_ctx = self.repo.changectx(parents[0])
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
657 if '.hgsvnexternals' not in parent_ctx and '.hgsvnexternals' in files:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
658 # Do not register empty externals files
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
659 if (files['.hgsvnexternals'] in self.current_files
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
660 and not self.current_files[files['.hgsvnexternals']]):
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
661 del files['.hgsvnexternals']
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
662
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
663 def filectxfn(repo, memctx, path):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
664 current_file = files[path]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
665 if current_file in self.deleted_files:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
666 raise IOError()
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
667 copied = self.copies.get(current_file)
55
987e44afa71e hg_delta_editor: simplify exec/symlink flags generation
Patrick Mezard <pmezard@gmail.com>
parents: 43
diff changeset
668 flags = parent_ctx.flags(path)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
669 is_exec = self.current_files_exec.get(current_file, 'x' in flags)
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
670 is_link = self.current_files_symlink.get(current_file, 'l' in flags)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
671 if current_file in self.current_files:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
672 data = self.current_files[current_file]
335
9ef720a611e0 HgChangeReceiver: better diagnostics for invalid links
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
673 if is_link and data.startswith('link '):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
674 data = data[len('link '):]
335
9ef720a611e0 HgChangeReceiver: better diagnostics for invalid links
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 331
diff changeset
675 elif is_link:
350
b6f9e270f103 hg_delta_editor: do not raise an error for bad symlinks, but warn instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 347
diff changeset
676 self.ui.warn('file marked as link, but contains data: '
b6f9e270f103 hg_delta_editor: do not raise an error for bad symlinks, but warn instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 347
diff changeset
677 '%s (%r)\n' % (current_file, flags))
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
678 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
679 data = parent_ctx.filectx(path).data()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
680 return context.memfilectx(path=path,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
681 data=data,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
682 islink=is_link, isexec=is_exec,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
683 copied=copied)
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
684 if not self.usebranchnames:
321
b6c6d32c8ef1 Add an option to clone without branch names.
Augie Fackler <durin42@gmail.com>
parents: 317
diff changeset
685 extra.pop('branch', None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
686 current_ctx = context.memctx(self.repo,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
687 parents,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
688 rev.message or '...',
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
689 files.keys(),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
690 filectxfn,
307
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
691 self.authors[rev.author],
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
692 date,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
693 extra)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
694 new_hash = self.repo.commitctx(current_ctx)
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
695 util.describe_commit(self.ui, new_hash, branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
696 if (rev.revnum, branch) not in self.revmap:
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
697 self.add_to_revmap(rev.revnum, branch, new_hash)
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
698
370
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
699 # 2. handle branches that need to be committed without any files
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
700 for branch in self.commit_branches_empty:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
701 ha = self.get_parent_revision(rev.revnum, branch)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
702 if ha == node.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
703 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
704 parent_ctx = self.repo.changectx(ha)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
705 def del_all_files(*args):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
706 raise IOError
369
ce2b7ef74f89 Extract closed_revs into closebranches and closedrevs.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 368
diff changeset
707 # True here meant nuke all files, shouldn't happen with branch closing
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
708 if self.commit_branches_empty[branch]: #pragma: no cover
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
709 raise hgutil.Abort('Empty commit to an open branch attempted. '
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
710 'Please report this issue.')
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
711 extra = util.build_extra(rev.revnum, branch, self.uuid, self.subdir)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
712 if not self.usebranchnames:
321
b6c6d32c8ef1 Add an option to clone without branch names.
Augie Fackler <durin42@gmail.com>
parents: 317
diff changeset
713 extra.pop('branch', None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
714 current_ctx = context.memctx(self.repo,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
715 (ha, node.nullid),
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
716 rev.message or ' ',
136
cf6fe8457570 Fix an apparent regression where branch name didn't get properly stored for
Augie Fackler <durin42@gmail.com>
parents: 133
diff changeset
717 [],
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
718 del_all_files,
307
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
719 self.authors[rev.author],
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
720 date,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
721 extra)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
722 new_hash = self.repo.commitctx(current_ctx)
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
723 util.describe_commit(self.ui, new_hash, branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
724 if (rev.revnum, branch) not in self.revmap:
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
725 self.add_to_revmap(rev.revnum, branch, new_hash)
370
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
726
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
727 # 3. handle tags
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
728 if tbdelta['tags'][0] or tbdelta['tags'][1]:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
729 self.committags(tbdelta['tags'], rev, closebranches)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
730
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
731 # 4. close any branches that need it
370
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
732 for branch in tbdelta['branches'][1]:
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
733 # self.get_parent_revision(rev.revnum, branch)
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
734 ha = closebranches.get(branch)
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
735 if ha is None:
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
736 continue
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 374
diff changeset
737 self.delbranch(branch, ha, rev)
370
c4da18ba92ea Reorder different commit blocks.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 369
diff changeset
738
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
739 self._save_metadata()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
740 self.clear_current_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
741
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 374
diff changeset
742 def delbranch(self, branch, node, rev):
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
743 pctx = self.repo[node]
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
744 def filectxfun(repo, memctx, path):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
745 return pctx[path]
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
746 files = pctx.manifest().keys()
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 374
diff changeset
747 extra = {'close': 1}
374
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
748 if self.usebranchnames:
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 374
diff changeset
749 extra['branch'] = branch or 'default'
374
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
750 ctx = context.memctx(self.repo,
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 374
diff changeset
751 (node, revlog.nullid),
374
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
752 rev.message or util.default_commit_msg,
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
753 files,
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
754 filectxfun,
374
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
755 self.authors[rev.author],
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
756 self.fixdate(rev.date),
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
757 extra)
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
758 new = self.repo.commitctx(ctx)
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
759 self.ui.status('Marked branch %s as closed.\n' % (branch or 'default'))
758d9dbae9f9 Extract branch closing from stupid/editor into separate function.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 370
diff changeset
760
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
761 def readfilemap(self, filemapfile):
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
762 self.ui.note(
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
763 ('Reading file map from %s\n')
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
764 % filemapfile)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
765 def addpathtomap(path, mapping, mapname):
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
766 if path in mapping:
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
767 self.ui.warn(('Duplicate %s entry in %s: "%d"\n') %
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
768 (mapname, filemapfile, path))
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
769 else:
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
770 self.ui.debug(('%sing %s\n') %
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
771 (mapname.capitalize().strip('e'), path))
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
772 mapping[path] = path
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
773
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
774 f = open(filemapfile, 'r')
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
775 for line in f:
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
776 if line.strip() == '' or line.strip()[0] == '#':
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
777 continue
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
778 try:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
779 cmd, path = line.split(' ', 1)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
780 cmd = cmd.strip()
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
781 path = path.strip()
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
782 if cmd == 'include':
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
783 addpathtomap(path, self.includepaths, 'include')
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
784 elif cmd == 'exclude':
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
785 addpathtomap(path, self.excludepaths, 'exclude')
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
786 else:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
787 self.ui.warn(
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
788 ('Unknown filemap command %s\n')
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
789 % cmd)
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
790 except IndexError:
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
791 self.ui.warn(
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
792 ('Ignoring bad line in filemap %s: %s\n')
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
793 % (filemapfile, line.rstrip()))
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
794 f.close()
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
795
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
796 def meta_data_dir(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
797 return os.path.join(self.path, '.hg', 'svn')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
798 meta_data_dir = property(meta_data_dir)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
799
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
800 def meta_file_named(self, name):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
801 return os.path.join(self.meta_data_dir, name)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
802
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
803 def revmap_file(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
804 return self.meta_file_named('rev_map')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
805 revmap_file = property(revmap_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
806
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
807 def _get_uuid(self):
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
808 return open(self.meta_file_named('uuid')).read()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
809
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
810 def _set_uuid(self, uuid):
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
811 if not uuid:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
812 return self._get_uuid()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
813 elif os.path.isfile(self.meta_file_named('uuid')):
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
814 stored_uuid = self._get_uuid()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
815 assert stored_uuid
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
816 if uuid != stored_uuid:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
817 raise hgutil.Abort('unable to operate on unrelated repository')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
818 else:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
819 return stored_uuid
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
820 else:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
821 if uuid:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
822 f = open(self.meta_file_named('uuid'), 'w')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
823 f.write(uuid)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
824 f.flush()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
825 f.close()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
826 return self._get_uuid()
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
827 else:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
828 raise hgutil.Abort('unable to operate on unrelated repository')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
829
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
830 uuid = property(_get_uuid, _set_uuid, None,
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
831 'Error-checked UUID of source Subversion repository.')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
832
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
833 def branch_info_file(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
834 return self.meta_file_named('branch_info')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
835 branch_info_file = property(branch_info_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
836
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
837 def tag_info_file(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
838 return self.meta_file_named('tag_info')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
839 tag_info_file = property(tag_info_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
840
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
841 def tag_locations_file(self):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
842 return self.meta_file_named('tag_locations')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
843 tag_locations_file = property(tag_locations_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
844
167
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 164
diff changeset
845 def authors_file(self):
3cd6a7354207 fetch: Add support for an authormap which can rename authors, intended for
Graham Booker <gbooker@cod3r.com>
parents: 164
diff changeset
846 return self.meta_file_named('authors')
181
e37f9d3fd5e7 remove decorators (compat with python2.3)
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 179
diff changeset
847 authors_file = property(authors_file)
168
4f26fa049452 authormap: Add tests, fix in stupid mode.
Augie Fackler <durin42@gmail.com>
parents: 167
diff changeset
848
364
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
849 def aresamefiles(self, parentctx, childctx, files):
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
850 """Assuming all files exist in childctx and parentctx, return True
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
851 if none of them was changed in-between.
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
852 """
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
853 if parentctx == childctx:
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
854 return True
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
855 if parentctx.rev() > childctx.rev():
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
856 parentctx, childctx = childctx, parentctx
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
857
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
858 def selfandancestors(selfctx):
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
859 yield selfctx
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
860 for ctx in selfctx.ancestors():
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
861 yield ctx
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
862
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
863 files = dict.fromkeys(files)
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
864 for pctx in selfandancestors(childctx):
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
865 if pctx.rev() <= parentctx.rev():
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
866 return True
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
867 for f in pctx.files():
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
868 if f in files:
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
869 return False
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
870 # parentctx is not an ancestor of childctx, files are unrelated
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
871 return False
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
872
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
873 # Here come all the actual editor methods
b71c8f935740 Move HgChangeReceiver.aresamefiles() to before the editor methods.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 363
diff changeset
874
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
875 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
876 def delete_entry(self, path, revision_bogus, parent_baton, pool=None):
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
877 br_path, branch = self._path_and_branch_for_path(path)
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
878 if br_path == '':
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
879 self.branches_to_delete.add(branch)
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
880 if br_path is not None:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
881 ha = self.get_parent_revision(self.current_rev.revnum, branch)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
882 if ha == revlog.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
883 return
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
884 ctx = self.repo.changectx(ha)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
885 if br_path not in ctx:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
886 br_path2 = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
887 if br_path != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
888 br_path2 = br_path + '/'
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
889 # assuming it is a directory
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
890 self.externals[path] = None
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
891 map(self.delete_file, [pat for pat in self.current_files.iterkeys()
232
c0063328587f Fix and test for directory deletes during branch creation.
Augie Fackler <durin42@gmail.com>
parents: 228
diff changeset
892 if pat.startswith(path+'/')])
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
893 for f in ctx.walk(util.PrefixMatch(br_path2)):
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 38
diff changeset
894 f_p = '%s/%s' % (path, f[len(br_path2):])
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 38
diff changeset
895 if f_p not in self.current_files:
145
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
896 self.delete_file(f_p)
b37c401b7f92 hg_delta_editor: reset properties of deleted entries
Patrick Mezard <pmezard@gmail.com>
parents: 141
diff changeset
897 self.delete_file(path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
898
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
899 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
900 def open_file(self, path, parent_baton, base_revision, p=None):
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
901 self.current_file = None
119
ea65fe2b0856 hg_delta_editor: fix update of stray files in branches/
Patrick Mezard <pmezard@gmail.com>
parents: 116
diff changeset
902 fpath, branch = self._path_and_branch_for_path(path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
903 if not fpath:
322
05cd4a5138bf Move some .warn() calls to noisy levels instead.
Augie Fackler <durin42@gmail.com>
parents: 321
diff changeset
904 self.ui.debug('WARNING: Opening non-existant file %s\n' % path)
378
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
905 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
906
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
907 self.current_file = path
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
908 self.ui.note('M %s\n' % path)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
909 if base_revision != -1:
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
910 self.base_revision = base_revision
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
911 else:
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
912 self.base_revision = None
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
913
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
914 if self.current_file in self.current_files:
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
915 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
916
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
917 baserev = base_revision
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
918 if baserev is None or baserev == -1:
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
919 baserev = self.current_rev.revnum - 1
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
920 parent = self.get_parent_revision(baserev + 1, branch)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
921
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
922 ctx = self.repo[parent]
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
923 if not self._is_path_valid(path):
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
924 return
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
925
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
926 if fpath not in ctx:
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
927 self.missing_plaintexts.add(svnpath)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
928
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
929 fctx = ctx.filectx(fpath)
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
930 base = fctx.data()
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
931 if 'l' in fctx.flags():
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
932 base = 'link ' + base
eeefbe104087 Inline HgChangeReceiver.load_base_from_ctx().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 377
diff changeset
933 self.set_file(path, base, 'x' in fctx.flags(), 'l' in fctx.flags())
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
934
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
935 @ieditor
300
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
936 def add_file(self, path, parent_baton=None, copyfrom_path=None,
4aba7542f6a9 Various cleanups, cosmetics and removal of superfluous assertions.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 299
diff changeset
937 copyfrom_revision=None, file_pool=None):
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
938 self.current_file = None
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
939 self.base_revision = None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
940 if path in self.deleted_files:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
941 del self.deleted_files[path]
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
942 fpath, branch = self._path_and_branch_for_path(path, existing=False)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
943 if not fpath:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
944 return
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
945 if branch not in self.branches:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
946 # we know this branch will exist now, because it has at least one file. Rock.
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
947 self.branches[branch] = None, 0, self.current_rev.revnum
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
948 self.current_file = path
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
949 if not copyfrom_path:
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
950 self.ui.note('A %s\n' % path)
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
951 self.set_file(path, '', False, False)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
952 return
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 181
diff changeset
953 self.ui.note('A+ %s\n' % path)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
954 (from_file,
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
955 from_branch) = self._path_and_branch_for_path(copyfrom_path)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
956 if not from_file:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
957 self.missing_plaintexts.add(path)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
958 return
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
959 ha = self.get_parent_revision(copyfrom_revision + 1,
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
960 from_branch)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
961 ctx = self.repo.changectx(ha)
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
962 if from_file in ctx:
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
963 fctx = ctx.filectx(from_file)
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
964 flags = fctx.flags()
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
965 self.set_file(path, fctx.data(), 'x' in flags, 'l' in flags)
67
e319c9168910 hg_delta_editor: register svn file copies
Patrick Mezard <pmezard@gmail.com>
parents: 59
diff changeset
966 if from_branch == branch:
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
967 parentid = self.get_parent_revision(self.current_rev.revnum,
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
968 branch)
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
969 if parentid != revlog.nullid:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
970 parentctx = self.repo.changectx(parentid)
73
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 72
diff changeset
971 if self.aresamefiles(parentctx, ctx, [from_file]):
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
972 self.copies[path] = from_file
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
973
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
974 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
975 def add_directory(self, path, parent_baton, copyfrom_path,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
976 copyfrom_revision, dir_pool=None):
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
977 self.dir_batons[path] = path
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
978 br_path, branch = self._path_and_branch_for_path(path)
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
979 if br_path is not None:
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
980 if not copyfrom_path and not br_path:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
981 self.commit_branches_empty[branch] = True
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
982 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
983 self.commit_branches_empty[branch] = False
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
984 if br_path is None or not copyfrom_path:
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
985 return path
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
986 if copyfrom_path:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
987 tag = self._is_path_tag(copyfrom_path)
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
988 if tag not in self.tags:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
989 tag = None
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
990 if not self._is_path_valid(copyfrom_path) and not tag:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
991 self.missing_plaintexts.add('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
992 return path
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
993 if tag:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
994 source_branch, source_rev = self.tags[tag]
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
995 cp_f = ''
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
996 else:
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
997 source_rev = copyfrom_revision
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
998 cp_f, source_branch = self._path_and_branch_for_path(copyfrom_path)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
999 if cp_f == '' and br_path == '':
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
1000 assert br_path is not None
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
1001 self.branches[branch] = source_branch, source_rev, self.current_rev.revnum
59
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
1002 new_hash = self.get_parent_revision(source_rev + 1,
430af23bef4a Performance fix for branches-from-tags in real replay, which is tied up with
Augie Fackler <durin42@gmail.com>
parents: 55
diff changeset
1003 source_branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1004 if new_hash == node.nullid:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1005 self.missing_plaintexts.add('%s/' % path)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1006 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1007 cp_f_ctx = self.repo.changectx(new_hash)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1008 if cp_f != '/' and cp_f != '':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1009 cp_f = '%s/' % cp_f
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1010 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1011 cp_f = ''
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1012 copies = {}
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1013 for f in cp_f_ctx:
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1014 if not f.startswith(cp_f):
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1015 continue
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1016 f2 = f[len(cp_f):]
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1017 fctx = cp_f_ctx.filectx(f)
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1018 fp_c = path + '/' + f2
97
0d3a2a7cefa3 hg_delta_editor: fix symlink prefix confusion
Patrick Mezard <pmezard@gmail.com>
parents: 73
diff changeset
1019 self.set_file(fp_c, fctx.data(), 'x' in fctx.flags(), 'l' in fctx.flags())
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1020 if fp_c in self.deleted_files:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1021 del self.deleted_files[fp_c]
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1022 if branch == source_branch:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1023 copies[fp_c] = f
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1024 if copies:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1025 # Preserve the directory copy records if no file was changed between
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1026 # the source and destination revisions, or discard it completely.
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1027 parentid = self.get_parent_revision(self.current_rev.revnum, branch)
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1028 if parentid != revlog.nullid:
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1029 parentctx = self.repo.changectx(parentid)
73
9c1b53abefcb fetch_command: support svn copy detection in stupid mode
Patrick Mezard <pmezard@gmail.com>
parents: 72
diff changeset
1030 if self.aresamefiles(parentctx, cp_f_ctx, copies.values()):
69
63ece4ea25c9 hg_delta_editor: register copies only if files are unchanged between source and dest
Patrick Mezard <pmezard@gmail.com>
parents: 67
diff changeset
1031 self.copies.update(copies)
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1032 return path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1033
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
1034 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1035 def change_file_prop(self, file_baton, name, value, pool=None):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1036 if name == 'svn:executable':
111
5497d1264b4d fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents: 97
diff changeset
1037 self.current_files_exec[self.current_file] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1038 elif name == 'svn:special':
111
5497d1264b4d fetch_command: Fix mis-converted executable when svn:executable was set to the
Augie Fackler <durin42@gmail.com>
parents: 97
diff changeset
1039 self.current_files_symlink[self.current_file] = bool(value is not None)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1040
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
1041 @ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1042 def change_dir_prop(self, dir_baton, name, value, pool=None):
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1043 if dir_baton is None:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1044 return
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1045 path = self.dir_batons[dir_baton]
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1046 if name == 'svn:externals':
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1047 self.externals[path] = value
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1048
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
1049 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1050 def open_directory(self, path, parent_baton, base_revision, dir_pool=None):
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1051 self.dir_batons[path] = path
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
1052 p_, branch = self._path_and_branch_for_path(path)
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
1053 if p_ == '':
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
1054 self.commit_branches_empty[branch] = False
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1055 return path
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1056
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
1057 @ieditor
174
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1058 def close_directory(self, dir_baton, dir_pool=None):
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1059 if dir_baton is not None:
f80132c5fea5 Convert svn:externals properties into a .hgsvnexternals file
Patrick Mezard <pmezard@gmail.com>
parents: 168
diff changeset
1060 del self.dir_batons[dir_baton]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1061
362
705f33c0a323 Replace stash_exception_on_self() by @ieditor.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 352
diff changeset
1062 @ieditor
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1063 def apply_textdelta(self, file_baton, base_checksum, pool=None):
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1064 # We know coming in here the file must be one of the following options:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1065 # 1) Deleted (invalid, fail an assertion)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1066 # 2) Missing a base text (bail quick since we have to fetch a full plaintext)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1067 # 3) Has a base text in self.current_files, apply deltas
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1068 base = ''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1069 if not self._is_path_valid(self.current_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1070 return lambda x: None
211
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1071 assert self.current_file not in self.deleted_files, (
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1072 'Cannot apply_textdelta to a deleted file: %s' % self.current_file)
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1073 assert (self.current_file in self.current_files
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1074 or self.current_file in self.missing_plaintexts), '%s not found' % self.current_file
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1075 if self.current_file in self.missing_plaintexts:
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1076 return lambda x: None
05243ec295e1 fetch: Fix a bug that caused plaintexts to be interpreted as missing more often than they should be.
Augie Fackler <durin42@gmail.com>
parents: 207
diff changeset
1077 base = self.current_files[self.current_file]
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1078 source = cStringIO.StringIO(base)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1079 target = cStringIO.StringIO()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1080 self.stream = target
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1081
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1082 handler, baton = delta.svn_txdelta_apply(source, target, None)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
1083 if not callable(handler): #pragma: no cover
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
1084 raise hgutil.Abort('Error in Subversion bindings: '
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
1085 'cannot call handler!')
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1086 def txdelt_window(window):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1087 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1088 if not self._is_path_valid(self.current_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1089 return
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1090 handler(window, baton)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1091 # window being None means commit this file
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1092 if not window:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1093 self.current_files[self.current_file] = target.getvalue()
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
1094 except core.SubversionException, e: #pragma: no cover
224
2165461d2dd8 Exception clean-ups; use symbolic names & avoid Python 2.6 deprecations.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 211
diff changeset
1095 if e.apr_err == core.SVN_ERR_INCOMPLETE_DATA:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1096 self.missing_plaintexts.add(self.current_file)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
1097 else: #pragma: no cover
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
1098 raise hgutil.Abort(*e.args)
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
1099 except: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1100 print len(base), self.current_file
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1101 self._exception_info = sys.exc_info()
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1102 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1103 return txdelt_window