[PATCH STABLE] archive: make it work with svn subrepos (issue3308)
Patrick Mezard
patrick at mezard.eu
Mon Apr 16 04:56:03 CDT 2012
# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1334569695 -7200
# Branch stable
# Node ID c9c8c905311992cae2e7cd90846d1b863a2a5c71
# Parent c3aedd526d530506891caf690ff9688404bb5ea8
archive: make it work with svn subrepos (issue3308)
- _svncommand() in files() returns a tuple since 0ae98cd2a83f not a string.
- _svncommand() in filedata() returns a tuple not a string.
- "svn list" returns files but also directories.
- "svn list" is not recursive by default.
I have no idea what happens to svn:externals possibly embedded in the svn
subrepository.
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -740,12 +740,21 @@
return True
def files(self):
- output = self._svncommand(['list'])
- # This works because svn forbids \n in filenames.
- return output.splitlines()
+ output = self._svncommand(['list', '--recursive', '--xml'])[0]
+ doc = xml.dom.minidom.parseString(output)
+ paths = []
+ for e in doc.getElementsByTagName('entry'):
+ kind = str(e.getAttribute('kind'))
+ if kind != 'file':
+ continue
+ name = ''.join(c.data for c
+ in e.getElementsByTagName('name')[0].childNodes
+ if c.nodeType == c.TEXT_NODE)
+ paths.append(name)
+ return paths
def filedata(self, name):
- return self._svncommand(['cat'], name)
+ return self._svncommand(['cat'], name)[0]
class gitsubrepo(abstractsubrepo):
diff --git a/tests/test-subrepo-svn.t b/tests/test-subrepo-svn.t
--- a/tests/test-subrepo-svn.t
+++ b/tests/test-subrepo-svn.t
@@ -543,3 +543,16 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ test -f recreated/somethingold
+Test archive
+
+ $ hg archive -S ../archive-all --debug
+ archiving: 0/2 files (0.00%)
+ archiving: .hgsub 1/2 files (50.00%)
+ archiving: .hgsubstate 2/2 files (100.00%)
+ archiving (obstruct): 0/1 files (0.00%)
+ archiving (obstruct): 1/1 files (100.00%)
+ archiving (s): 0/2 files (0.00%)
+ archiving (s): 1/2 files (50.00%)
+ archiving (s): 2/2 files (100.00%)
+ archiving (recreated): 0/1 files (0.00%)
+ archiving (recreated): 1/1 files (100.00%)
More information about the Mercurial-devel
mailing list