Mercurial > hg
comparison hgext/convert/p4.py @ 30629:e92776c00ffd
convert: use return value in parse_view() instead of manipulating state
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Tue, 20 Dec 2016 09:23:50 -0800 |
parents | 32a07b8a9f77 |
children | 3830f8806094 |
comparison
equal
deleted
inserted
replaced
30628:a001cd7296a5 | 30629:e92776c00ffd |
---|---|
93 | 93 |
94 def _parse_view(self, path): | 94 def _parse_view(self, path): |
95 "Read changes affecting the path" | 95 "Read changes affecting the path" |
96 cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path) | 96 cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path) |
97 stdout = util.popen(cmd, mode='rb') | 97 stdout = util.popen(cmd, mode='rb') |
98 p4changes = {} | |
98 for d in loaditer(stdout): | 99 for d in loaditer(stdout): |
99 c = d.get("change", None) | 100 c = d.get("change", None) |
100 if c: | 101 if c: |
101 self.p4changes[c] = True | 102 p4changes[c] = True |
103 return p4changes | |
102 | 104 |
103 def _parse(self, ui, path): | 105 def _parse(self, ui, path): |
104 "Prepare list of P4 filenames and revisions to import" | 106 "Prepare list of P4 filenames and revisions to import" |
105 ui.status(_('reading p4 views\n')) | 107 ui.status(_('reading p4 views\n')) |
106 | 108 |
107 # read client spec or view | 109 # read client spec or view |
108 if "/" in path: | 110 if "/" in path: |
109 self._parse_view(path) | 111 self.p4changes.update(self._parse_view(path)) |
110 if path.startswith("//") and path.endswith("/..."): | 112 if path.startswith("//") and path.endswith("/..."): |
111 views = {path[:-3]:""} | 113 views = {path[:-3]:""} |
112 else: | 114 else: |
113 views = {"//": ""} | 115 views = {"//": ""} |
114 else: | 116 else: |
117 | 119 |
118 views = {} | 120 views = {} |
119 for client in clientspec: | 121 for client in clientspec: |
120 if client.startswith("View"): | 122 if client.startswith("View"): |
121 sview, cview = clientspec[client].split() | 123 sview, cview = clientspec[client].split() |
122 self._parse_view(sview) | 124 self.p4changes.update(self._parse_view(sview)) |
123 if sview.endswith("...") and cview.endswith("..."): | 125 if sview.endswith("...") and cview.endswith("..."): |
124 sview = sview[:-3] | 126 sview = sview[:-3] |
125 cview = cview[:-3] | 127 cview = cview[:-3] |
126 cview = cview[2:] | 128 cview = cview[2:] |
127 cview = cview[cview.find("/") + 1:] | 129 cview = cview[cview.find("/") + 1:] |