def parse_svn_dateprop(date): """Parse a Subversion date property and return a unix timestamp. :param date: A string containing a Subversion date string :return: Unix timestamp """ assert isinstance(date, str) return (properties.time_from_cstring(date) / 1000000.0, 0)
def test_time_from_cstring_independent_from_dst(self): old_tz = os.environ.get('TZ', None) # On Windows, there is no tzset function, so skip this test. if getattr(time, 'tzset', None) is None: raise SkipTest("tzset not available on Windows") try: # First specify a fixed timezone with known DST (late March to late October) os.environ['TZ'] = 'Europe/London' time.tzset() # Now test a time within that DST self.assertEqual(1275295762430000L, properties.time_from_cstring("2010-05-31T08:49:22.430000Z")) finally: if old_tz is None: del os.environ['TZ'] else: os.environ['TZ'] = old_tz time.tzset()
def test_time_from_cstring_independent_from_dst(self): old_tz = os.environ.get('TZ', None) # On Windows, there is no tzset function, so skip this test. if getattr(time, 'tzset', None) is None: raise SkipTest("tzset not available on Windows") try: # First specify a fixed timezone with known DST (late March to late October) os.environ['TZ'] = 'Europe/London' time.tzset() # Now test a time within that DST self.assertEqual( 1275295762430000L, properties.time_from_cstring("2010-05-31T08:49:22.430000Z")) finally: if old_tz is None: del os.environ['TZ'] else: os.environ['TZ'] = old_tz time.tzset()
def test_time_from_cstring(self): self.assertEqual(1225704780716938L, properties.time_from_cstring("2008-11-03T09:33:00.716938Z"))
def test_time_from_cstring(self): self.assertEqual( 1225704780716938, properties.time_from_cstring("2008-11-03T09:33:00.716938Z"))
def commit(self, rev, date, author, log, *, init_export, base_rev, base_path, gitrev, path, prefix, url): if not init_export and base_path != path[1:]: # Base revision is at a different branch location. # Will have to diff the base location against the # current location. Have to switch root because the # diff reporter does not accept link_path() on the # top-level directory. self.url = self.repos_root + "/" + base_path self.url = self.url.rstrip("/") self.ra.reparent(self.url) self.log(":") editor = RevEditor(self.output, self.quiet) # Diff editor does not convey deletions when starting # from scratch if init_export: dir = DirEditor(editor) for (file, (action, _, _)) in self.paths.items(): if not file.startswith(prefix) or action not in "DR": continue file = file[len(prefix):] for p in self.ignore: if file == p or file.startswith((p + "/").lstrip("/")): break else: dir.delete_entry(file) reporter = self.ra.do_diff(rev, "", url, editor, True, True, True) if init_export: reporter.set_path("", rev, True) else: reporter.set_path("", base_rev, False) for p in self.ignore: reporter.set_path(p, INVALID_REVNUM, True, None, subvertpy.ra.DEPTH_EXCLUDE) reporter.finish() # Assume the editor calls are all completed now merges = list() if editor.mergeinfo: self.log("\n") basehist = Ancestors(self) if base_rev: basehist.add_natural(base_path, base_rev) merged = RevisionSet() ancestors = Ancestors(self) merged.update(basehist) mergeinfo = editor.mergeinfo.items() for (branch, ranges) in mergeinfo: for (start, end, _) in ranges: merged.add_segment(branch, start, end) ancestors.add_natural(branch, end) if merged != basehist and ancestors == merged: # TODO: minimise so that only independent branch heads are listed # i.e. do not explicitly merge C if also merging A and B, and C is an ancestor of both A and B for (branch, ranges) in mergeinfo: branch = branch.lstrip("/") for (_, end, _) in ranges: ancestor = self.export(self.git_ref, branch, end) if ancestor is not None: merges.append(ancestor) self.output.printf("commit {}", self.git_ref) mark = self.output.newmark() self.output.printf("mark {}", mark) date = time_from_cstring(date) // 10**6 if self.author_map is None: author = "{author} <{author}@{uuid}>".format( author=author, uuid=self.uuid) else: author = self.author_map[author] self.output.printf("committer {} {} +0000", author, date) log = "{}\n\ngit-svn-id: {}{}@{} {}\n".format( log, self.root, path.rstrip("/"), rev, self.uuid) log = log.encode("utf-8") self.output.printf("data {}", len(log)) self.output.file.write(log) self.output.printf("") if (init_export or merges) and gitrev is not None: self.output.printf("from {}", gitrev) for ancestor in merges: self.output.printf("merge {}", ancestor) for line in editor.edits: self.output.printf("{}", line) self.output.printf("") return mark