##// END OF EJS Templates
convert/darcs: handle directory renaming
Patrick Mezard -
r9527:b3c13e72 default
parent child Browse files
Show More
@@ -85,6 +85,17 b' class darcs_source(converter_source, com'
85 85 self.checkexit(fp.close())
86 86 return etree.getroot()
87 87
88 def manifest(self):
89 man = []
90 output, status = self.run('show', 'files', no_directories=True,
91 repodir=self.tmppath)
92 self.checkexit(status)
93 for line in output.split('\n'):
94 path = line[2:]
95 if path:
96 man.append(path)
97 return man
98
88 99 def getheads(self):
89 100 return self.parents[None]
90 101
@@ -107,19 +118,35 b' class darcs_source(converter_source, com'
107 118 output, status = self.run('revert', all=True, repodir=self.tmppath)
108 119 self.checkexit(status, output)
109 120
110 def getchanges(self, rev):
111 self.pull(rev)
121 def getchanges(self, rev):
112 122 copies = {}
113 123 changes = []
124 man = None
114 125 for elt in self.changes[rev].find('summary').getchildren():
115 126 if elt.tag in ('add_directory', 'remove_directory'):
116 127 continue
117 128 if elt.tag == 'move':
118 changes.append((elt.get('from'), rev))
119 changes.append((elt.get('to'), rev))
120 copies[elt.get('to')] = elt.get('from')
129 if man is None:
130 man = self.manifest()
131 source, dest = elt.get('from'), elt.get('to')
132 if source in man:
133 # File move
134 changes.append((source, rev))
135 changes.append((dest, rev))
136 copies[dest] = source
137 else:
138 # Directory move, deduce file moves from manifest
139 source = source + '/'
140 for f in man:
141 if not f.startswith(source):
142 continue
143 fdest = dest + '/' + f[len(source):]
144 changes.append((f, rev))
145 changes.append((fdest, rev))
146 copies[fdest] = f
121 147 else:
122 148 changes.append((elt.text.strip(), rev))
149 self.pull(rev)
123 150 self.lastrev = rev
124 151 return sorted(changes), copies
125 152
@@ -44,10 +44,17 b' darcs pull -a ../darcs-clone'
44 44 sleep 1
45 45 echo e > a
46 46 echo f > f
47 mkdir dir
48 echo d > dir/d
49 echo d > dir/d2
47 50 darcs record -a -l -m p2
48 51
49 52 echo % test file and directory move
50 53 darcs mv f ff
54 # Test remove + move
55 darcs remove dir/d2
56 rm dir/d2
57 darcs mv dir dir2
51 58 darcs record -a -l -m p3
52 59 cd ..
53 60
@@ -21,9 +21,9 b' 3 p1.2'
21 21 2 p1.1
22 22 1 p2
23 23 0 p3
24 o 4 "p3" files: f ff
24 o 4 "p3" files: dir/d dir/d2 dir2/d f ff
25 25 |
26 o 3 "p2" files: a f
26 o 3 "p2" files: a dir/d dir/d2 f
27 27 |
28 28 o 2 "p1.1" files:
29 29 |
@@ -33,4 +33,5 b' o 0 "p0" files: a'
33 33
34 34 7225b30cdf38257d5cc7780772c051b6f33e6d6b 644 a
35 35 1e88685f5ddec574a34c70af492f95b6debc8741 644 b
36 d278f41640da5fc303a4cf9894af31c2983fc11d 644 dir2/d
36 37 ef5c76581d78340f568d5f48d679bf307452cbc9 644 ff
General Comments 0
You need to be logged in to leave comments. Login now