annotate hgsubversion/svnmeta.py @ 474:63cb630d667d

tags: handle the most recent commit being an edit to an svn tag properly
author Augie Fackler <durin42@gmail.com>
date Sat, 18 Jul 2009 22:30:59 -0500
parents 45df4d9320fa
children 1fd3cfa47c5e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import cPickle as pickle
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
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
10 import util
317
5dc8fee7fc96 Less import *
Augie Fackler <durin42@gmail.com>
parents: 316
diff changeset
11 import maps
421
8277113036f1 editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 420
diff changeset
12 import editor
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
13
363
ccef78b91ac9 Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 362
diff changeset
14
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
15 def pickle_atomic(data, file_path, dir=None):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
16 """pickle some data to a path atomically.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
17
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
18 This is present because I kept corrupting my revmap by managing to hit ^C
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
19 during the pickle of that file.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
20 """
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
21 try:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
22 f, path = tempfile.mkstemp(prefix='pickling', dir=dir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
23 f = os.fdopen(f, 'w')
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
24 pickle.dump(data, f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
25 f.close()
146
4da9f20aef01 Add some more coverage directives.
Augie Fackler <durin42@gmail.com>
parents: 145
diff changeset
26 except: #pragma: no cover
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
27 raise
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28 else:
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 237
diff changeset
29 hgutil.rename(path, file_path)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
30
411
d71972428fce editor: move current revision state into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
31
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
32 class SVNMeta(object):
33
a9c15cae50e5 Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents: 23
diff changeset
33
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
34 def __init__(self, repo, uuid=None, subdir=''):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
35 """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
36
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
37 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
38 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
39 """
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
40 self.ui = repo.ui
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
41 self.repo = repo
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
42 self.path = os.path.normpath(repo.join('..'))
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
43
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
44 if not os.path.isdir(self.meta_data_dir):
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
45 os.makedirs(self.meta_data_dir)
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
46 self._set_uuid(uuid)
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
47 # TODO: validate subdir too
408
f137231f9d30 extract the revmap support into a separate dict-like class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 407
diff changeset
48 self.revmap = maps.RevMap(repo)
405
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
49
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
50 author_host = self.ui.config('hgsubversion', 'defaulthost', uuid)
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
51 authors = self.ui.config('hgsubversion', 'authormap')
a98b8d424221 editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 400
diff changeset
52 tag_locations = self.ui.configlist('hgsubversion', 'tagpaths', ['tags'])
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
53 self.usebranchnames = self.ui.configbool('hgsubversion',
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 330
diff changeset
54 'usebranchnames', True)
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 123
diff changeset
55
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 342
diff changeset
56 # FIXME: test that this hasn't changed! defer & compare?
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
57 self.subdir = subdir
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
58 if self.subdir and self.subdir[0] == '/':
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
59 self.subdir = self.subdir[1:]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
60 self.branches = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
61 if os.path.exists(self.branch_info_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
62 f = open(self.branch_info_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
63 self.branches = pickle.load(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
64 f.close()
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
65 self.tags = maps.TagMap(repo)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
66 if os.path.exists(self.tag_locations_file):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
67 f = open(self.tag_locations_file)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
68 self.tag_locations = pickle.load(f)
8
c89f53103502 Another fix for Win32 compat.
Shun-ichi GOTO <shunichi.goto@gmail.com>
parents: 6
diff changeset
69 f.close()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
70 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
71 self.tag_locations = tag_locations
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
72 pickle_atomic(self.tag_locations, self.tag_locations_file,
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
73 self.meta_data_dir)
295
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
74 # ensure nested paths are handled properly
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
75 self.tag_locations.sort()
aacc8cf83e13 Ensure proper handling of nested tag paths by sorting and reversing them.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 224
diff changeset
76 self.tag_locations.reverse()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
77
317
5dc8fee7fc96 Less import *
Augie Fackler <durin42@gmail.com>
parents: 316
diff changeset
78 self.authors = maps.AuthorMap(self.ui, self.authors_file,
307
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
79 defaulthost=author_host)
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 306
diff changeset
80 if authors: self.authors.load(authors)
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
81
290
153266401676 hg_delta_editor: add timezone to default date to avoid DST issues
Patrick Mezard <pmezard@gmail.com>
parents: 279
diff changeset
82 self.lastdate = '1970-01-01 00:00:00 -0000'
409
d4615986e1db extract the filemap support into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
83 self.filemap = maps.FileMap(repo)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
84
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
85 @property
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
86 def editor(self):
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
87 if not hasattr(self, '_editor'):
421
8277113036f1 editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 420
diff changeset
88 self._editor = editor.HgEditor(self)
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
89 return self._editor
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 415
diff changeset
90
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
91 def _get_uuid(self):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
92 return open(os.path.join(self.meta_data_dir, 'uuid')).read()
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
93
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
94 def _set_uuid(self, uuid):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
95 if not uuid:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
96 return
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
97 elif os.path.isfile(os.path.join(self.meta_data_dir, 'uuid')):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
98 stored_uuid = self._get_uuid()
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
99 assert stored_uuid
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
100 if uuid != stored_uuid:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
101 raise hgutil.Abort('unable to operate on unrelated repository')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
102 else:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
103 if uuid:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
104 f = open(os.path.join(self.meta_data_dir, 'uuid'), 'w')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
105 f.write(uuid)
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
106 f.flush()
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
107 f.close()
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
108 else:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
109 raise hgutil.Abort('unable to operate on unrelated repository')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
110
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
111 uuid = property(_get_uuid, _set_uuid, None,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
112 'Error-checked UUID of source Subversion repository.')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
113
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
114 @property
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
115 def meta_data_dir(self):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
116 return os.path.join(self.path, '.hg', 'svn')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
117
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
118 @property
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
119 def branch_info_file(self):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
120 return os.path.join(self.meta_data_dir, 'branch_info')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
121
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
122 @property
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
123 def tag_locations_file(self):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
124 return os.path.join(self.meta_data_dir, 'tag_locations')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
125
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
126 @property
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
127 def authors_file(self):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
128 return os.path.join(self.meta_data_dir, 'authors')
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
129
237
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
130 def fixdate(self, date):
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
131 if date is not None:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
132 date = date.replace('T', ' ').replace('Z', '').split('.')[0]
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
133 date += ' -0000'
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
134 self.lastdate = date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
135 else:
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
136 date = self.lastdate
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
137 return date
c90cfa665b81 Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 232
diff changeset
138
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
139 def save(self):
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
140 '''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
141 every revision is created.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
142 '''
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
143 pickle_atomic(self.branches, self.branch_info_file, self.meta_data_dir)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
144
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
145 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
146 """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
147 """
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
148 if path == 'trunk':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
149 return None
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
150 elif path.startswith('branches/'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
151 return path[len('branches/'):]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
152 return '../%s' % path
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
153
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
154 def remotename(self, branch):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
155 if branch == 'default' or branch is None:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
156 return 'trunk'
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
157 elif branch.startswith('../'):
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
158 return branch[3:]
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
159 return 'branches/%s' % branch
72
9ec2a12c12ae hg_delta_editor: make branches_in_paths() return the branch svn path too
Patrick Mezard <pmezard@gmail.com>
parents: 69
diff changeset
160
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
161 def genextra(self, revnum, branch):
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
162 extra = {}
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
163 branchpath = 'trunk'
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
164 if branch:
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
165 extra['branch'] = branch
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
166 if branch.startswith('../'):
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
167 branchpath = branch[3:]
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
168 else:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
169 branchpath = 'branches/%s' % branch
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
170
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
171 subdir = self.subdir
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
172 if subdir and subdir[-1] == '/':
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
173 subdir = subdir[:-1]
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
174 if subdir and subdir[0] != '/':
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
175 subdir = '/' + subdir
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
176
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
177 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
178 'uuid': self.uuid,
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
179 'path': '%s/%s' % (subdir , branchpath),
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
180 'rev': revnum,
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
181 }
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
182 return extra
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
183
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
184 def normalize(self, path):
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
185 '''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
186 have one.
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
187 '''
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
188 if path and path[0] == '/':
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
189 path = path[1:]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
190 if path and path.startswith(self.subdir):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
191 path = path[len(self.subdir):]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
192 if path and path[0] == '/':
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
193 path = path[1:]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
194 return path
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
195
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
196 def is_path_tag(self, path):
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
197 """If path could represent the path to a tag, returns the potential tag
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
198 name. Otherwise, returns False.
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
199
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
200 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
201 (or tag) we have, for our purposes.
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
202 """
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
203 path = self.normalize(path)
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
204 for tagspath in self.tag_locations:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
205 onpath = path.startswith(tagspath)
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
206 longer = len(path) > len('%s/' % tagspath)
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
207 if path and onpath and longer:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
208 tag, subpath = path[len(tagspath) + 1:], ''
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
209 return tag
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
210 return False
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
211
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
212 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
213 """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
214 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
215
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
216 Returns a tuple of (path within branch, local branch name, server-side branch path).
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
217
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
218 If existing=True, will return None, None, None if the file isn't on some known
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
219 branch. If existing=False, then it will guess what the branch would be if it were
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
220 known.
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
221 """
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
222 path = self.normalize(path)
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
223 if self.is_path_tag(path):
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
224 tag = self.is_path_tag(path)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
225 matched = [t for t in self.tags.iterkeys() if tag.startswith(t+'/')]
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
226 if not matched:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
227 return None, None, None
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
228 matched.sort(cmp=lambda x,y: cmp(len(x),len(y)), reverse=True)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
229 brpath = tag[len(matched[0])+1:]
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
230 svrpath = path[:-(len(brpath)+1)]
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
231 ln = self.localname(svrpath)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
232 return brpath, ln, svrpath
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
233 test = ''
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
234 path_comps = path.split('/')
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
235 while self.localname(test) not in self.branches and len(path_comps):
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
236 if not test:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
237 test = path_comps.pop(0)
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
238 else:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
239 test += '/%s' % path_comps.pop(0)
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
240 if self.localname(test) in self.branches:
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
241 return path[len(test)+1:], self.localname(test), test
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
242 if existing:
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
243 return None, None, None
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
244 if path == 'trunk' or path.startswith('trunk/'):
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
245 path = path.split('/')[1:]
207
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
246 test = 'trunk'
218
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
247 elif path.startswith('branches/'):
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
248 elts = path.split('/')
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
249 test = '/'.join(elts[:2])
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
250 path = '/'.join(elts[2:])
207
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
251 else:
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
252 path = test.split('/')[-1]
b20a6c149021 fetch: Fix a bogus case where no files in the root level of trunk caused breakage in the branch detection.
Augie Fackler <durin42@gmail.com>
parents: 203
diff changeset
253 test = '/'.join(test.split('/')[:-1])
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
254 ln = self.localname(test)
218
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
255 if ln and ln.startswith('../'):
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
256 return None, None, None
a360ddc97719 branches: change handling again, but this time a little less magic.
Augie Fackler <durin42@gmail.com>
parents: 217
diff changeset
257 return path, ln, test
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
258
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
259 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
260 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
261 src_file, src_branch = self.split_branch_path(src_path)[:2]
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
262 src_tag = self.is_path_tag(src_path)
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
263 if src_tag != False or src_file == '': # case 2
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
264 ln = self.localname(p)
454
29fe7212cae0 tags: be more aggressive about not copying from tags we do not have
Augie Fackler <durin42@gmail.com>
parents: 453
diff changeset
265 if src_tag != False and src_tag in self.tags:
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
266 ci = self.repo[self.tags[src_tag]].extra()['convert_revision']
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
267 src_rev, src_branch, = self.parse_converted_revision(ci)
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
268 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
269 return {}
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
270
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
271 def is_path_valid(self, path):
217
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
272 if path is None:
6eb691a163cd hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents: 214
diff changeset
273 return False
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
274 subpath = self.split_branch_path(path)[0]
179
a336e3e82648 Fetch: add a filemap argument for use in converting old repositories to
Graham Booker <gbooker@cod3r.com>
parents: 176
diff changeset
275 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
276 return False
409
d4615986e1db extract the filemap support into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
277 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
278
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
279 def get_parent_svn_branch_and_rev(self, number, branch):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
280 number -= 1
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
281 if (number, branch) in self.revmap:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
282 return number, branch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
283 real_num = 0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
284 for num, br in self.revmap.iterkeys():
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
285 if br != branch:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
286 continue
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
287 if num <= number and num > real_num:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
288 real_num = num
133
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
289 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
290 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
291 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
292 # 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
293 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
294 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
295 # 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
296 # 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
297 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
298 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
299 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
300 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
301 parent_branch = None
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
302 if branch_created_rev <= number+1 and branch != parent_branch:
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
303 return self.get_parent_svn_branch_and_rev(
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
304 parent_branch_rev+1,
2242dd1163c6 hg_delta_editor: fix bad parent revision calculation in the case of a branch
Augie Fackler <durin42@gmail.com>
parents: 131
diff changeset
305 parent_branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
306 if real_num != 0:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
307 return real_num, branch
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
308 return None, None
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
309
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
310 def get_parent_revision(self, number, branch):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
311 '''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
312 '''
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
313 tag = self.is_path_tag(self.remotename(branch))
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
314 limitedtags = maps.TagMap(self.repo, endrev=number-1)
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
315 if tag and tag in limitedtags:
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
316 ha = limitedtags[tag]
450
7ca49177991a tags: Handle edits to edited tags.
Augie Fackler <durin42@gmail.com>
parents: 449
diff changeset
317 return ha
7ca49177991a tags: Handle edits to edited tags.
Augie Fackler <durin42@gmail.com>
parents: 449
diff changeset
318 r, br = self.get_parent_svn_branch_and_rev(number, branch)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
319 if r is not None:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
320 return self.revmap[r, br]
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
321 return revlog.nullid
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
322
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
323 def parse_converted_revision(self, convertedrev):
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
324 branch, revnum = convertedrev[40:].rsplit('@', 1)
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
325 return int(revnum), self.localname(self.normalize(branch))
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
326
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
327 def update_branch_tag_map_for_rev(self, revision):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
328 paths = revision.paths
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
329 added_branches = {}
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
330 added_tags = {}
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
331 self.closebranches = set()
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
332 tags_to_delete = set()
131
4d42dbbb5127 hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents: 124
diff changeset
333 for p in sorted(paths):
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
334 t_name = self.is_path_tag(p)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
335 if t_name != False:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
336 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
337 # if you commit to a tag, I'm calling you stupid and ignoring
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
338 # you.
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
339 if src_p is not None and src_rev is not None:
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 417
diff changeset
340 file, branch = self.split_branch_path(src_p)[:2]
116
30580c05dccc hg_delta_editor: merge _is_path_valid() and _path_and_branch_from_path()
Patrick Mezard <pmezard@gmail.com>
parents: 111
diff changeset
341 if file is None:
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
342 # some crazy people make tags from other tags
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
343 from_tag = self.is_path_tag(src_p)
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
344 if not from_tag:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
345 continue
454
29fe7212cae0 tags: be more aggressive about not copying from tags we do not have
Augie Fackler <durin42@gmail.com>
parents: 453
diff changeset
346 if from_tag in self.tags:
29fe7212cae0 tags: be more aggressive about not copying from tags we do not have
Augie Fackler <durin42@gmail.com>
parents: 453
diff changeset
347 ci = self.repo[self.tags[from_tag]].extra()['convert_revision']
29fe7212cae0 tags: be more aggressive about not copying from tags we do not have
Augie Fackler <durin42@gmail.com>
parents: 453
diff changeset
348 src_rev, branch, = self.parse_converted_revision(ci)
459
7151f63ab33c tags: fix a bug triggered by copies from non-branch-roots
Augie Fackler <durin42@gmail.com>
parents: 457
diff changeset
349 file = ''
381
a441ba143ac8 tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents: 380
diff changeset
350 if t_name not in added_tags and file is '':
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
351 added_tags[t_name] = branch, src_rev
381
a441ba143ac8 tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents: 380
diff changeset
352 elif file:
a441ba143ac8 tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents: 380
diff changeset
353 t_name = t_name[:-(len(file)+1)]
456
b5b4095d2993 Second fix required for our tags to work.
Michael J. Pedersen <mpedersen@datapipe.com>
parents: 455
diff changeset
354 if t_name in added_tags and src_rev > added_tags[t_name][1]:
381
a441ba143ac8 tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents: 380
diff changeset
355 added_tags[t_name] = branch, src_rev
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
356 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
357 and t_name in self.tags):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
358 tags_to_delete.add(t_name)
203
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
359 continue
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
360 # 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
361 # 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
362 # 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
363 # checks:
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
364 # 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
365 # 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
366 # interesting.
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
367 # 2. Does the file have copyfrom information? If yes, then
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
368 # 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
369 # 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
370 # 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
371 # 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
372 # 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
373 # (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
374 # 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
375 # we do nothing here.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
376 # 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
377 # 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
378 # 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
379 # already-known branches, so we mark them as deleted.
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
380 # 6. It's a branch being replaced by another branch - the
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
381 # action will be 'R'.
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 417
diff changeset
382 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
383 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
384 if fi == '':
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
385 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
386 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
387 elif paths[p].action == 'R':
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
388 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
389 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
390 revision.revnum)
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
391 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
392 continue # case 1
907c160c6289 Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
393 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
394 for known in self.branches:
417
8630d1ebcdb9 svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 416
diff changeset
395 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
396 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
397 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
398 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, revision.revnum)
313
942f198b8ff5 hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents: 312
diff changeset
399 if not parent and paths[p].copyfrom_path:
420
59e19c73b0df svnmeta: eliminate unneeded path_and_branch_for_path() method
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 417
diff changeset
400 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
401 if (bpath is not None
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
402 and branch not in self.branches
cc7a10efddc9 Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents: 350
diff changeset
403 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
404 parent = {branch: (None, 0, revision.revnum)}
312
4dc197f533c1 hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents: 290
diff changeset
405 added_branches.update(parent)
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
406 def branchoftag(tag):
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
407 cr = self.repo[self.tags[tag]].extra()['convert_revision']
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
408 return self.parse_converted_revision(cr)[1]
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
409 rmtags = dict((t, branchoftag(t)) for t in tags_to_delete)
367
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
410 return {
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
411 'tags': (added_tags, rmtags),
414
343da842dbe6 split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 413
diff changeset
412 '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
413 }
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
414
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
415 def save_tbdelta(self, tbdelta):
ce64d57172a3 Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 365
diff changeset
416 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
417 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
418 self.branches.update(tbdelta['branches'][0])
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
419
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
420 def movetag(self, tag, hash, branch, rev, date):
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
421 if self.tags[tag] == hash:
63cb630d667d tags: handle the most recent commit being an edit to an svn tag properly
Augie Fackler <durin42@gmail.com>
parents: 473
diff changeset
422 return
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
423 if branch == 'default':
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
424 branch = None
449
bda5b47ad2a2 tags: handle editing a tag and its source branch simultaneously
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
425 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
426 if '.hgtags' in parentctx:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
427 tagdata = parentctx.filectx('.hgtags').data()
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
428 else:
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
429 tagdata = ''
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
430 tagdata += '%s %s\n' % (node.hex(hash), tag, )
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
431 def hgtagsfn(repo, memctx, path):
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
432 assert path == '.hgtags'
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
433 return context.memfilectx(path=path,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
434 data=tagdata,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
435 islink=False,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
436 isexec=False,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
437 copied=False)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
438 pextra = parentctx.extra()
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
439 revnum, branch = self.parse_converted_revision(pextra['convert_revision'])
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
440 newparent = None
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
441 for child in parentctx.children():
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
442 cextra = child.extra()
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
443 if (self.parse_converted_revision(cextra['convert_revision'])[1] == branch
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
444 and cextra.get('close', False)):
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
445 newparent = child
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
446 if newparent:
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
447 parentctx = newparent
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
448 pextra = parentctx.extra()
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
449 revnum, branch = self.parse_converted_revision(pextra['convert_revision'])
447
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
450 ctx = context.memctx(self.repo,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
451 (parentctx.node(), node.nullid),
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
452 rev.message or '...',
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
453 ['.hgtags', ],
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
454 hgtagsfn,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
455 self.authors[rev.author],
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
456 date,
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
457 pextra)
0d3b5acb1d51 tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents: 423
diff changeset
458 new_hash = self.repo.commitctx(ctx)
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
459 if not newparent:
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 451
diff changeset
460 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
461 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
462 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
463 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
464
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
465 def committags(self, delta, rev, endbranches):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
466
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
467 date = self.fixdate(rev.date)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
468 # determine additions/deletions per branch
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
469 branches = {}
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
470 for tag, source in delta[0].iteritems():
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
471 b, r = source
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
472 branches.setdefault(b, []).append(('add', tag, r))
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
473 for tag, branch in delta[1].iteritems():
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
474 branches.setdefault(branch, []).append(('rm', tag, None))
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
475
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
476 for b, tags in branches.iteritems():
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
477 fromtag = self.is_path_tag(self.remotename(b))
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
478 # modify parent's .hgtags source
389
a8811c84e3ee tags: Fix an improper parent calculation.
Augie Fackler <durin42@gmail.com>
parents: 386
diff changeset
479 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
480 if '.hgtags' not in parent:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
481 src = ''
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
482 else:
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
483 src = parent['.hgtags'].data()
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
484 for op, tag, r in sorted(tags, reverse=True):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
485 if op == 'add':
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
486 if fromtag:
455
54e57da61c1a This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents: 452
diff changeset
487 if fromtag in self.tags:
54e57da61c1a This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents: 452
diff changeset
488 tagged = node.hex(self.tags[fromtag])
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
489 else:
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
490 tagged = node.hex(self.revmap[
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
491 self.get_parent_svn_branch_and_rev(r+1, b)])
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
492 elif op == 'rm':
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
493 tagged = node.hex(node.nullid)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
494 src += '%s %s\n' % (tagged, tag)
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
495 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
496
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
497 # add new changeset containing updated .hgtags
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
498 def fctxfun(repo, memctx, path):
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
499 return context.memfilectx(path='.hgtags', data=src,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
500 islink=False, isexec=False,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
501 copied=None)
422
6086363e8230 svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 421
diff changeset
502 extra = self.genextra(rev.revnum, b)
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
503 if fromtag:
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
504 extra['branch'] = parent.extra().get('branch', 'default')
398
f13dd964d10c tags: obey usebranchnames setting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 397
diff changeset
505 if not self.usebranchnames:
f13dd964d10c tags: obey usebranchnames setting
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 397
diff changeset
506 extra.pop('branch', None)
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
507 if b in endbranches or fromtag:
399
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
508 extra['close'] = 1
376
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
509 ctx = context.memctx(self.repo,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
510 (parent.node(), node.nullid),
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
511 rev.message or ' ',
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
512 ['.hgtags'],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
513 fctxfun,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
514 self.authors[rev.author],
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
515 date,
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
516 extra)
9327e9325645 Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 375
diff changeset
517 new = self.repo.commitctx(ctx)
451
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
518
e533e78f1b2f tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents: 450
diff changeset
519 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
520 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
521 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
522 endbranches.pop(b)
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
523 bname = b or 'default'
94f7e8c53c36 tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 398
diff changeset
524 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
525
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
526 def delbranch(self, branch, node, rev):
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
527 pctx = self.repo[node]
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
528 files = pctx.manifest().keys()
423
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 422
diff changeset
529 extra = self.genextra(rev.revnum, branch)
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 422
diff changeset
530 extra['close'] = 1
413
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
531 if self.usebranchnames:
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
532 extra['branch'] = branch or 'default'
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
533 ctx = context.memctx(self.repo,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
534 (node, revlog.nullid),
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
535 rev.message or util.default_commit_msg,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
536 [],
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
537 lambda x, y, z: None,
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
538 self.authors[rev.author],
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
539 self.fixdate(rev.date),
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
540 extra)
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
541 new = self.repo.commitctx(ctx)
ac0cc3c9ea63 sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 411
diff changeset
542 self.ui.status('Marked branch %s as closed.\n' % (branch or 'default'))