Mercurial > hg > mercurial-crew-with-dirclash
comparison hgext/convert/subversion.py @ 4787:c5dd8e184279
convert: svn: add function to get the latest revision touching a path
Make it work for HTTP URLs
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Tue, 03 Jul 2007 12:44:04 -0700 |
parents | 62e1b6412b62 |
children | c2ef09a35c53 |
comparison
equal
deleted
inserted
replaced
4786:62e1b6412b62 | 4787:c5dd8e184279 |
---|---|
118 try: | 118 try: |
119 self.get_blacklist() | 119 self.get_blacklist() |
120 except IOError, e: | 120 except IOError, e: |
121 pass | 121 pass |
122 | 122 |
123 if not latest: | 123 self.last_changed = self.latest(self.module, latest) |
124 latest = svn.ra.get_latest_revnum(self.ra) | |
125 dirent = svn.ra.stat(self.ra, self.module, latest) | |
126 if not dirent: | |
127 raise util.Abort('module %s not found in revision %d' % (self.module, latest)) | |
128 self.last_changed = dirent.created_rev | |
129 | 124 |
130 self.head = self.rev(self.last_changed) | 125 self.head = self.rev(self.last_changed) |
131 | 126 |
132 def rev(self, revnum): | 127 def rev(self, revnum): |
133 return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding) | 128 return (u"svn:%s%s@%s" % (self.uuid, self.module, revnum)).decode(self.encoding) |
134 | 129 |
135 def revnum(self, rev): | 130 def revnum(self, rev): |
136 return int(rev.split('@')[-1]) | 131 return int(rev.split('@')[-1]) |
137 | 132 |
133 def latest(self, path, revnum, stop=0): | |
134 'find the latest revision affecting path, up to stop' | |
135 if not stop: | |
136 stop = svn.ra.get_latest_revnum(self.ra) | |
137 try: | |
138 self.reparent('') | |
139 dirent = svn.ra.stat(self.ra, path.strip('/'), stop) | |
140 self.reparent(self.module) | |
141 except SubversionException: | |
142 dirent = None | |
143 if not dirent: | |
144 raise util.Abort('module %s not found up to revision %d' \ | |
145 % (self.module, stop)) | |
146 | |
147 return dirent.created_rev | |
148 | |
138 def get_blacklist(self): | 149 def get_blacklist(self): |
139 """Avoid certain revision numbers. | 150 """Avoid certain revision numbers. |
140 It is not uncommon for two nearby revisions to cancel each other | 151 It is not uncommon for two nearby revisions to cancel each other |
141 out, e.g. 'I copied trunk into a subdirectory of itself instead | 152 out, e.g. 'I copied trunk into a subdirectory of itself instead |
142 of making a branch'. The converted repository is significantly | 153 of making a branch'. The converted repository is significantly |