Merge lp:~vmiklos/bzr-fastimport/darcs into lp:bzr-fastimport

Proposed by Miklos Vajna
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vmiklos/bzr-fastimport/darcs
Merge into: lp:bzr-fastimport
Diff against target: 188 lines (+58/-36)
3 files modified
exporters/darcs/darcs-fast-export (+19/-33)
exporters/darcs/git-darcs (+18/-2)
exporters/darcs/git-darcs.txt (+21/-1)
To merge this branch: bzr merge lp:~vmiklos/bzr-fastimport/darcs
Reviewer Review Type Date Requested Status
Ian Clatworthy Approve
Review via email: mp+21512@code.launchpad.net

Description of the change

- 3 minor patches i forgot to push out (a bugfix, a small feature and a documentation update)
- a patch from bug 538933

To post a comment you must log in.
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

I'll merge

review: Approve
lp:~vmiklos/bzr-fastimport/darcs updated
276. By Ian Clatworthy

Merge patches from Miklos for darcs-fast-export

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'exporters/darcs/darcs-fast-export'
2--- exporters/darcs/darcs-fast-export 2010-01-24 23:45:31 +0000
3+++ exporters/darcs/darcs-fast-export 2010-03-17 00:20:31 +0000
4@@ -47,30 +47,6 @@
5 self.export_marks = []
6 self.import_marks = []
7
8- def __get_zone(self):
9- now = time.localtime()
10- if time.daylight and now[-1]:
11- offset = time.altzone
12- else:
13- offset = time.timezone
14- hours, minutes = divmod(abs(offset), 3600)
15- if offset > 0:
16- sign = "-"
17- else:
18- sign = "+"
19- return sign, hours, minutes
20-
21- def get_zone_str(self):
22- sign, hours, minutes = self.__get_zone()
23- return "%s%02d%02d" % (sign, hours, minutes // 60)
24-
25- def get_zone_int(self):
26- sign, hours, minutes = self.__get_zone()
27- ret = hours*3600+minutes*60
28- if sign == "-":
29- ret *= -1
30- return ret
31-
32 def get_patchname(self, patch):
33 ret = []
34 s = ""
35@@ -106,12 +82,22 @@
36 author = author[author.index('>')+2:] + ' ' + author[:author.index('>')+1]
37 return author.encode('utf-8')
38
39- def get_date(self, patch):
40- try:
41- date = time.strptime(patch, "%Y%m%d%H%M%S")
42- except ValueError:
43- date = time.strptime(patch[:19] + patch[-5:], '%a %b %d %H:%M:%S %Y')
44- return int(time.mktime(date)) + self.get_zone_int()
45+ def get_time_info(self, patch):
46+ date = time.strptime(patch, "%a %b %d %H:%M:%S %Z %Y")
47+ timestamp = int(time.mktime(date))
48+ # calculate the timezone offset
49+ fields=re.split('[ ]+', patch)
50+ fields[4]="UTC"
51+ patch_utc=" ".join(fields)
52+ date_utc=time.strptime(patch_utc, "%a %b %d %H:%M:%S %Z %Y")
53+ offset=int(time.timezone + time.mktime(date) - time.mktime(date_utc))
54+ hours, minutes = divmod(abs(offset), 3600)
55+ if offset > 0:
56+ sign = "-"
57+ else:
58+ sign = "+"
59+ zone = "%s%02d%02d" % (sign, hours, minutes // 60)
60+ return timestamp, zone
61
62 def progress(self, s):
63 print "progress [%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), s)
64@@ -343,8 +329,8 @@
65 print "mark :%s" % markcount
66 if self.options.export_marks:
67 self.export_marks.append(":%s %s" % (markcount, hash))
68- date = self.get_date(i.attributes['date'].value)
69- print "committer %s %s %s" % (self.get_author(i), date, self.get_zone_str())
70+ date, zone = self.get_time_info(i.attributes['local_date'].value)
71+ print "committer %s %s %s" % (self.get_author(i), date, zone)
72 print "data %d\n%s" % (len(message), message)
73 if markcount > 1:
74 print "from :%s" % (markcount-1)
75@@ -368,7 +354,7 @@
76 tag = re.sub('[^\xe9-\xf8\w.\-]+', '_', message[4:].strip().split('\n')[0]).strip('_')
77 print "tag %s" % tag
78 print "from :%s" % markcount
79- print "tagger %s %s %s" % (self.get_author(i), date, self.get_zone_str())
80+ print "tagger %s %s %s" % (self.get_author(i), date, zone)
81 print "data %d\n%s" % (len(message), message)
82 if count % self.prognum == 0:
83 self.progress("%d/%d patches" % (count, patchnum))
84
85=== modified file 'exporters/darcs/git-darcs'
86--- exporters/darcs/git-darcs 2010-02-11 09:11:22 +0000
87+++ exporters/darcs/git-darcs 2010-03-17 00:20:31 +0000
88@@ -2,7 +2,7 @@
89 #
90 # git-darcs - bidirectional operation between a darcs repo and git
91 #
92-# Copyright (c) 2008 by Miklos Vajna <vmiklos@frugalware.org>
93+# Copyright (c) 2008, 2010 by Miklos Vajna <vmiklos@frugalware.org>
94 #
95 # Based on git-bzr, which is
96 #
97@@ -48,9 +48,9 @@
98 exit
99 fi
100 git config git-darcs.$name.location $location
101- git config git-darcs.$name.darcs-fast-export-options "$*"
102 echo "Darcs repo $name added. You can fetch it with 'git darcs fetch $name'"
103 if ! [ -z "$*" ]; then
104+ git config git-darcs.$name.darcs-fast-export-options "$*"
105 echo "darcs-fast-export will get options: $*"
106 fi
107 }
108@@ -78,6 +78,10 @@
109 darcs_map=$git_dir/darcs-git/$remote-darcs-map
110 common_opts="--working $git_dir/darcs-git/repo --logfile $git_dir/darcs-git/fetch.log --git-branch=darcs/$remote"
111 dfe_opts=$(git config git-darcs.$remote.darcs-fast-export-options)
112+ pre_fetch="$(git config git-darcs.$remote.pre-fetch)"
113+ if [ -n "$pre_fetch" ]; then
114+ $pre_fetch
115+ fi
116 if [ ! -f $git_map -a ! -f $darcs_map ]; then
117 echo "There doesn't seem to be an existing refmap."
118 echo "Doing an initial import"
119@@ -101,6 +105,10 @@
120 echo "One of the mapfiles is missing! Something went wrong!"
121 exit
122 fi
123+ post_fetch="$(git config git-darcs.$remote.post-fetch)"
124+ if [ -n "$post_fetch" ]; then
125+ $post_fetch
126+ fi
127 }
128
129 pull()
130@@ -144,6 +152,10 @@
131 echo "We do not have refmapping yet. Then how can I push?"
132 exit
133 fi
134+ pre_push="$(git config git-darcs.$remote.pre-push)"
135+ if [ -n "$pre_push" ]; then
136+ $pre_push
137+ fi
138 echo "Pushing the following updates:"
139 git shortlog darcs/$remote..
140 git fast-export --import-marks=$git_map --export-marks=$git_map HEAD | \
141@@ -151,6 +163,10 @@
142 --logfile $git_dir/darcs-git/push.log)
143 if [ $? == 0 ]; then
144 git update-ref darcs/$remote HEAD
145+ post_push="$(git config git-darcs.$remote.post-push)"
146+ if [ -n "$post_push" ]; then
147+ $post_push
148+ fi
149 fi
150 }
151
152
153=== modified file 'exporters/darcs/git-darcs.txt'
154--- exporters/darcs/git-darcs.txt 2009-06-28 22:31:05 +0000
155+++ exporters/darcs/git-darcs.txt 2010-03-17 00:20:31 +0000
156@@ -20,7 +20,7 @@
157 $ mkdir git-repo
158 $ cd git-repo
159 $ git init
160-$ git darcs add upstream ../darcs-repo
161+$ git darcs add upstream /path/to/darcs-repo
162 $ git darcs pull upstream
163
164 ... hack, hack, hack ...
165@@ -70,3 +70,23 @@
166 find-git::
167 Searches for git commits matching a darcs patch prefix.
168 The syntax is `find-git <patch-prefix>`.
169+
170+== HOOKS
171+
172+It's possible to automatically run before and after the fetch and the
173+push subcommand. For example if you want to automatically run `darcs
174+pull -a` before a `git darcs fetch upstream`:
175+
176+----
177+git config git-darcs.upstream.pre-fetch "darcs pull -a --repodir=/path/to/darcs-repo"
178+----
179+
180+Or in case you want to automatically `darcs send` all patches after a
181+`git darcs push upstream`:
182+
183+----
184+git config git-darcs.upstream.post-push "darcs send -a --repodir=/path/to/darcs-repo"
185+----
186+
187+== SEE-ALSO
188+*git*(1), *darcs*(1)

Subscribers

People subscribed via source and target branches