annotate hgsubversion/svnmeta.py @ 1450:3c4fbf59e503

svnmeta: do not add instance references to the class object This is part of a bigger plan to prevent a fd leak by making sure the sqlite connection object is garbage collected. Usually this is not a very serious issue but the testing framework will run all tests in a single process by default. The fd leak will make tests fail on systems with a low RLIMIT_NOFILE. Previously, when we are adding new properties to the SVNMeta class, we bind the current instance in the closure, which essentially prevents any SVNMeta instances from being garbage collected (and its state like revmap). This patch changed "self" from the closure one to the lambda argument to address the issue.
author Jun Wu <quark@fb.com>
date Fri, 27 May 2016 01:42:55 +0100
parents 6463dae16c33
children 32166f557518
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
551
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
1 import posixpath
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import tempfile
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
4
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
5 from mercurial import context
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
6 from mercurial import util as hgutil
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 from mercurial import revlog
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 from mercurial import node
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9
1219
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
10 import compathacks
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
11 import util
317
5dc8fee7fc96 Less import *
Augie Fackler <durin42@gmail.com>
parents: 316
diff changeset
12 import maps
1005
5bba4d1becde layouts: refactor layout loading based on config into function
David Schleimer <dschleimer@fb.com>
parents: 986
diff changeset
13 import layouts
421
8277113036f1 editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 420
diff changeset
14 import editor
1299
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
15 import svnwrap
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
16
363
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
17
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
18 class SVNMeta(object):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
19
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
20 def __init__(self, repo, uuid=None, subdir=None, skiperrorcheck=False):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 """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
22
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 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
24 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
25 """
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
26 # simple and public variables
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
27 self.ui = repo.ui
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
28 self.repo = repo
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
29 self.path = os.path.normpath(repo.join('..'))
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
30 self.lastdate = '1970-01-01 00:00:00 -0000'
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
31 self.addedtags = {}
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
32 self.deletedtags = {}
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
33
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
34 # private variables
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
35 self._skiperror = skiperrorcheck
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
36 self._tags = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
37 self._layoutobj = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
38 self._revmap = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
39 self._authors = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
40 self._branchmap = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
41 self._tagmap = None
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
42 self._filemap = None
1301
9e46dfddd3a9 svnmeta: turn layout into a cached property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1299
diff changeset
43 self._layout = None
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
44
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
45 # create .hg/svn folder if it doesn't exist
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
46 if not os.path.isdir(self.metapath):
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
47 os.makedirs(self.metapath)
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
48
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
49 # properties that need .hg/svn to exist
745
6252f0cc7b7a svnmeta: cache the UUID in an attribute.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 742
diff changeset
50 self.uuid = uuid
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
51 self.subdir = subdir
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
52
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
53 # generated properties that have a persistent file stored on disk
1189
0ef719f4c371 svnmeta: add defaultauthors property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1187
diff changeset
54 self._gen_cachedconfig('defaultauthors', True)
1190
5df842451d7e svnmeta: add caseignoreauthors property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1189
diff changeset
55 self._gen_cachedconfig('caseignoreauthors', False)
1374
a17d8874a099 Added dynamic author mapping.
Jerome M. BERGER <jeberger@free.fr>
parents: 1355
diff changeset
56 self._gen_cachedconfig('mapauthorscmd', None)
1191
f0d5c03a71b9 svnmeta: add defaulthost property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1190
diff changeset
57 self._gen_cachedconfig('defaulthost', self.uuid)
1192
23a845fbfc6a svnmeta: use generator for usebranchnames property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1191
diff changeset
58 self._gen_cachedconfig('usebranchnames', True)
1282
5aecb986a5a0 svnmeta: generate cached defaultmessage property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1281
diff changeset
59 self._gen_cachedconfig('defaultmessage', '')
1296
631a572658c2 svnmeta: add generated cached branch property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
60 self._gen_cachedconfig('branch', '')
1301
9e46dfddd3a9 svnmeta: turn layout into a cached property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1299
diff changeset
61 self._gen_cachedconfig('layout', 'auto')
1184
43384d2782dc svnmeta: move revmap.youngest to meta.lastpulled
Sean Farley <sean.michael.farley@gmail.com>
parents: 1183
diff changeset
62
1259
b7b0ed1e1455 svnmeta: reorder code in __init__ for easier reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1228
diff changeset
63 # misc
1130
ed4804ee68c4 svnmeta: use util.load instead of bare pickle
Sean Farley <sean.michael.farley@gmail.com>
parents: 1127
diff changeset
64 self.branches = util.load(self.branch_info_file) or {}
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
65 self.prevbranches = dict(self.branches)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66
1267
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
67 def _get_cachedconfig(self, name, filename, configname, default, pre):
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
68 """Return a cached value for a config option. If the cache is uninitialized
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
69 then try to read its value from disk. Option can be overridden by the
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
70 commandline.
1434
0a6b3da6d34c RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents: 1429
diff changeset
71 name: property name, e.g. 'defaultauthors'
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
72 filename: name of file in .hg/svn
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
73 configname: commandline option name
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
74 default: default value
1267
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
75 pre: transformation to apply to a value before caching it.
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
76 """
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
77 varname = '_' + name
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
78 if getattr(self, varname) is None:
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
79 # construct the file path from metapath (e.g. .hg/svn) plus the
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
80 # filename
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
81 f = os.path.join(self.metapath, filename)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
82
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
83 # load the config property (i.e. command-line or .hgrc)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
84 c = None
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
85 if configname:
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
86 # a little awkward but we need to convert the option from a
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
87 # string to whatever type the default value is, so we use the
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
88 # type of `default` to determine with ui.config method to call
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
89 c = None
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
90 if isinstance(default, bool):
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
91 c = self.ui.configbool('hgsubversion', configname, default)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
92 elif isinstance(default, int):
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
93 c = self.ui.configint('hgsubversion', configname, default)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
94 elif isinstance(default, list):
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
95 c = self.ui.configlist('hgsubversion', configname, default)
1327
72fe317a7b94 svnmeta: add functionality for configitems in _get_cachedconfig
Sean Farley <sean.michael.farley@gmail.com>
parents: 1318
diff changeset
96 elif isinstance(default, dict):
72fe317a7b94 svnmeta: add functionality for configitems in _get_cachedconfig
Sean Farley <sean.michael.farley@gmail.com>
parents: 1318
diff changeset
97 c = dict(self.ui.configitems(configname))
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
98 else:
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
99 c = self.ui.config('hgsubversion', configname, default)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
100
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
101 # load the value from disk
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
102 val = util.load(f, default=default)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
103
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
104 # prefer the non-default, and the one sent from command-line
1197
1414cdafa7af svnmeta: explicitly test for None
Sean Farley <sean.michael.farley@gmail.com>
parents: 1194
diff changeset
105 if c is not None and c != val and c != default:
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
106 val = c
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
107
1267
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
108 # apply transformation if necessary
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
109 if pre:
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
110 val = pre(val)
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
111
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
112 # set the value as the one from disk (or default if not found)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
113 setattr(self, varname, val)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
114
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
115 # save the value to disk by using the setter property
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
116 setattr(self, name, val)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
117
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
118 return getattr(self, varname)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
119
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
120 def _set_cachedconfig(self, value, name, filename):
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
121 varname = '_' + name
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
122 f = os.path.join(self.metapath, filename)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
123 setattr(self, varname, value)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
124 util.dump(value, f)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
125
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
126 def _gen_cachedconfig(self, name, default=None, filename=None,
1267
5f86e2ac7659 svnmeta: add pre-transformation parameter to cached generator
Sean Farley <sean.michael.farley@gmail.com>
parents: 1265
diff changeset
127 configname=None, pre=None):
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
128 """Generate an attribute for reading (and caching) config data.
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
129
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
130 This method constructs a new attribute on self with the given name.
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
131 The actual value from the config file will be read lazily, and then
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
132 cached once that read has occurred. No cache invalidation will happen,
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
133 so within a session these values shouldn't be required to mutate.
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
134 """
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
135 setattr(SVNMeta, '_' + name, None)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
136 if filename is None:
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
137 filename = name
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
138 if configname is None:
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
139 configname = name
1450
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
140 prop = property(lambda x: x._get_cachedconfig(name,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
141 filename,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
142 configname,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
143 default,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
144 pre=pre),
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
145 lambda x, y: x._set_cachedconfig(y,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
146 name,
3c4fbf59e503 svnmeta: do not add instance references to the class object
Jun Wu <quark@fb.com>
parents: 1449
diff changeset
147 filename))
1181
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
148 setattr(SVNMeta, name, prop)
eb4c7bc23f9e svnmeta: add generator for cached svn configuration properties
Sean Farley <sean.michael.farley@gmail.com>
parents: 1161
diff changeset
149
1299
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
150 def layout_from_subversion(self, svn, revision=None):
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
151 """ Guess what layout to use based on directories under the svn root.
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
152
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
153 This is intended for use during bootstrapping. It guesses which
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
154 layout to use based on the presence or absence of the conventional
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
155 trunk, branches, tags dirs immediately under the path your are
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
156 cloning.
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
157
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
158 Additionally, this will write the layout in use to the ui object
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
159 passed, if any.
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
160
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
161 """
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
162
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
163 try:
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
164 rootlist = svn.list_dir('', revision=revision)
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
165 except svnwrap.SubversionException, e:
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
166 err = "%s (subversion error: %d)" % (e.args[0], e.args[1])
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
167 raise hgutil.Abort(err)
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
168 if sum(map(lambda x: x in rootlist, ('branches', 'tags', 'trunk'))):
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
169 layout = 'standard'
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
170 else:
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
171 layout = 'single'
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
172 self.ui.setconfig('hgsubversion', 'layout', layout)
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
173 return layout
8b3b456afd5f svnmeta: copy layout_from_subversion from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1298
diff changeset
174
1298
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
175 def layout_from_commit(self, subdir, revpath, branch):
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
176 """ Guess what the layout is based existing commit info
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
177
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
178 Specifically, this compares the subdir for the repository and the
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
179 revpath as extracted from the convinfo in the commit. If they
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
180 match, the layout is assumed to be single. Otherwise, it tries
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
181 the available layouts and selects the first one that would
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
182 translate the given branch to the given revpath.
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
183
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
184 """
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
185
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
186 subdir = subdir or '/'
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
187 if subdir == revpath:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
188 return 'single'
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
189
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
190 candidates = set()
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
191 for layout in layouts.NAME_TO_CLASS:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
192 layoutobj = layouts.layout_from_name(layout, self)
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
193 try:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
194 remotepath = layoutobj.remotepath(branch, subdir)
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
195 except KeyError:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
196 continue
1318
f1b8029cf8e9 svnmeta: pep8
Sean Farley <sean.michael.farley@gmail.com>
parents: 1314
diff changeset
197 if remotepath == revpath:
1298
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
198 candidates.add(layout)
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
199
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
200 if len(candidates) == 1:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
201 return candidates.pop()
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
202 elif candidates:
1314
577054dbd9af svnmeta: use self.layout instead of calling ui.config directly
Sean Farley <sean.michael.farley@gmail.com>
parents: 1312
diff changeset
203 config_layout = self.layout
1298
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
204 if config_layout in candidates:
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
205 return config_layout
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
206
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
207 return 'standard'
4ba1481484e6 svnmeta: copy layout_from_commit from detect
Sean Farley <sean.michael.farley@gmail.com>
parents: 1296
diff changeset
208
1261
51f88d3aa4dd svnmeta: add a layout_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1259
diff changeset
209 @property
51f88d3aa4dd svnmeta: add a layout_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1259
diff changeset
210 def layout_file(self):
51f88d3aa4dd svnmeta: add a layout_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1259
diff changeset
211 return os.path.join(self.metapath, 'layout')
51f88d3aa4dd svnmeta: add a layout_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1259
diff changeset
212
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
213 @property
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
214 def layoutobj(self):
1312
80b57ed92544 svnmeta: create a new layoutobj if layout has changed
Sean Farley <sean.michael.farley@gmail.com>
parents: 1301
diff changeset
215 # if self.layout has changed, we need to create a new layoutobj
80b57ed92544 svnmeta: create a new layoutobj if layout has changed
Sean Farley <sean.michael.farley@gmail.com>
parents: 1301
diff changeset
216 if not self._layoutobj or self._layoutobj.name != self.layout:
1265
4744b7bfa476 layouts: change constructor to take a meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1263
diff changeset
217 self._layoutobj = layouts.layout_from_name(self.layout, self)
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
218 return self._layoutobj
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
219
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
220 @property
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
221 def editor(self):
1404
c79fdd5f615d cleanup: stop using hasattr
Augie Fackler <raf@durin42.com>
parents: 1374
diff changeset
222 if not hgutil.safehasattr(self, '_editor'):
421
8277113036f1 editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 420
diff changeset
223 self._editor = editor.HgEditor(self)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
224 return self._editor
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
225
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
226 def _get_subdir(self):
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
227 return self.__subdir
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
228
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
229 def _set_subdir(self, subdir):
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
230 if subdir:
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
231 subdir = '/'.join(p for p in subdir.split('/') if p)
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
232
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
233 self.__subdir = None
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
234 subdirfile = os.path.join(self.metapath, 'subdir')
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
235
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
236 if os.path.isfile(subdirfile):
1152
aa98fdccaa0e subdir: use util.dump and util.load for writing and reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1150
diff changeset
237 stored_subdir = util.load(subdirfile)
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
238 assert stored_subdir is not None
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
239 if subdir is None:
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
240 self.__subdir = stored_subdir
1152
aa98fdccaa0e subdir: use util.dump and util.load for writing and reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1150
diff changeset
241 elif subdir and subdir != stored_subdir:
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
242 raise hgutil.Abort('unable to work on a different path in the '
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
243 'repository')
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
244 else:
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
245 self.__subdir = subdir
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
246 elif subdir is not None:
1152
aa98fdccaa0e subdir: use util.dump and util.load for writing and reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1150
diff changeset
247 util.dump(subdir, subdirfile)
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
248 self.__subdir = subdir
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
249 elif not self._skiperror:
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
250 raise hgutil.Abort("hgsubversion metadata unavailable; "
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
251 "please run 'hg svn rebuildmeta'")
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
252
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
253 subdir = property(_get_subdir, _set_subdir, None,
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
254 'Error-checked sub-directory of source Subversion '
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
255 'repository.')
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 747
diff changeset
256
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
257 def _get_uuid(self):
747
34b25f6bc4ef svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 746
diff changeset
258 return self.__uuid
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
259
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
260 def _set_uuid(self, uuid):
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
261 self.__uuid = None
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
262 uuidfile = os.path.join(self.metapath, 'uuid')
747
34b25f6bc4ef svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 746
diff changeset
263 if os.path.isfile(uuidfile):
1150
510fa46caf9c uuid: use util.dump and util.load for writing and reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1130
diff changeset
264 stored_uuid = util.load(uuidfile)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
265 assert stored_uuid
746
174f03c288d4 svnmeta: abort when no UUID given and none is stored on disk.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 745
diff changeset
266 if uuid and uuid != stored_uuid:
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
267 raise hgutil.Abort('unable to operate on unrelated repository')
747
34b25f6bc4ef svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 746
diff changeset
268 self.__uuid = uuid or stored_uuid
746
174f03c288d4 svnmeta: abort when no UUID given and none is stored on disk.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 745
diff changeset
269 elif uuid:
1150
510fa46caf9c uuid: use util.dump and util.load for writing and reading
Sean Farley <sean.michael.farley@gmail.com>
parents: 1130
diff changeset
270 util.dump(uuid, uuidfile)
746
174f03c288d4 svnmeta: abort when no UUID given and none is stored on disk.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 745
diff changeset
271 self.__uuid = uuid
1154
24edef55e61b svnmeta: relax error checking with a parameter
Sean Farley <sean.michael.farley@gmail.com>
parents: 1153
diff changeset
272 elif not self._skiperror:
746
174f03c288d4 svnmeta: abort when no UUID given and none is stored on disk.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 745
diff changeset
273 raise hgutil.Abort("hgsubversion metadata unavailable; "
174f03c288d4 svnmeta: abort when no UUID given and none is stored on disk.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 745
diff changeset
274 "please run 'hg svn rebuildmeta'")
745
6252f0cc7b7a svnmeta: cache the UUID in an attribute.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 742
diff changeset
275
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
276 uuid = property(_get_uuid, _set_uuid, None,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
277 'Error-checked UUID of source Subversion repository.')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
278
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
279 @property
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
280 def metapath(self):
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
281 return os.path.join(self.path, '.hg', 'svn')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
282
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
283 @property
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
284 def branch_info_file(self):
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
285 return os.path.join(self.metapath, 'branch_info')
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
286
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
287 @property
1332
ecce8aef4b21 svnmeta: rename authors_file to authormap_file
Sean Farley <sean.michael.farley@gmail.com>
parents: 1327
diff changeset
288 def authormap_file(self):
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
289 return os.path.join(self.metapath, 'authors')
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
290
1207
9fc3557ce85e svnmeta: turn authors into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1199
diff changeset
291 @property
9fc3557ce85e svnmeta: turn authors into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1199
diff changeset
292 def authors(self):
9fc3557ce85e svnmeta: turn authors into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1199
diff changeset
293 if self._authors is None:
1429
3a723188051e AuthorMap: make local implementation concerns stop using self.meta
Augie Fackler <raf@durin42.com>
parents: 1423
diff changeset
294 self._authors = maps.AuthorMap(
1442
a0ba38def79b AuthorMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1434
diff changeset
295 self.ui, self.authormap_file, self.defaulthost,
a0ba38def79b AuthorMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1434
diff changeset
296 self.caseignoreauthors, self.mapauthorscmd, self.defaultauthors)
1207
9fc3557ce85e svnmeta: turn authors into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1199
diff changeset
297 return self._authors
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
298
846
7ca3d1b08d67 Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents: 837
diff changeset
299 @property
7ca3d1b08d67 Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents: 837
diff changeset
300 def filemap_file(self):
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
301 return os.path.join(self.metapath, 'filemap')
846
7ca3d1b08d67 Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents: 837
diff changeset
302
1216
572417ad0313 svnmeta: turn filemap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1214
diff changeset
303 @property
572417ad0313 svnmeta: turn filemap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1214
diff changeset
304 def filemap(self):
572417ad0313 svnmeta: turn filemap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1214
diff changeset
305 if self._filemap is None:
1447
a6fa4f3aa826 FileMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1446
diff changeset
306 self._filemap = maps.FileMap(self.ui, self.filemap_file)
1216
572417ad0313 svnmeta: turn filemap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1214
diff changeset
307 return self._filemap
572417ad0313 svnmeta: turn filemap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1214
diff changeset
308
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
309 @property
1161
8693c9558f1a svnmeta: unify variable names cleanup
Sean Farley <sean.michael.farley@gmail.com>
parents: 1160
diff changeset
310 def branchmap_file(self):
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
311 return os.path.join(self.metapath, 'branchmap')
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
312
1212
0ca7f80d0ab6 svnmeta: turn branchmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1211
diff changeset
313 @property
0ca7f80d0ab6 svnmeta: turn branchmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1211
diff changeset
314 def branchmap(self):
0ca7f80d0ab6 svnmeta: turn branchmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1211
diff changeset
315 if self._branchmap is None:
1443
887430c1b8ab BranchMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1442
diff changeset
316 self._branchmap = maps.BranchMap(self.ui, self.branchmap_file)
1212
0ca7f80d0ab6 svnmeta: turn branchmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1211
diff changeset
317 return self._branchmap
846
7ca3d1b08d67 Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents: 837
diff changeset
318
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
319 @property
1158
770ac6de58c5 svnmeta: add tagfile property for use with the Tags object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1157
diff changeset
320 def tagfile(self):
770ac6de58c5 svnmeta: add tagfile property for use with the Tags object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1157
diff changeset
321 # called tagmap for backwards compatibility
770ac6de58c5 svnmeta: add tagfile property for use with the Tags object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1157
diff changeset
322 return os.path.join(self.metapath, 'tagmap')
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
323
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
324 @property
1160
f06bb42bd2b2 svnmeta: turn tags into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1158
diff changeset
325 def tags(self):
f06bb42bd2b2 svnmeta: turn tags into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1158
diff changeset
326 if self._tags is None:
1445
5dbc6356a0d3 Tags: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1444
diff changeset
327 self._tags = maps.Tags(self.ui, self.tagfile)
1160
f06bb42bd2b2 svnmeta: turn tags into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1158
diff changeset
328 return self._tags
f06bb42bd2b2 svnmeta: turn tags into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1158
diff changeset
329
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
330 @property
1161
8693c9558f1a svnmeta: unify variable names cleanup
Sean Farley <sean.michael.farley@gmail.com>
parents: 1160
diff changeset
331 def tagmap_file(self):
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
332 # called tag-renames for backwards compatibility
1153
c3c4518e00aa svnmeta: rename meta_data_dir to metapath
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
333 return os.path.join(self.metapath, 'tag-renames')
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
334
1209
20c28c511551 svnmeta: turn tagmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1208
diff changeset
335 @property
20c28c511551 svnmeta: turn tagmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1208
diff changeset
336 def tagmap(self):
20c28c511551 svnmeta: turn tagmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1208
diff changeset
337 if self._tagmap is None:
1444
e745b543db05 TagMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1443
diff changeset
338 self._tagmap = maps.TagMap(self.ui, self.tagmap_file)
1209
20c28c511551 svnmeta: turn tagmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1208
diff changeset
339 return self._tagmap
20c28c511551 svnmeta: turn tagmap into a lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1208
diff changeset
340
1156
0b40caaaa0ee svnmeta: add revmap_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1154
diff changeset
341 @property
0b40caaaa0ee svnmeta: add revmap_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1154
diff changeset
342 def revmap_file(self):
0b40caaaa0ee svnmeta: add revmap_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1154
diff changeset
343 return os.path.join(self.metapath, 'rev_map')
0b40caaaa0ee svnmeta: add revmap_file property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1154
diff changeset
344
1157
c2b72618645a svnmeta: turn revmap into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1156
diff changeset
345 @property
c2b72618645a svnmeta: turn revmap into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1156
diff changeset
346 def revmap(self):
c2b72618645a svnmeta: turn revmap into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1156
diff changeset
347 if self._revmap is None:
1446
2eba84031a78 RevMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1445
diff changeset
348 self._revmap = maps.RevMap(
2eba84031a78 RevMap: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1445
diff changeset
349 self.revmap_file, os.path.join(self.metapath, 'lastpulled'))
1157
c2b72618645a svnmeta: turn revmap into lazy property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1156
diff changeset
350 return self._revmap
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
351
1415
d6cec13b4bb0 svnmeta: add the "revmapexists" method
Jun Wu <quark@fb.com>
parents: 1404
diff changeset
352 @property
d6cec13b4bb0 svnmeta: add the "revmapexists" method
Jun Wu <quark@fb.com>
parents: 1404
diff changeset
353 def revmapexists(self):
1449
6463dae16c33 meta: check for revmap existence locally
Augie Fackler <raf@durin42.com>
parents: 1447
diff changeset
354 return os.path.exists(self.revmap_file)
1415
d6cec13b4bb0 svnmeta: add the "revmapexists" method
Jun Wu <quark@fb.com>
parents: 1404
diff changeset
355
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
356 def fixdate(self, date):
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
357 if date is not None:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
358 date = date.replace('T', ' ').replace('Z', '').split('.')[0]
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
359 date += ' -0000'
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
360 self.lastdate = date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
361 else:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
362 date = self.lastdate
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
363 return date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
364
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
365 def save(self):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
366 '''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
367 every revision is created.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
368 '''
1127
eaefb3413b87 util: rename pickle_atomic to dump
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
369 util.dump(self.branches, self.branch_info_file)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
370
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
371 def localname(self, path):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
372 """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
373 """
1012
e8cd211684c4 layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents: 1006
diff changeset
374 return self.layoutobj.localname(path)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
375
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
376 def remotename(self, branch):
1013
d507c1a12dcb layouts: refactor mercurial branch to svn path mapping out of svnmeta
David Schleimer <dschleimer@fb.com>
parents: 1012
diff changeset
377 return self.layoutobj.remotename(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
378
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
379 def genextra(self, revnum, branch):
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
380 extra = {}
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
381 subdir = self.subdir
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
382 if subdir and subdir[-1] == '/':
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
383 subdir = subdir[:-1]
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
384 if subdir and subdir[0] != '/':
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
385 subdir = '/' + subdir
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
386
1014
0ed7cf23e801 layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents: 1013
diff changeset
387 path = self.layoutobj.remotepath(branch, subdir)
0ed7cf23e801 layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents: 1013
diff changeset
388
0ed7cf23e801 layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents: 1013
diff changeset
389 if branch:
0ed7cf23e801 layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents: 1013
diff changeset
390 extra['branch'] = branch
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
391
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
392 extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % {
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
393 'uuid': self.uuid,
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
394 'path': path,
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
395 'rev': revnum,
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
396 }
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
397 return extra
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
398
1355
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
399 def skipbranch(self, name):
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
400 '''Returns whether or not we're skipping a branch.'''
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
401 # sometimes it's easier to pass the path instead of just the branch
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
402 # name, so we test for that here
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
403 if name:
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
404 bname = self.split_branch_path(name)
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
405 if bname != (None, None, None):
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
406 name = bname[1]
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
407
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
408 # if the mapped branch == '' and the original branch name == '' then we
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
409 # won't commit this branch
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
410 return name and not self.branchmap.get(name, True)
79e319fe767d svnmeta: add method to determine whether we will skip a particular branch
Sean Farley <sean@farley.io>
parents: 1332
diff changeset
411
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
412 def mapbranch(self, extra, close=False):
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
413 if close:
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
414 extra['close'] = 1
634
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
415 mapped = self.branchmap.get(extra.get('branch', 'default'))
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
416 if not self.usebranchnames or mapped == 'default':
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
417 extra.pop('branch', None)
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
418 elif mapped:
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
419 extra['branch'] = mapped
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
420
634
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
421 if extra.get('branch') == 'default':
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
422 extra.pop('branch', None)
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
423
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
424 def normalize(self, path):
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
425 '''Normalize a path to strip of leading slashes and our subdir if we
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
426 have one.
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
427 '''
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
428 if self.subdir and path == self.subdir[:-1]:
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
429 return ''
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
430 if path and path[0] == '/':
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
431 path = path[1:]
888
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 878
diff changeset
432 if path == self.subdir:
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 878
diff changeset
433 return ''
c6388ed0ec0a svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 878
diff changeset
434 if path and path.startswith(self.subdir + '/'):
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
435 path = path[len(self.subdir):]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
436 if path and path[0] == '/':
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
437 path = path[1:]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
438 return path
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
439
1281
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
440 def getmessage(self, rev):
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
441 msg = rev.message
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
442
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
443 if msg:
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
444 try:
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
445 msg.decode('utf-8')
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
446 return msg
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
447
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
448 except UnicodeDecodeError:
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
449 # ancient svn failed to enforce utf8 encoding
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
450 return msg.decode('iso-8859-1').encode('utf-8')
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
451 else:
1283
dde1f536d820 svnmeta: use self.defaultmessage instead of ui.config call
Sean Farley <sean.michael.farley@gmail.com>
parents: 1282
diff changeset
452 return self.defaultmessage
1281
e74fad41077b svnmeta: copy util.getmessage to here so we can refactor
Sean Farley <sean.michael.farley@gmail.com>
parents: 1267
diff changeset
453
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
454 def get_path_tag(self, path):
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
455 """If path could represent the path to a tag, returns the
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
456 potential (non-empty) tag name. Otherwise, returns None
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
457
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
458 Note that it's only a tag if it was copied from the path '' in a branch
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
459 (or tag) we have, for our purposes.
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
460 """
1027
16045f6f3fef layouts: pull svn path -> potential tag name mapping into layouts
David Schleimer <dschleimer@fb.com>
parents: 1026
diff changeset
461 path = self.normalize(path)
1292
7bbe120be193 layouts: turn taglocations method into a property
Sean Farley <sean.michael.farley@gmail.com>
parents: 1290
diff changeset
462 return self.layoutobj.get_path_tag(path, self.layoutobj.taglocations)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
463
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
464 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
465 """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
466 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
467
724
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
468 Returns a tuple of (path within branch, local branch name, server-side
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
469 branch path).
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
470
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
471 Note that tag paths can also be matched: assuming tags/tag-1.1
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
472 is a tag then:
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
473 tags/tag-1.1 => ('', '../tags/tag-1.1', 'tags/tag-1.1')
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
474 tags/tag-1.1/file => ('file', '../tags/tag-1.1', 'tags/tag-1.1')
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
475 tags/tag-1.2 => (None, None, None)
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
476
724
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
477 If existing=True, will return None, None, None if the file isn't on
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
478 some known branch. If existing=False, then it will guess what the
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
479 branch would be if it were known. Server-side branch path should be
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
480 relative to our subdirectory.
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
481 """
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
482 path = self.normalize(path)
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
483 tag = self.get_path_tag(path)
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
484 if tag:
521
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 520
diff changeset
485 # consider the new tags when dispatching entries
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 520
diff changeset
486 matched = []
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 520
diff changeset
487 for tags in (self.tags, self.addedtags):
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
488 matched += [t for t in tags
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
489 if (tag == t or tag.startswith(t + '/'))]
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
490 if not matched:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
491 return None, None, None
521
839734dfb5c7 Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 520
diff changeset
492 matched.sort(key=len, reverse=True)
536
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
493 if tag == matched[0]:
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
494 brpath = ''
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
495 svrpath = path
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
496 else:
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
497 brpath = tag[len(matched[0])+1:]
460eb781d840 Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents: 534
diff changeset
498 svrpath = path[:-(len(brpath)+1)]
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
499 ln = self.localname(svrpath)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
500 return brpath, ln, svrpath
1029
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
501
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
502 branch_path, local_path = self.layoutobj.split_remote_name(path,
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
503 self.branches)
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
504 branch_name = self.layoutobj.localname(branch_path)
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
505
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
506 if branch_name in self.branches:
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
507 return local_path, branch_name, branch_path
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
508 elif existing or (branch_name and branch_name.startswith('../')):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
509 return None, None, None
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
510 else:
1029
513f2b607b06 layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents: 1027
diff changeset
511 return local_path, branch_name, branch_path
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
512
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
513 def _determine_parent_branch(self, p, src_path, src_rev, revnum):
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
514 if src_path is not None:
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 417
diff changeset
515 src_file, src_branch = self.split_branch_path(src_path)[:2]
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
516 src_tag = self.get_path_tag(src_path)
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
517 if src_tag or src_file == '':
1094
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
518 brpath, fpath = self.layoutobj.split_remote_name(p,
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
519 self.branches)
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
520 # we'll sometimes get a different path out of
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
521 # split_remate_name than the one we passed in, but
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
522 # only for the root of a branch, since the svn copies
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
523 # of those will sometimes be of parent directories of
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
524 # our root
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
525 if fpath == '':
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
526 ln = self.localname(brpath)
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
527 else:
9a7e3dbd0f6e layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents: 1079
diff changeset
528 ln = self.localname(p)
519
247110c633f7 maps: TagMap tags are non-empty strings
Patrick Mezard <pmezard@gmail.com>
parents: 517
diff changeset
529 if src_tag in self.tags:
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
530 changeid = self.tags[src_tag]
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
531 src_rev, src_branch = self.get_source_rev(changeid)[:2]
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
532 return {ln: (src_branch, src_rev, revnum)}
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
533 return {}
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
534
950
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 888
diff changeset
535 def is_path_valid(self, path, existing=True):
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
536 if path is None:
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
537 return False
950
a80b01ceb1fc editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents: 888
diff changeset
538 subpath = self.split_branch_path(path, existing)[0]
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
539 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
540 return False
409
d4615986e1db extract the filemap support into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
541 return subpath in self.filemap
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
542
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
543 def get_parent_svn_branch_and_rev(self, number, branch, exact=False):
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
544 """Return the parent revision of branch at number as a tuple
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
545 (parentnum, parentbranch) or (None, None) if undefined.
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
546
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
547 By default, current revision copy records will be used to resolve
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
548 the parent. For instance, if branch1 is replaced by branch2 in
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
549 current revision, then the parent of current revision on branch1
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
550 will be branch2. In this case, use exact=True to select the
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
551 existing branch before looking at the copy records.
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
552 """
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
553 if (number, branch) in self.revmap:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
554 return number, branch
1423
52749d8aba99 svnmeta: do not iterate revmap directly
Jun Wu <quark@fb.com>
parents: 1415
diff changeset
555 real_num = self.revmap.branchmaxrevnum(branch, number)
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
556 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
557 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
558 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
559 # 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
560 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
561 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
562 # 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
563 # 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
564 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
565 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
566 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
567 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
568 parent_branch = None
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 831
diff changeset
569 if branch_created_rev <= number + 1 and branch != parent_branch:
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
570 # did the branch exist in previous run
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
571 if exact and branch in self.prevbranches:
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
572 if self.prevbranches[branch][1] < real_num:
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
573 return real_num, branch
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
574 return self.get_parent_svn_branch_and_rev(
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
575 parent_branch_rev, parent_branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
576 if real_num != 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
577 return real_num, branch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
578 return None, None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
579
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
580 def get_parent_revision(self, number, branch, exact=False):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
581 '''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
582 '''
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
583 tag = self.get_path_tag(self.remotename(branch))
533
7b330c576920 svnmeta: speedup get_parent_revision() in common case
Patrick Mezard <pmezard@gmail.com>
parents: 521
diff changeset
584 if tag:
537
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
585 # Reference a tag being created
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
586 if tag in self.addedtags:
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
587 tbranch, trev = self.addedtags[tag]
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
588 fromtag = self.get_path_tag(self.remotename(tbranch))
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
589 if not fromtag:
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
590 # Created from a regular branch, not another tag
575
c278a225b750 svnmeta: reverse parameter calculation to lessen complexity
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 574
diff changeset
591 tagged = self.get_parent_svn_branch_and_rev(trev, tbranch)
537
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
592 return node.hex(self.revmap[tagged])
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
593 tag = fromtag
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
594 # Reference an existing tag
1445
5dbc6356a0d3 Tags: no longer take a meta
Augie Fackler <raf@durin42.com>
parents: 1444
diff changeset
595 limitedtags = maps.Tags(self.ui, self.tagfile, endrev=number - 1)
533
7b330c576920 svnmeta: speedup get_parent_revision() in common case
Patrick Mezard <pmezard@gmail.com>
parents: 521
diff changeset
596 if tag in limitedtags:
537
3c8b86949072 svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents: 536
diff changeset
597 return limitedtags[tag]
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
598 r, br = self.get_parent_svn_branch_and_rev(number - 1, branch, exact)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
599 if r is not None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
600 return self.revmap[r, br]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
601 return revlog.nullid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
602
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
603 def get_source_rev(self, changeid=None, ctx=None):
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
604 """Return the source svn revision, the branch name and the svn
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
605 branch path or a converted changeset. If supplied revision
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
606 has no conversion record, raise KeyError.
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
607
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
608 If ctx is None, build one from supplied changeid
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
609 """
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
610 if ctx is None:
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
611 ctx = self.repo[changeid]
632
eea224fa1156 svnmeta: improve error message in get_source_rev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 594
diff changeset
612 extra = ctx.extra()
eea224fa1156 svnmeta: improve error message in get_source_rev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 594
diff changeset
613 if 'convert_revision' not in extra:
eea224fa1156 svnmeta: improve error message in get_source_rev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 594
diff changeset
614 raise KeyError('%s has no conversion record' % ctx)
eea224fa1156 svnmeta: improve error message in get_source_rev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 594
diff changeset
615 branchpath, revnum = extra['convert_revision'][40:].rsplit('@', 1)
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
616 branch = self.localname(self.normalize(branchpath))
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
617 if branchpath and branchpath[0] == '/':
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
618 branchpath = branchpath[1:]
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
619 return int(revnum), branch, branchpath
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
620
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
621 def update_branch_tag_map_for_rev(self, revision):
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
622 """Given a revision object, determine changes to branches.
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
623
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
624 Returns: a dict of {
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
625 'branches': (added_branches, self.closebranches),
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
626 } where adds are dicts where the keys are branch names and
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
627 values are the place the branch came from. The deletions are
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
628 sets of the deleted branches.
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 474
diff changeset
629 """
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
630 paths = revision.paths
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
631 added_branches = {}
538
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
632 # Reset the tags delta before detecting the new one, and take
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
633 # care not to fill them until done since split_branch_path()
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
634 # use them.
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
635 self.addedtags, self.deletedtags = {}, {}
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
636 addedtags, deletedtags = {}, {}
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
637 self.closebranches = set()
131
4d42dbbb5127 hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents: 124
diff changeset
638 for p in sorted(paths):
517
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
639 t_name = self.get_path_tag(p)
ef288fb7f2fe svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents: 499
diff changeset
640 if t_name:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
641 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
642 if src_p is not None and src_rev is not None:
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
643 file, branch = self.split_branch_path(src_p)[:2]
539
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
644 from_tag = self.get_path_tag(src_p)
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
645 if file is None and not from_tag:
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
646 continue
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
647 if from_tag and from_tag not in self.tags:
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
648 # Ignore copies from unknown tags
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
649 continue
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
650 if not file:
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
651 # Direct branch or tag copy
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
652 if from_tag:
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
653 changeid = self.tags[from_tag]
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
654 src_rev, branch = self.get_source_rev(changeid)[:2]
539
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
655 if t_name not in addedtags:
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
656 addedtags[t_name] = branch, src_rev
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
657 else:
36eb608b831b svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents: 538
diff changeset
658 # Subbranch or subtag copy
381
a441ba143ac8 tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents: 380
diff changeset
659 t_name = t_name[:-(len(file)+1)]
538
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
660 found = t_name in addedtags
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
661 if found and src_rev > addedtags[t_name][1]:
545
ebd8fb1a05e4 clean up trailing whitespace
Augie Fackler <durin42@gmail.com>
parents: 540
diff changeset
662 addedtags[t_name] = branch, src_rev
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
663 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
664 and t_name in self.tags):
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
665 branch = self.get_source_rev(self.tags[t_name])[1]
538
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
666 deletedtags[t_name] = branch, None
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
667 continue
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
668
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
669 # 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
670 # 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
671 # 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
672 # checks:
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
673 # 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
674 # 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
675 # interesting.
952
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
676 # 2. Does the file have copyfrom information? If yes, and
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
677 # the branch is being replaced by what would be an
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
678 # ancestor, treat it as a regular revert. Otherwise,
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
679 # 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
680 # 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
681 # 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
682 # 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
683 # 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
684 # (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
685 # 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
686 # we do nothing here.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
687 # 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
688 # 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
689 # 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
690 # already-known branches, so we mark them as deleted.
1099
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
691 # 6. It's a branch being replaced by another branch or a new
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
692 # directory - the action will be 'R'.
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
693 fi, br = self.split_branch_path(p)[:2]
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
694 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
695 if fi == '':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
696 if paths[p].action == 'D':
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
697 self.closebranches.add(br) # case 4
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
698 elif paths[p].action == 'R':
952
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
699 # Check the replacing source is not an ancestor
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
700 # branch of the branch being replaced, this
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 950
diff changeset
701 # would just be a revert.
1099
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
702 if paths[p].copyfrom_path:
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
703 cfi, cbr = self.split_branch_path(
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
704 paths[p].copyfrom_path, paths[p].copyfrom_rev)[:2]
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
705 if cfi == '':
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
706 cctx = self.repo[self.get_parent_revision(
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
707 paths[p].copyfrom_rev + 1, cbr)]
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
708 ctx = self.repo[self.get_parent_revision(
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
709 revision.revnum, br)]
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
710 if cctx and util.isancestor(ctx, cctx):
c6f7a8cfeca9 pull: correctly handle replacing the root of a branch with a non-copied directory
David Schleimer <dschleimer@fb.com>
parents: 1094
diff changeset
711 continue
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
712 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
713 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
714 revision.revnum)
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
715 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
716 continue # case 1
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
717 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
718 for known in self.branches:
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
719 if self.remotename(known).startswith(p):
473
45df4d9320fa Fix 'parent dir of a branch is deleted' refactoring from 343da84.
Max Bowsher <maxb@f2s.com>
parents: 459
diff changeset
720 self.closebranches.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
721 parent = self._determine_parent_branch(
724
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
722 p, paths[p].copyfrom_path, paths[p].copyfrom_rev,
cacaf69912ac fix some line lengths
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 701
diff changeset
723 revision.revnum)
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
724 if not parent and paths[p].copyfrom_path:
540
8dc759dc9ca9 svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents: 539
diff changeset
725 bpath, branch = self.split_branch_path(p, False)[:2]
352
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
726 if (bpath is not None
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
727 and branch not in self.branches
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
728 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
729 parent = {branch: (None, 0, revision.revnum)}
551
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
730 elif bpath is None:
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
731 srcpath = paths[p].copyfrom_path
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
732 srcrev = paths[p].copyfrom_rev
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
733 parent = {}
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
734 for br in self.branches:
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
735 rn = self.remotename(br)
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
736 if rn.startswith(srcpath[1:] + '/'):
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
737 bname = posixpath.basename(rn)
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
738 newbr = posixpath.join(p, bname)
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
739 parent.update(
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
740 self._determine_parent_branch(
d17cec76e769 replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents: 547
diff changeset
741 newbr, rn, srcrev, revision.revnum))
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
742 added_branches.update(parent)
538
93bb37e38675 svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents: 537
diff changeset
743 self.addedtags, self.deletedtags = addedtags, deletedtags
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
744 return {
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
745 'branches': (added_branches, self.closebranches),
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
746 }
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
747
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
748 def save_tbdelta(self, tbdelta):
584
d000b9a361e4 svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents: 575
diff changeset
749 self.prevbranches = dict(self.branches)
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
750 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
751 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
752 self.branches.update(tbdelta['branches'][0])
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
753
634
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
754 def movetag(self, tag, hash, rev, date):
547
9e6499c415a9 tags: fix files edited during tag creation
Augie Fackler <durin42@gmail.com>
parents: 545
diff changeset
755 if tag in self.tags and self.tags[tag] == hash:
474
63cb630d667d tags: handle the most recent commit being an edit to an svn tag properly
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
756 return
634
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
757
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
758 # determine branch from earliest unclosed ancestor
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
759 branchparent = self.repo[hash]
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
760 while branchparent.extra().get('close'):
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
761 branchparent = branchparent.parents()[0]
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
762 branch = self.get_source_rev(ctx=branchparent)[1]
a400f3bf5611 replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 632
diff changeset
763
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 831
diff changeset
764 parentctx = self.repo[self.get_parent_revision(rev.revnum + 1, branch)]
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
765 if '.hgtags' in parentctx:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
766 tagdata = parentctx.filectx('.hgtags').data()
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
767 else:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
768 tagdata = ''
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
769 tagdata += '%s %s\n' % (node.hex(hash), self.tagmap.get(tag, tag))
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
770 def hgtagsfn(repo, memctx, path):
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
771 assert path == '.hgtags'
1219
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
772 return compathacks.makememfilectx(repo,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
773 path=path,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
774 data=tagdata,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
775 islink=False,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
776 isexec=False,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
777 copied=False)
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
778 revnum, branch = self.get_source_rev(ctx=parentctx)[:2]
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
779 newparent = None
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
780 for child in parentctx.children():
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
781 if (self.get_source_rev(ctx=child)[1] == branch
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
782 and child.extra().get('close', False)):
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
783 newparent = child
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
784 if newparent:
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
785 parentctx = newparent
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
786 revnum, branch = self.get_source_rev(ctx=parentctx)[:2]
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
787 ctx = context.memctx(self.repo,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
788 (parentctx.node(), node.nullid),
1284
6d6345604772 svnmeta: call self.getmessage instead of util
Sean Farley <sean.michael.farley@gmail.com>
parents: 1283
diff changeset
789 self.getmessage(rev),
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
790 ['.hgtags', ],
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
791 hgtagsfn,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
792 self.authors[rev.author],
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
793 date,
534
e38f110e7088 svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents: 533
diff changeset
794 parentctx.extra())
831
be5bbb2f2d68 svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents: 773
diff changeset
795 new_hash = self.repo.svn_commitctx(ctx)
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
796 if not newparent:
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
797 assert self.revmap[revnum, branch] == parentctx.node()
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
798 self.revmap[revnum, branch] = new_hash
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
799 self.tags[tag] = hash, rev.revnum
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
800 util.describe_commit(self.ui, new_hash, branch)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
801
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
802 def committags(self, rev, endbranches):
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
803 if not self.addedtags and not self.deletedtags:
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
804 return
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
805 date = self.fixdate(rev.date)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
806 # determine additions/deletions per branch
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
807 branches = {}
520
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
808 for tags in (self.addedtags, self.deletedtags):
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
809 for tag, (branch, srcrev) in tags.iteritems():
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
810 op = srcrev is None and 'rm' or 'add'
5a5b90a6d522 svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents: 519
diff changeset
811 branches.setdefault(branch, []).append((op, tag, srcrev))
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
812
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
813 for b, tags in branches.iteritems():
726
8d36054b04ed keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 724
diff changeset
814
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
815 # modify parent's .hgtags source
726
8d36054b04ed keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 724
diff changeset
816
389
a8811c84e3ee tags: Fix an improper parent calculation.
Augie Fackler <durin42@gmail.com>
parents: 386
diff changeset
817 parent = self.repo[self.get_parent_revision(rev.revnum, b)]
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
818 if '.hgtags' not in parent:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
819 src = ''
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
820 else:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
821 src = parent['.hgtags'].data()
726
8d36054b04ed keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 724
diff changeset
822
8d36054b04ed keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 724
diff changeset
823 fromtag = self.get_path_tag(self.remotename(b))
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
824 for op, tag, r in sorted(tags, reverse=True):
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
825
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
826 if tag in self.tagmap and not self.tagmap[tag]:
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
827 continue
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
828
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
829 tagged = node.hex(node.nullid) # op != 'add'
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
830 if op == 'add':
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
831 if fromtag:
455
54e57da61c1a This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents: 452
diff changeset
832 if fromtag in self.tags:
54e57da61c1a This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents: 452
diff changeset
833 tagged = node.hex(self.tags[fromtag])
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
834 else:
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
835 tagged = node.hex(self.revmap[
575
c278a225b750 svnmeta: reverse parameter calculation to lessen complexity
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 574
diff changeset
836 self.get_parent_svn_branch_and_rev(r, b)])
729
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
837
467b95348e6a implement tag renames
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 728
diff changeset
838 src += '%s %s\n' % (tagged, self.tagmap.get(tag, tag))
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
839 self.tags[tag] = node.bin(tagged), rev.revnum
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
840
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
841 # add new changeset containing updated .hgtags
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
842 def fctxfun(repo, memctx, path):
1219
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
843 return compathacks.makememfilectx(repo,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
844 path='.hgtags',
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
845 data=src,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
846 islink=False,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
847 isexec=False,
656718fdd3be svnmeta: call makememfilectx
Sean Farley <sean.michael.farley@gmail.com>
parents: 1099
diff changeset
848 copied=None)
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
849
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
850 extra = self.genextra(rev.revnum, b)
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
851 if fromtag:
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
852 extra['branch'] = parent.extra().get('branch', 'default')
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
853 self.mapbranch(extra, b in endbranches or fromtag)
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
854
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
855 ctx = context.memctx(self.repo,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
856 (parent.node(), node.nullid),
1284
6d6345604772 svnmeta: call self.getmessage instead of util
Sean Farley <sean.michael.farley@gmail.com>
parents: 1283
diff changeset
857 self.getmessage(rev),
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
858 ['.hgtags'],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
859 fctxfun,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
860 self.authors[rev.author],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
861 date,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
862 extra)
831
be5bbb2f2d68 svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents: 773
diff changeset
863 new = self.repo.svn_commitctx(ctx)
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
864
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
865 if not fromtag and (rev.revnum, b) not in self.revmap:
408
f137231f9d30 extract the revmap support into a separate dict-like class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 407
diff changeset
866 self.revmap[rev.revnum, b] = new
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
867 if b in endbranches:
399
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
868 endbranches.pop(b)
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
869 bname = b or 'default'
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
870 self.ui.status('Marked branch %s as closed.\n' % bname)
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
871
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
872 def delbranch(self, branch, node, rev):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
873 pctx = self.repo[node]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
874 files = pctx.manifest().keys()
423
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 422
diff changeset
875 extra = self.genextra(rev.revnum, branch)
574
8e025a6f0db4 add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 551
diff changeset
876 self.mapbranch(extra, True)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
877 ctx = context.memctx(self.repo,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
878 (node, revlog.nullid),
1284
6d6345604772 svnmeta: call self.getmessage instead of util
Sean Farley <sean.michael.farley@gmail.com>
parents: 1283
diff changeset
879 self.getmessage(rev),
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
880 [],
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
881 lambda x, y, z: None,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
882 self.authors[rev.author],
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
883 self.fixdate(rev.date),
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
884 extra)
831
be5bbb2f2d68 svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents: 773
diff changeset
885 new = self.repo.svn_commitctx(ctx)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
886 self.ui.status('Marked branch %s as closed.\n' % (branch or 'default'))