Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/hg.py @ 5378:8a2915f57dfc
convert: add a mode where mercurial_sink skips empty revisions.
The getchanges function of some converter_source classes can return
some false positives. I.e. they sometimes claim that a file "foo"
was changed in some revision, even though its contents are still the
same.
convert_svn is particularly bad, but I think this can also happen with
convert_cvs and, at least in theory, with mercurial_source.
For regular conversions this is not really a problem - as long as
getfile returns the right contents, we'll get a converted revision
with the right contents. But when we use --filemap, this could lead
to superfluous revisions being converted.
Instead of fixing every converter_source, I decided to change
mercurial_sink to work around this problem.
When --filemap is used, we're interested only in revisions that touch
some specific files. If a revision doesn't change any of these files,
then we're not interested in it (at least for revisions with a single
parent; merges are special).
For mercurial_sink, we abuse this property and rollback a commit if
the manifest text hasn't changed. This avoids duplicating the logic
from localrepo.filecommit to detect unchanged files.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Thu, 04 Oct 2007 23:21:37 -0300 |
parents | b98c377b3c16 |
children | d3e51dc804f8 |
comparison
equal
deleted
inserted
replaced
5377:756a43a30e34 | 5378:8a2915f57dfc |
---|---|
26 self.repo = hg.repository(self.ui, path) | 26 self.repo = hg.repository(self.ui, path) |
27 except: | 27 except: |
28 raise NoRepo("could not open hg repo %s as sink" % path) | 28 raise NoRepo("could not open hg repo %s as sink" % path) |
29 self.lock = None | 29 self.lock = None |
30 self.wlock = None | 30 self.wlock = None |
31 self.filemapmode = False | |
31 | 32 |
32 def before(self): | 33 def before(self): |
33 self.wlock = self.repo.wlock() | 34 self.wlock = self.repo.wlock() |
34 self.lock = self.repo.lock() | 35 self.lock = self.repo.lock() |
35 self.repo.dirstate.clear() | 36 self.repo.dirstate.clear() |
94 for p in parents: | 95 for p in parents: |
95 if p not in seen: | 96 if p not in seen: |
96 pl.append(p) | 97 pl.append(p) |
97 seen[p] = 1 | 98 seen[p] = 1 |
98 parents = pl | 99 parents = pl |
100 nparents = len(parents) | |
101 if self.filemapmode and nparents == 1: | |
102 m1node = self.repo.changelog.read(bin(parents[0]))[0] | |
103 parent = parents[0] | |
99 | 104 |
100 if len(parents) < 2: parents.append("0" * 40) | 105 if len(parents) < 2: parents.append("0" * 40) |
101 if len(parents) < 2: parents.append("0" * 40) | 106 if len(parents) < 2: parents.append("0" * 40) |
102 p2 = parents.pop(0) | 107 p2 = parents.pop(0) |
103 | 108 |
115 bin(p1), bin(p2), extra=extra) | 120 bin(p1), bin(p2), extra=extra) |
116 self.repo.dirstate.clear() | 121 self.repo.dirstate.clear() |
117 text = "(octopus merge fixup)\n" | 122 text = "(octopus merge fixup)\n" |
118 p2 = hg.hex(self.repo.changelog.tip()) | 123 p2 = hg.hex(self.repo.changelog.tip()) |
119 | 124 |
125 if self.filemapmode and nparents == 1: | |
126 man = self.repo.manifest | |
127 mnode = self.repo.changelog.read(bin(p2))[0] | |
128 if not man.cmp(m1node, man.revision(mnode)): | |
129 self.repo.rollback() | |
130 self.repo.dirstate.clear() | |
131 return parent | |
120 return p2 | 132 return p2 |
121 | 133 |
122 def puttags(self, tags): | 134 def puttags(self, tags): |
123 try: | 135 try: |
124 old = self.repo.wfile(".hgtags").read() | 136 old = self.repo.wfile(".hgtags").read() |
151 tagparent = nullid | 163 tagparent = nullid |
152 self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", | 164 self.repo.rawcommit([".hgtags"], "update tags", "convert-repo", |
153 date, tagparent, nullid) | 165 date, tagparent, nullid) |
154 return hex(self.repo.changelog.tip()) | 166 return hex(self.repo.changelog.tip()) |
155 | 167 |
168 def setfilemapmode(self, active): | |
169 self.filemapmode = active | |
170 | |
156 class mercurial_source(converter_source): | 171 class mercurial_source(converter_source): |
157 def __init__(self, ui, path, rev=None): | 172 def __init__(self, ui, path, rev=None): |
158 converter_source.__init__(self, ui, path, rev) | 173 converter_source.__init__(self, ui, path, rev) |
159 try: | 174 try: |
160 self.repo = hg.repository(self.ui, path) | 175 self.repo = hg.repository(self.ui, path) |