Mercurial > hgsubversion
annotate hgsubversion/svnmeta.py @ 1152:aa98fdccaa0e
subdir: use util.dump and util.load for writing and reading
We need to change both svnmeta and svncommands at the same time since they are
heavily tied together.
The reason for this change is to remove the duplicate code for reading and
writing subdir present in svncommands.py. We will now use the standard
util.dump and util.load for writing and reading.
Due to the way json reads a string, the old format is still valid for use and
will be read correctly.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Tue, 18 Feb 2014 18:28:33 -0600 |
parents | 510fa46caf9c |
children | c3c4518e00aa |
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 |
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 | 11 import maps |
1005
5bba4d1becde
layouts: refactor layout loading based on config into function
David Schleimer <dschleimer@fb.com>
parents:
986
diff
changeset
|
12 import layouts |
421
8277113036f1
editor: rename hg_delta_editor.HgChangeReceiver to editor.HgEditor
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
420
diff
changeset
|
13 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
|
14 |
363
ccef78b91ac9
Move exception classes in hg_delta_editor up top.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
362
diff
changeset
|
15 |
414
343da842dbe6
split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
413
diff
changeset
|
16 class SVNMeta(object): |
33
a9c15cae50e5
Faster append-only revmap implementation.
Andreas Hartmetz <ahartmetz@gmail.com>
parents:
23
diff
changeset
|
17 |
748
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
18 def __init__(self, repo, uuid=None, subdir=None): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 """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
|
20 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 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
|
22 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
|
23 """ |
405
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
24 self.ui = repo.ui |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
25 self.repo = repo |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
26 self.path = os.path.normpath(repo.join('..')) |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
27 |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
28 if not os.path.isdir(self.meta_data_dir): |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
29 os.makedirs(self.meta_data_dir) |
745
6252f0cc7b7a
svnmeta: cache the UUID in an attribute.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
742
diff
changeset
|
30 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
|
31 self.subdir = subdir |
408
f137231f9d30
extract the revmap support into a separate dict-like class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
407
diff
changeset
|
32 self.revmap = maps.RevMap(repo) |
405
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
33 |
a98b8d424221
editor: simplify HgChangeReceiver constructor signature
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
400
diff
changeset
|
34 author_host = self.ui.config('hgsubversion', 'defaulthost', uuid) |
973
21197f5ee9de
expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
959
diff
changeset
|
35 authors = util.configpath(self.ui, 'authormap') |
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
|
36 self.usebranchnames = self.ui.configbool('hgsubversion', |
594
3dbd3af0ffaf
svnmeta: minor cosmetics whitespace cleanup.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
584
diff
changeset
|
37 'usebranchnames', True) |
973
21197f5ee9de
expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
959
diff
changeset
|
38 branchmap = util.configpath(self.ui, 'branchmap') |
21197f5ee9de
expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
959
diff
changeset
|
39 tagmap = util.configpath(self.ui, 'tagmap') |
21197f5ee9de
expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
959
diff
changeset
|
40 filemap = util.configpath(self.ui, 'filemap') |
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
|
41 |
1130
ed4804ee68c4
svnmeta: use util.load instead of bare pickle
Sean Farley <sean.michael.farley@gmail.com>
parents:
1127
diff
changeset
|
42 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
|
43 self.prevbranches = dict(self.branches) |
728
cfefeefad199
rename TagMap to Tags, to free up the TagMap name
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
726
diff
changeset
|
44 self.tags = maps.Tags(repo) |
1006
7a3b938825cd
layouts: refactor layout loading and persisting out of svnmeta.py
David Schleimer <dschleimer@fb.com>
parents:
1005
diff
changeset
|
45 self._layout = layouts.detect.layout_from_file(self.meta_data_dir, |
7a3b938825cd
layouts: refactor layout loading and persisting out of svnmeta.py
David Schleimer <dschleimer@fb.com>
parents:
1005
diff
changeset
|
46 ui=self.repo.ui) |
1012
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
47 self._layoutobj = None |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 |
317 | 49 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
|
50 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
|
51 if authors: self.authors.load(authors) |
729 | 52 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
53 self.branchmap = maps.BranchMap(self.ui, self.branchmapfile) |
693
03dca55abec9
clone: add --singlebranch option
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
671
diff
changeset
|
54 if branchmap: |
03dca55abec9
clone: add --singlebranch option
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
671
diff
changeset
|
55 self.branchmap.load(branchmap) |
237
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
56 |
729 | 57 self.tagmap = maps.TagMap(self.ui, self.tagmapfile) |
58 if tagmap: | |
59 self.tagmap.load(tagmap) | |
60 | |
846
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
61 self.filemap = maps.FileMap(self.ui, self.filemap_file) |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
62 if filemap: |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
63 self.filemap.load(filemap) |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
64 |
290
153266401676
hg_delta_editor: add timezone to default date to avoid DST issues
Patrick Mezard <pmezard@gmail.com>
parents:
279
diff
changeset
|
65 self.lastdate = '1970-01-01 00:00:00 -0000' |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
66 self.addedtags = {} |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
67 self.deletedtags = {} |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
69 @property |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
70 def layout(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
71 # this method can't determine the layout, but it needs to be |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
72 # resolved into something other than auto before this ever |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
73 # gets called |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
74 if not self._layout or self._layout == 'auto': |
1005
5bba4d1becde
layouts: refactor layout loading based on config into function
David Schleimer <dschleimer@fb.com>
parents:
986
diff
changeset
|
75 self._layout = layouts.detect.layout_from_config(self.repo.ui) |
1006
7a3b938825cd
layouts: refactor layout loading and persisting out of svnmeta.py
David Schleimer <dschleimer@fb.com>
parents:
1005
diff
changeset
|
76 layouts.persist.layout_to_file(self.meta_data_dir, self._layout) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
77 return self._layout |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
78 |
1012
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
79 @property |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
80 def layoutobj(self): |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
81 if not self._layoutobj: |
1024
8feff33e387d
layouts: make ui object available to layout instances
David Schleimer <dschleimer@fb.com>
parents:
1014
diff
changeset
|
82 self._layoutobj = layouts.layout_from_name(self.layout, self.ui) |
1012
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
83 return self._layoutobj |
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
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 |
748
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
91 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
|
92 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
|
93 |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
98 subdirfile = os.path.join(self.meta_data_dir, 'subdir') |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
99 |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 'repository') |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
108 else: |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 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
|
113 else: |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
114 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
|
115 "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
|
116 |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
117 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
|
118 '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
|
119 'repository.') |
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
747
diff
changeset
|
120 |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
121 def _get_uuid(self): |
747
34b25f6bc4ef
svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
746
diff
changeset
|
122 return self.__uuid |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
123 |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
124 def _set_uuid(self, uuid): |
747
34b25f6bc4ef
svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
746
diff
changeset
|
125 uuidfile = os.path.join(self.meta_data_dir, 'uuid') |
34b25f6bc4ef
svnmeta: slight refactor of the UUID property.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
746
diff
changeset
|
126 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
|
127 stored_uuid = util.load(uuidfile) |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
128 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
|
129 if uuid and uuid != stored_uuid: |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 self.__uuid = uuid |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
135 else: |
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
|
136 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
|
137 "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
|
138 |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
139 uuid = property(_get_uuid, _set_uuid, None, |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
140 'Error-checked UUID of source Subversion repository.') |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
141 |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
142 @property |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
143 def meta_data_dir(self): |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
144 return os.path.join(self.path, '.hg', 'svn') |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
145 |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
146 @property |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
147 def branch_info_file(self): |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
148 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
|
149 |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
150 @property |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
151 def authors_file(self): |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
152 return os.path.join(self.meta_data_dir, 'authors') |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
153 |
846
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
154 @property |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
155 def filemap_file(self): |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
156 return os.path.join(self.meta_data_dir, 'filemap') |
7ca3d1b08d67
Save filemap into .hg/svn/filemap just like other maps
Vitaliy Filippov <vitalif@yourcmc.ru>
parents:
837
diff
changeset
|
157 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
158 @property |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
159 def branchmapfile(self): |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
160 return os.path.join(self.meta_data_dir, 'branchmap') |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
161 |
729 | 162 @property |
163 def tagmapfile(self): | |
164 # called tag-renames for backwards compatibility | |
165 return os.path.join(self.meta_data_dir, 'tag-renames') | |
166 | |
237
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
167 def fixdate(self, date): |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
168 if date is not None: |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
169 date = date.replace('T', ' ').replace('Z', '').split('.')[0] |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
170 date += ' -0000' |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
171 self.lastdate = date |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
172 else: |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
173 date = self.lastdate |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
174 return date |
c90cfa665b81
Cope with date-less revisions.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
232
diff
changeset
|
175 |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
176 def save(self): |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
177 '''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
|
178 every revision is created. |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
179 ''' |
1127
eaefb3413b87
util: rename pickle_atomic to dump
Sean Farley <sean.michael.farley@gmail.com>
parents:
1099
diff
changeset
|
180 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
|
181 |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
182 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
|
183 """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
|
184 """ |
1012
e8cd211684c4
layouts: refactor out svn path to mercurial branch logic
David Schleimer <dschleimer@fb.com>
parents:
1006
diff
changeset
|
185 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
|
186 |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
187 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
|
188 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
|
189 |
422
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
190 def genextra(self, revnum, branch): |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
191 extra = {} |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
192 subdir = self.subdir |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
193 if subdir and subdir[-1] == '/': |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
194 subdir = subdir[:-1] |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
195 if subdir and subdir[0] != '/': |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
196 subdir = '/' + subdir |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
197 |
1014
0ed7cf23e801
layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents:
1013
diff
changeset
|
198 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
|
199 |
0ed7cf23e801
layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents:
1013
diff
changeset
|
200 if branch: |
0ed7cf23e801
layouts: refactor path component of convinfo generation into layouts lib
David Schleimer <dschleimer@fb.com>
parents:
1013
diff
changeset
|
201 extra['branch'] = branch |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
202 |
422
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
203 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
|
204 'uuid': self.uuid, |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
205 'path': path, |
422
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
206 'rev': revnum, |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
207 } |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
208 return extra |
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
209 |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
210 def mapbranch(self, extra, close=False): |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
211 if close: |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
212 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
|
213 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
|
214 if not self.usebranchnames or mapped == 'default': |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
215 extra.pop('branch', None) |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
216 elif mapped: |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
217 extra['branch'] = mapped |
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
218 |
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
|
219 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
|
220 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
|
221 |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
222 def normalize(self, path): |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
223 '''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
|
224 have one. |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
225 ''' |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
226 if self.subdir and path == self.subdir[:-1]: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
227 return '' |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
228 if path and path[0] == '/': |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
229 path = path[1:] |
888
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
878
diff
changeset
|
230 if path == self.subdir: |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
878
diff
changeset
|
231 return '' |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
878
diff
changeset
|
232 if path and path.startswith(self.subdir + '/'): |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
233 path = path[len(self.subdir):] |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
234 if path and path[0] == '/': |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
235 path = path[1:] |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
236 return path |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
237 |
1079
c1077b223648
svnmeta: factor out a property for obtaining the tag locations
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1045
diff
changeset
|
238 @property |
c1077b223648
svnmeta: factor out a property for obtaining the tag locations
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1045
diff
changeset
|
239 def taglocations(self): |
c1077b223648
svnmeta: factor out a property for obtaining the tag locations
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1045
diff
changeset
|
240 return self.layoutobj.taglocations(self.meta_data_dir) |
c1077b223648
svnmeta: factor out a property for obtaining the tag locations
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1045
diff
changeset
|
241 |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
242 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
|
243 """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
|
244 potential (non-empty) tag name. Otherwise, returns None |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
245 |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
246 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
|
247 (or tag) we have, for our purposes. |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
248 """ |
1027
16045f6f3fef
layouts: pull svn path -> potential tag name mapping into layouts
David Schleimer <dschleimer@fb.com>
parents:
1026
diff
changeset
|
249 path = self.normalize(path) |
1079
c1077b223648
svnmeta: factor out a property for obtaining the tag locations
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1045
diff
changeset
|
250 return self.layoutobj.get_path_tag(path, self.taglocations) |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
251 |
540
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
252 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
|
253 """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
|
254 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
|
255 |
724 | 256 Returns a tuple of (path within branch, local branch name, server-side |
257 branch path). | |
203
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
258 |
540
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
259 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
|
260 is a tag then: |
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
261 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
|
262 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
|
263 tags/tag-1.2 => (None, None, None) |
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
264 |
724 | 265 If existing=True, will return None, None, None if the file isn't on |
266 some known branch. If existing=False, then it will guess what the | |
267 branch would be if it were known. Server-side branch path should be | |
268 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
|
269 """ |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
270 path = self.normalize(path) |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
271 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
|
272 if tag: |
521
839734dfb5c7
Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
520
diff
changeset
|
273 # 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
|
274 matched = [] |
839734dfb5c7
Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
520
diff
changeset
|
275 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
|
276 matched += [t for t in tags |
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
277 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
|
278 if not matched: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
279 return None, None, None |
521
839734dfb5c7
Handle tag subdirectory as tag in replay mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
520
diff
changeset
|
280 matched.sort(key=len, reverse=True) |
536
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
281 if tag == matched[0]: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
282 brpath = '' |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
283 svrpath = path |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
284 else: |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
285 brpath = tag[len(matched[0])+1:] |
460eb781d840
Handle subdirectory tags in stupid mode (issue119)
Patrick Mezard <pmezard@gmail.com>
parents:
534
diff
changeset
|
286 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
|
287 ln = self.localname(svrpath) |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
288 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
|
289 |
513f2b607b06
layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents:
1027
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 |
513f2b607b06
layouts: pull out logic for splitting svn paths into branch and local parts
David Schleimer <dschleimer@fb.com>
parents:
1027
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 |
414
343da842dbe6
split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
413
diff
changeset
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 self.branches) |
9a7e3dbd0f6e
layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents:
1079
diff
changeset
|
308 # 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
|
309 # 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
|
310 # 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
|
311 # 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
|
312 # our root |
9a7e3dbd0f6e
layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents:
1079
diff
changeset
|
313 if fpath == '': |
9a7e3dbd0f6e
layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents:
1079
diff
changeset
|
314 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
|
315 else: |
9a7e3dbd0f6e
layouts: add support for an infix between tbt and the hg root
David Schleimer <dschleimer@fb.com>
parents:
1079
diff
changeset
|
316 ln = self.localname(p) |
519
247110c633f7
maps: TagMap tags are non-empty strings
Patrick Mezard <pmezard@gmail.com>
parents:
517
diff
changeset
|
317 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
|
318 changeid = self.tags[src_tag] |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
319 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
|
320 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
|
321 return {} |
343da842dbe6
split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
413
diff
changeset
|
322 |
950
a80b01ceb1fc
editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents:
888
diff
changeset
|
323 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
|
324 if path is None: |
6eb691a163cd
hg_delta_editor: stop using foobaz as a bogus filename.
Augie Fackler <durin42@gmail.com>
parents:
214
diff
changeset
|
325 return False |
950
a80b01ceb1fc
editor: relax copyfrom dir checks to avoid extra missing entries
Patrick Mezard <patrick@mezard.eu>
parents:
888
diff
changeset
|
326 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
|
327 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
|
328 return False |
409
d4615986e1db
extract the filemap support into a separate class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
329 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
|
330 |
584
d000b9a361e4
svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents:
575
diff
changeset
|
331 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
|
332 """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
|
333 (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
|
334 |
d000b9a361e4
svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents:
575
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 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
|
339 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
|
340 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
341 if (number, branch) in self.revmap: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
342 return number, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
343 real_num = 0 |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
344 for num, br in self.revmap.iterkeys(): |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
345 if br != branch: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
346 continue |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
347 if num <= number and num > real_num: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 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
|
352 # 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
|
353 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
|
354 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
|
355 # 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
|
356 # 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 # 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
|
364 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
|
365 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
|
366 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
|
367 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
|
368 parent_branch_rev, parent_branch) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
369 if real_num != 0: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
370 return real_num, branch |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
371 return None, None |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
372 |
584
d000b9a361e4
svnmeta: add exact arg to get_parent_revision() to handle 'R'
Patrick Mezard <pmezard@gmail.com>
parents:
575
diff
changeset
|
373 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
|
374 '''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
|
375 ''' |
517
ef288fb7f2fe
svnmeta: is_path_tag() is really get_path_tag()
Patrick Mezard <pmezard@gmail.com>
parents:
499
diff
changeset
|
376 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
|
377 if tag: |
537
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
378 # Reference a tag being created |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
379 if tag in self.addedtags: |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
380 tbranch, trev = self.addedtags[tag] |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
381 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
|
382 if not fromtag: |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
383 # 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
|
384 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
|
385 return node.hex(self.revmap[tagged]) |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
386 tag = fromtag |
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
387 # Reference an existing tag |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
831
diff
changeset
|
388 limitedtags = maps.Tags(self.repo, endrev=number - 1) |
533
7b330c576920
svnmeta: speedup get_parent_revision() in common case
Patrick Mezard <pmezard@gmail.com>
parents:
521
diff
changeset
|
389 if tag in limitedtags: |
537
3c8b86949072
svnmeta: make get_parent_revision() handle added tags
Patrick Mezard <pmezard@gmail.com>
parents:
536
diff
changeset
|
390 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
|
391 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
|
392 if r is not None: |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
393 return self.revmap[r, br] |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
394 return revlog.nullid |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
395 |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
396 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
|
397 """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
|
398 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
|
399 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
|
400 |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
401 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
|
402 """ |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
403 if ctx is None: |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
404 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
|
405 extra = ctx.extra() |
eea224fa1156
svnmeta: improve error message in get_source_rev()
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
594
diff
changeset
|
406 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
|
407 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
|
408 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
|
409 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
|
410 if branchpath and branchpath[0] == '/': |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
411 branchpath = branchpath[1:] |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
412 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
|
413 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
414 def update_branch_tag_map_for_rev(self, revision): |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
415 """Given a revision object, determine changes to branches. |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
416 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
417 Returns: a dict of { |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
418 'branches': (added_branches, self.closebranches), |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
419 } 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
|
420 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
|
421 sets of the deleted branches. |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
474
diff
changeset
|
422 """ |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
423 paths = revision.paths |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
424 added_branches = {} |
538
93bb37e38675
svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents:
537
diff
changeset
|
425 # 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
|
426 # 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
|
427 # use them. |
93bb37e38675
svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents:
537
diff
changeset
|
428 self.addedtags, self.deletedtags = {}, {} |
93bb37e38675
svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents:
537
diff
changeset
|
429 addedtags, deletedtags = {}, {} |
414
343da842dbe6
split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
413
diff
changeset
|
430 self.closebranches = set() |
131
4d42dbbb5127
hg_delta_editor: fix parent revision detection on branch copy
Patrick Mezard <pmezard@gmail.com>
parents:
124
diff
changeset
|
431 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
|
432 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
|
433 if t_name: |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
434 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
|
435 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
|
436 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
|
437 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
|
438 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
|
439 continue |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
440 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
|
441 # Ignore copies from unknown tags |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
442 continue |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
443 if not file: |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
444 # Direct branch or tag copy |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
445 if from_tag: |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
446 changeid = self.tags[from_tag] |
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
447 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
|
448 if t_name not in addedtags: |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
449 addedtags[t_name] = branch, src_rev |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
450 else: |
36eb608b831b
svnmeta: make tag detection code more explicity
Patrick Mezard <pmezard@gmail.com>
parents:
538
diff
changeset
|
451 # Subbranch or subtag copy |
381
a441ba143ac8
tags: fix handling for certain nonstandard tag layouts.
Augie Fackler <durin42@gmail.com>
parents:
380
diff
changeset
|
452 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
|
453 found = t_name in addedtags |
93bb37e38675
svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents:
537
diff
changeset
|
454 if found and src_rev > addedtags[t_name][1]: |
545
ebd8fb1a05e4
clean up trailing whitespace
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
455 addedtags[t_name] = branch, src_rev |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
456 elif (paths[p].action == 'D' and p.endswith(t_name) |
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
457 and t_name in self.tags): |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
458 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
|
459 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
|
460 continue |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
461 |
312
4dc197f533c1
hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents:
290
diff
changeset
|
462 # 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
|
463 # 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
|
464 # 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
|
465 # checks: |
4dc197f533c1
hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents:
290
diff
changeset
|
466 # 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
|
467 # 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
|
468 # interesting. |
952
9c3b4f59e7e6
stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents:
950
diff
changeset
|
469 # 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
|
470 # 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
|
471 # 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
|
472 # 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
|
473 # 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
|
474 # 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
|
475 # 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
|
476 # 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
|
477 # (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
|
478 # 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
|
479 # we do nothing here. |
4dc197f533c1
hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents:
290
diff
changeset
|
480 # 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
|
481 # 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
|
482 # 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
|
483 # 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
|
484 # 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
|
485 # directory - the action will be 'R'. |
540
8dc759dc9ca9
svnmeta: remove split_branch_tag() exacttag argument
Patrick Mezard <pmezard@gmail.com>
parents:
539
diff
changeset
|
486 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
|
487 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
|
488 if fi == '': |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
489 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
|
490 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
|
491 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
|
492 # 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
|
493 # 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
|
494 # 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
|
495 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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 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
|
501 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
|
502 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
|
503 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
|
504 continue |
312
4dc197f533c1
hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents:
290
diff
changeset
|
505 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
|
506 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
|
507 revision.revnum) |
4dc197f533c1
hg_delta_editor: reformat huge comment, rename __determine_parent_branch()
Patrick Mezard <pmezard@gmail.com>
parents:
290
diff
changeset
|
508 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
|
509 continue # case 1 |
907c160c6289
Refactor branch handling to be much more dynamic (and hopefully robust).
Augie Fackler <durin42@gmail.com>
parents:
198
diff
changeset
|
510 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
|
511 for known in self.branches: |
417
8630d1ebcdb9
svnmeta: deprivatize a bunch of member functions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
416
diff
changeset
|
512 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
|
513 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
|
514 parent = self._determine_parent_branch( |
724 | 515 p, paths[p].copyfrom_path, paths[p].copyfrom_rev, |
516 revision.revnum) | |
313
942f198b8ff5
hg_delta_editor: detect new branches issued from non-branch directories
Patrick Mezard <pmezard@gmail.com>
parents:
312
diff
changeset
|
517 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
|
518 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
|
519 if (bpath is not None |
cc7a10efddc9
Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents:
350
diff
changeset
|
520 and branch not in self.branches |
cc7a10efddc9
Fix a bug in branch ancestry calculation.
Augie Fackler <durin42@gmail.com>
parents:
350
diff
changeset
|
521 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
|
522 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
|
523 elif bpath is None: |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
524 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
|
525 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
|
526 parent = {} |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
527 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
|
528 rn = self.remotename(br) |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
529 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
|
530 bname = posixpath.basename(rn) |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
531 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
|
532 parent.update( |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
533 self._determine_parent_branch( |
d17cec76e769
replay: correctly handle renaming the parent dir of a branch
Augie Fackler <durin42@gmail.com>
parents:
547
diff
changeset
|
534 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
|
535 added_branches.update(parent) |
538
93bb37e38675
svnmeta: do not change added/deletedtags while detecting them
Patrick Mezard <pmezard@gmail.com>
parents:
537
diff
changeset
|
536 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
|
537 return { |
414
343da842dbe6
split parts of HgChangeReceiver out into an SVNMeta class
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
413
diff
changeset
|
538 '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
|
539 } |
ce64d57172a3
Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
365
diff
changeset
|
540 |
ce64d57172a3
Generate separate data structure containing revision's tags/branches changes.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
365
diff
changeset
|
541 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
|
542 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
|
543 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
|
544 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
|
545 self.branches.update(tbdelta['branches'][0]) |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
546 |
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
|
547 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
|
548 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
|
549 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
|
550 |
a400f3bf5611
replay/stupid: fix tagging on a branch renamed using a branch map
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
632
diff
changeset
|
551 # 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
|
552 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
|
553 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
|
554 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
|
555 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
|
556 |
832
e9af7eba88db
globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents:
831
diff
changeset
|
557 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
|
558 if '.hgtags' in parentctx: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
559 tagdata = parentctx.filectx('.hgtags').data() |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
560 else: |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
561 tagdata = '' |
729 | 562 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
|
563 def hgtagsfn(repo, memctx, path): |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
564 assert path == '.hgtags' |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
565 return context.memfilectx(path=path, |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
566 data=tagdata, |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
567 islink=False, |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
568 isexec=False, |
545
ebd8fb1a05e4
clean up trailing whitespace
Augie Fackler <durin42@gmail.com>
parents:
540
diff
changeset
|
569 copied=False) |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
570 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
|
571 newparent = None |
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
451
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 newparent = child |
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
451
diff
changeset
|
576 if newparent: |
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
451
diff
changeset
|
577 parentctx = newparent |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
578 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
|
579 ctx = context.memctx(self.repo, |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
580 (parentctx.node(), node.nullid), |
1045
67e11b650e94
handle invalid UTF-8 in commit messages consistently
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1032
diff
changeset
|
581 util.getmessage(self.ui, rev), |
447
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
582 ['.hgtags', ], |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
583 hgtagsfn, |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
584 self.authors[rev.author], |
0d3b5acb1d51
tags: handle edits to tags as gracefully as possible
Augie Fackler <durin42@gmail.com>
parents:
423
diff
changeset
|
585 date, |
534
e38f110e7088
svnmeta: make it easier to get converted revision info
Patrick Mezard <pmezard@gmail.com>
parents:
533
diff
changeset
|
586 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
|
587 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
|
588 if not newparent: |
ae35c389cdef
tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents:
451
diff
changeset
|
589 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
|
590 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
|
591 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
|
592 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
|
593 |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
594 def committags(self, rev, endbranches): |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
595 if not self.addedtags and not self.deletedtags: |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
596 return |
376
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
597 date = self.fixdate(rev.date) |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
598 # determine additions/deletions per branch |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
599 branches = {} |
520
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
600 for tags in (self.addedtags, self.deletedtags): |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
601 for tag, (branch, srcrev) in tags.iteritems(): |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
602 op = srcrev is None and 'rm' or 'add' |
5a5b90a6d522
svnmeta: internalize tags delta
Patrick Mezard <pmezard@gmail.com>
parents:
519
diff
changeset
|
603 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
|
604 |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
605 for b, tags in branches.iteritems(): |
726
8d36054b04ed
keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
724
diff
changeset
|
606 |
376
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
607 # modify parent's .hgtags source |
726
8d36054b04ed
keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
724
diff
changeset
|
608 |
389
a8811c84e3ee
tags: Fix an improper parent calculation.
Augie Fackler <durin42@gmail.com>
parents:
386
diff
changeset
|
609 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
|
610 if '.hgtags' not in parent: |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
611 src = '' |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
612 else: |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
613 src = parent['.hgtags'].data() |
726
8d36054b04ed
keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
724
diff
changeset
|
614 |
8d36054b04ed
keep variables more local, add some whitespace
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
724
diff
changeset
|
615 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
|
616 for op, tag, r in sorted(tags, reverse=True): |
729 | 617 |
618 if tag in self.tagmap and not self.tagmap[tag]: | |
619 continue | |
620 | |
621 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
|
622 if op == 'add': |
451
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
623 if fromtag: |
455
54e57da61c1a
This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents:
452
diff
changeset
|
624 if fromtag in self.tags: |
54e57da61c1a
This patch fixes, partially, an issue with tagpaths.
Michael J. Pedersen <mpedersen@datapipe.com>
parents:
452
diff
changeset
|
625 tagged = node.hex(self.tags[fromtag]) |
451
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
626 else: |
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
627 tagged = node.hex(self.revmap[ |
575
c278a225b750
svnmeta: reverse parameter calculation to lessen complexity
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
574
diff
changeset
|
628 self.get_parent_svn_branch_and_rev(r, b)]) |
729 | 629 |
630 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
|
631 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
|
632 |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
633 # add new changeset containing updated .hgtags |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
634 def fctxfun(repo, memctx, path): |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
635 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
|
636 islink=False, isexec=False, |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
637 copied=None) |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
638 |
422
6086363e8230
svnmeta: move util.build_extra() to SVNMeta.genextra()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
421
diff
changeset
|
639 extra = self.genextra(rev.revnum, b) |
451
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
640 if fromtag: |
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
641 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
|
642 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
|
643 |
376
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
644 ctx = context.memctx(self.repo, |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
645 (parent.node(), node.nullid), |
1045
67e11b650e94
handle invalid UTF-8 in commit messages consistently
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1032
diff
changeset
|
646 util.getmessage(self.ui, rev), |
376
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
647 ['.hgtags'], |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
648 fctxfun, |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
649 self.authors[rev.author], |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
650 date, |
9327e9325645
Use tbdelta to push added tags into .hgtags.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
375
diff
changeset
|
651 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
|
652 new = self.repo.svn_commitctx(ctx) |
451
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
653 |
e533e78f1b2f
tags: handle tags from edited tags.
Augie Fackler <durin42@gmail.com>
parents:
450
diff
changeset
|
654 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
|
655 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
|
656 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
|
657 endbranches.pop(b) |
94f7e8c53c36
tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
398
diff
changeset
|
658 bname = b or 'default' |
94f7e8c53c36
tags: end branch while tagging instead of creating extra changeset
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
398
diff
changeset
|
659 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
|
660 |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
661 def delbranch(self, branch, node, rev): |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
662 pctx = self.repo[node] |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
663 files = pctx.manifest().keys() |
423
021bdbf391bb
put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
422
diff
changeset
|
664 extra = self.genextra(rev.revnum, branch) |
574
8e025a6f0db4
add basic branchmap functionality, to rename branches
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
551
diff
changeset
|
665 self.mapbranch(extra, True) |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
666 ctx = context.memctx(self.repo, |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
667 (node, revlog.nullid), |
1045
67e11b650e94
handle invalid UTF-8 in commit messages consistently
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
1032
diff
changeset
|
668 util.getmessage(self.ui, rev), |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
669 [], |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
670 lambda x, y, z: None, |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
671 self.authors[rev.author], |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
672 self.fixdate(rev.date), |
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
673 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
|
674 new = self.repo.svn_commitctx(ctx) |
413
ac0cc3c9ea63
sort HgChangeReceiver methods and properties
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
411
diff
changeset
|
675 self.ui.status('Marked branch %s as closed.\n' % (branch or 'default')) |