Show More
@@ -2,17 +2,14 b'' | |||
|
2 | 2 | # |
|
3 | 3 | # Copyright(C) 2007 Daniel Holth et al |
|
4 | 4 | |
|
5 | import os | |
|
6 | import re | |
|
7 | import sys | |
|
5 | import os, re, sys, tempfile, urllib, urllib2, xml.dom.minidom | |
|
8 | 6 | import cPickle as pickle |
|
9 | import tempfile | |
|
10 | import urllib | |
|
11 | import urllib2 | |
|
12 | 7 | |
|
13 | 8 | from mercurial import strutil, scmutil, util, encoding |
|
14 | 9 | from mercurial.i18n import _ |
|
15 | 10 | |
|
11 | propertycache = util.propertycache | |
|
12 | ||
|
16 | 13 | # Subversion stuff. Works best with very recent Python SVN bindings |
|
17 | 14 | # e.g. SVN 1.5 or backports. Thanks to the bzr folks for enhancing |
|
18 | 15 | # these bindings. |
@@ -1057,6 +1054,29 b' class svn_sink(converter_sink, commandli' | |||
|
1057 | 1054 | def wjoin(self, *names): |
|
1058 | 1055 | return os.path.join(self.wc, *names) |
|
1059 | 1056 | |
|
1057 | @propertycache | |
|
1058 | def manifest(self): | |
|
1059 | # As of svn 1.7, the "add" command fails when receiving | |
|
1060 | # already tracked entries, so we have to track and filter them | |
|
1061 | # ourselves. | |
|
1062 | m = set() | |
|
1063 | output = self.run0('ls', recursive=True, xml=True) | |
|
1064 | doc = xml.dom.minidom.parseString(output) | |
|
1065 | for e in doc.getElementsByTagName('entry'): | |
|
1066 | for n in e.childNodes: | |
|
1067 | if n.nodeType != n.ELEMENT_NODE or n.tagName != 'name': | |
|
1068 | continue | |
|
1069 | name = ''.join(c.data for c in n.childNodes | |
|
1070 | if c.nodeType == c.TEXT_NODE) | |
|
1071 | # Entries are compared with names coming from | |
|
1072 | # mercurial, so bytes with undefined encoding. Our | |
|
1073 | # best bet is to assume they are in local | |
|
1074 | # encoding. They will be passed to command line calls | |
|
1075 | # later anyway, so they better be. | |
|
1076 | m.add(encoding.tolocal(name.encode('utf-8'))) | |
|
1077 | break | |
|
1078 | return m | |
|
1079 | ||
|
1060 | 1080 | def putfile(self, filename, flags, data): |
|
1061 | 1081 | if 'l' in flags: |
|
1062 | 1082 | self.wopener.symlink(data, filename) |
@@ -1099,6 +1119,7 b' class svn_sink(converter_sink, commandli' | |||
|
1099 | 1119 | try: |
|
1100 | 1120 | self.run0('copy', source, dest) |
|
1101 | 1121 | finally: |
|
1122 | self.manifest.add(dest) | |
|
1102 | 1123 | if exists: |
|
1103 | 1124 | try: |
|
1104 | 1125 | os.unlink(wdest) |
@@ -1117,13 +1138,16 b' class svn_sink(converter_sink, commandli' | |||
|
1117 | 1138 | |
|
1118 | 1139 | def add_dirs(self, files): |
|
1119 | 1140 | add_dirs = [d for d in sorted(self.dirs_of(files)) |
|
1120 |
if not |
|
|
1141 | if d not in self.manifest] | |
|
1121 | 1142 | if add_dirs: |
|
1143 | self.manifest.update(add_dirs) | |
|
1122 | 1144 | self.xargs(add_dirs, 'add', non_recursive=True, quiet=True) |
|
1123 | 1145 | return add_dirs |
|
1124 | 1146 | |
|
1125 | 1147 | def add_files(self, files): |
|
1148 | files = [f for f in files if f not in self.manifest] | |
|
1126 | 1149 | if files: |
|
1150 | self.manifest.update(files) | |
|
1127 | 1151 | self.xargs(files, 'add', quiet=True) |
|
1128 | 1152 | return files |
|
1129 | 1153 | |
@@ -1133,6 +1157,7 b' class svn_sink(converter_sink, commandli' | |||
|
1133 | 1157 | wd = self.wjoin(d) |
|
1134 | 1158 | if os.listdir(wd) == '.svn': |
|
1135 | 1159 | self.run0('delete', d) |
|
1160 | self.manifest.remove(d) | |
|
1136 | 1161 | deleted.append(d) |
|
1137 | 1162 | return deleted |
|
1138 | 1163 | |
@@ -1170,6 +1195,8 b' class svn_sink(converter_sink, commandli' | |||
|
1170 | 1195 | self.copies = [] |
|
1171 | 1196 | if self.delete: |
|
1172 | 1197 | self.xargs(self.delete, 'delete') |
|
1198 | for f in self.delete: | |
|
1199 | self.manifest.remove(f) | |
|
1173 | 1200 | self.delete = [] |
|
1174 | 1201 | entries.update(self.add_files(files.difference(entries))) |
|
1175 | 1202 | entries.update(self.tidy_dirs(entries)) |
General Comments 0
You need to be logged in to leave comments.
Login now